View Javadoc
1   package ca.uhn.hl7v2.protocol;
2   
3   import java.util.Map;
4   
5   import ca.uhn.hl7v2.HL7Exception;
6   import ca.uhn.hl7v2.app.Application;
7   import ca.uhn.hl7v2.app.ApplicationException;
8   import ca.uhn.hl7v2.model.Message;
9   
10  /**
11   * Wraps a legacy HAPI {@link Application} to convert it to a new
12   * style {@link ReceivingApplication}
13   */
14  public class ApplicationWrapper implements ReceivingApplication<Message> {
15  
16  	private final Application application;
17  
18  	/**
19  	 * Constructor
20  	 * 
21  	 * @param theApplication The application to wrap
22  	 */
23  	public ApplicationWrapper(Application theApplication) {
24  		this.application = theApplication;
25  	}
26  
27  	/**
28  	 * {@inheritDoc}
29  	 */
30  	public Message../../ca/uhn/hl7v2/model/Message.html#Message">Message processMessage(Message theMessage, Map<String, Object> theMetadata) throws ReceivingApplicationException, HL7Exception {
31  		try {
32  			return this.application.processMessage(theMessage);
33  		} catch (ApplicationException e) {
34  			throw new ReceivingApplicationException(e);
35  		}
36  	}
37  
38  	/**
39  	 * {@inheritDoc}
40  	 */
41  	public boolean canProcess(Message theMessage) {
42  		return this.application.canProcess(theMessage);
43  	}
44  
45  }