1 package org.jmage.dispatcher;
2
3 import org.apache.log4j.Logger;
4 import org.jmage.ImageRequest;
5 import org.jmage.JmageException;
6 import org.jmage.filterchain.FilterChainManager;
7 import org.jmage.resource.ResourceManager;
8
9 /***
10 * InternalFilteringRequestDispatcher omits encoding and has all other steps defined as optional. If no image is
11 * specified, or if it finds an imageURI, it tries to load one through resourceManager. If a chain URI is specified,
12 * it filters the image through it, else it returns straight away.
13 */
14 public class InternalRequestDispatcher extends FilteringRequestDispatcher {
15 protected static Logger log = Logger.getLogger(InternalRequestDispatcher.class.getName());
16
17 /***
18 * Dispatch an ImageRequest for internal purposes.
19 */
20 public void dispatch(ImageRequest imageRequest) throws JmageException {
21 if (imageRequest.getImage() == null || imageRequest.getImageURI() !=null) {
22 ResourceManager resourceManager = context.obtainResourceManager();
23 resourceManager.handle(imageRequest);
24 context.releaseResourceManager(resourceManager);
25 }
26
27 if (imageRequest.getFilterChainURI() != null) {
28
29 imageRequest.getFilterChainProperties().clear();
30
31 FilterChainManager filterChainManager = context.obtainFilterChainManager();
32 filterChainManager.handle(imageRequest);
33 context.releaseFilterChainManager(filterChainManager);
34 }
35 }
36 }