1 package org.jmage.mapper;
2
3 import org.apache.log4j.Logger;
4 import org.jmage.ApplicationContext;
5 import org.jmage.ImageRequest;
6 import org.jmage.JmageException;
7 import org.jmage.dispatcher.RequestDispatcher;
8
9 /***
10 * Maps and handles an ImageRequest
11 */
12 public class ImageRequestMapper {
13 protected ImageRequest imageRequest;
14 protected ApplicationContext context;
15 protected static Logger log = Logger.getLogger(ImageRequestMapper.class.getName());
16
17 public ImageRequestMapper() {
18 context = ApplicationContext.getContext();
19 }
20
21 public ImageRequest getImageRequest() {
22 return imageRequest;
23 }
24
25 public void setImageRequest(ImageRequest imageRequest) {
26 this.imageRequest = imageRequest;
27 }
28
29 public byte[] processRequest() throws JmageException {
30
31 RequestDispatcher dispatcher = context.obtainRequestDispatcher();
32
33
34 dispatcher.dispatch(imageRequest);
35
36
37 context.releaseRequestDispatcher(dispatcher);
38
39 return imageRequest.getEncoded();
40 }
41 }