View Javadoc
1   /*
2    * Created on 16-May-2005
3    */
4   package ca.uhn.hl7v2.protocol.impl;
5   
6   import java.util.Map;
7   
8   import ca.uhn.hl7v2.HL7Exception;
9   import ca.uhn.hl7v2.app.Application;
10  import ca.uhn.hl7v2.app.ApplicationException;
11  import ca.uhn.hl7v2.model.Message;
12  import ca.uhn.hl7v2.protocol.ReceivingApplication;
13  import ca.uhn.hl7v2.protocol.ReceivingApplicationException;
14  
15  /**
16   * Wraps a ca.uhn.hl7v2.app.Application as a ca.uhn.hl7v2.protocol.ReceivingApplication. 
17   * ReceivingApplication replaces Application with HAPI 0.5.
18   *  
19   * @author <a href="mailto:bryan.tripp@uhn.on.ca">Bryan Tripp</a>
20   * @version $Revision: 1.1 $ updated on $Date: 2007-02-19 02:24:26 $ by $Author: jamesagnew $
21   */
22  public class AppWrapper implements ReceivingApplication<Message> {
23  
24      private final Application myApplication;
25      
26      /**
27       * @param theApplication an Application to wrap as a ReceivingApplication.  
28       */
29      public AppWrapper(Application theApplication) {
30          myApplication = theApplication;
31      }
32  
33      /** 
34       * @see ca.uhn.hl7v2.protocol.ReceivingApplication#processMessage(ca.uhn.hl7v2.model.Message, java.util.Map)
35       */
36      public Message../../../ca/uhn/hl7v2/model/Message.html#Message">Message processMessage(Message theMessage, Map<String, Object> theMetadata) 
37              throws ReceivingApplicationException, HL7Exception {
38          Message result;
39          try {
40              result = myApplication.processMessage(theMessage);
41          } catch (ApplicationException e) {
42              throw new ReceivingApplicationException(e);
43          }
44          
45          return result;
46      }
47  
48      /** 
49       * @see ca.uhn.hl7v2.protocol.ReceivingApplication#canProcess(ca.uhn.hl7v2.model.Message)
50       */
51      public boolean canProcess(Message theMessage) {
52          return myApplication.canProcess(theMessage);
53      }
54  
55  }