001 /*
002 * Created on 16-May-2005
003 */
004 package ca.uhn.hl7v2.protocol.impl;
005
006 import java.util.Map;
007
008 import ca.uhn.hl7v2.HL7Exception;
009 import ca.uhn.hl7v2.app.Application;
010 import ca.uhn.hl7v2.app.ApplicationException;
011 import ca.uhn.hl7v2.model.Message;
012 import ca.uhn.hl7v2.protocol.ReceivingApplication;
013 import ca.uhn.hl7v2.protocol.ReceivingApplicationException;
014
015 /**
016 * Wraps a ca.uhn.hl7v2.app.Application as a ca.uhn.hl7v2.protocol.ReceivingApplication.
017 * ReceivingApplication replaces Application with HAPI 0.5.
018 *
019 * @author <a href="mailto:bryan.tripp@uhn.on.ca">Bryan Tripp</a>
020 * @version $Revision: 1.1 $ updated on $Date: 2007-02-19 02:24:26 $ by $Author: jamesagnew $
021 */
022 public class AppWrapper implements ReceivingApplication {
023
024 private Application myApplication;
025
026 /**
027 * @param theApplication an Application to wrap as a ReceivingApplication.
028 */
029 public AppWrapper(Application theApplication) {
030 myApplication = theApplication;
031 }
032
033 /**
034 * @see ca.uhn.hl7v2.protocol.ReceivingApplication#processMessage(ca.uhn.hl7v2.model.Message, java.util.Map)
035 */
036 public Message processMessage(Message theMessage, Map<String, Object> theMetadata)
037 throws ReceivingApplicationException, HL7Exception {
038 Message result = null;
039
040 try {
041 result = myApplication.processMessage(theMessage);
042 } catch (ApplicationException e) {
043 throw new ReceivingApplicationException(e);
044 }
045
046 return result;
047 }
048
049 /**
050 * @see ca.uhn.hl7v2.protocol.ReceivingApplication#canProcess(ca.uhn.hl7v2.model.Message)
051 */
052 public boolean canProcess(Message theMessage) {
053 return myApplication.canProcess(theMessage);
054 }
055
056 }