View Javadoc

1   package ca.uhn.hl7v2.hoh.relay;
2   
3   import org.springframework.beans.factory.InitializingBean;
4   
5   import ca.uhn.hl7v2.hoh.relay.listener.IRelayListener;
6   import ca.uhn.hl7v2.hoh.relay.sender.IRelaySender;
7   import ca.uhn.hl7v2.hoh.util.Validate;
8   import ca.uhn.hl7v2.protocol.impl.AppRoutingDataImpl;
9   
10  public class Binder implements InitializingBean {
11  
12  	private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(Binder.class);
13  
14  	private IRelayListener myRelayListener;
15  	private String myMessageType = "*";
16  	private String myProcessingId = "*";
17  	private IRelaySender myRelaySender;
18  	private String myTriggerEvent = "*";
19  	private String myVersionId = "*";
20  
21  	/**
22  	 * {@inheritDoc}
23  	 */
24  	public void afterPropertiesSet() throws Exception {
25  		Validate.propertySet(myRelayListener, "listener");
26  		Validate.propertySet(myRelaySender, "sender");
27  
28  		ourLog.info("Binding sender[{}] to listener[{}] for messages with profile[MsgType:{} / MsgTrigger:{} / Version:{} / Processing:{}]", new Object[] { myRelaySender.getBeanName(), myRelayListener.getBeanName(), myMessageType, myTriggerEvent, myVersionId, myProcessingId });
29  
30  		AppRoutingDataImpl appRoutingData = new AppRoutingDataImpl(myMessageType, myTriggerEvent, myProcessingId, myVersionId);
31  		myRelayListener.registerApplication(appRoutingData, myRelaySender);
32  	}
33  
34  	public void setListener(IRelayListener theRelayListener) {
35  		myRelayListener = theRelayListener;
36  	}
37  
38  	/**
39  	 * @param theRelaySender
40  	 *            the sender to set
41  	 */
42  	public void setSender(IRelaySender theRelaySender) {
43  		myRelaySender = theRelaySender;
44  	}
45  
46  }