1 17 package org.apache.servicemix.eip.support; 18 19 import javax.jbi.component.ComponentContext; 20 import javax.jbi.messaging.MessageExchange; 21 import javax.jbi.messaging.MessagingException; 22 import javax.jbi.servicedesc.ServiceEndpoint; 23 import javax.xml.namespace.QName ; 24 25 import org.apache.servicemix.jbi.resolver.URIResolver; 26 import org.springframework.beans.factory.InitializingBean; 27 28 37 public class ExchangeTarget implements InitializingBean { 38 39 private QName _interface; 40 41 private QName operation; 42 43 private QName service; 44 45 private String endpoint; 46 47 private String uri; 48 49 52 public String getEndpoint() { 53 return endpoint; 54 } 55 56 60 public void setEndpoint(String endpoint) { 61 this.endpoint = endpoint; 62 } 63 64 67 public QName getInterface() { 68 return _interface; 69 } 70 71 75 public void setInterface(QName _interface) { 76 this._interface = _interface; 77 } 78 79 82 public QName getOperation() { 83 return operation; 84 } 85 86 90 public void setOperation(QName operation) { 91 this.operation = operation; 92 } 93 94 97 public QName getService() { 98 return service; 99 } 100 101 105 public void setService(QName service) { 106 this.service = service; 107 } 108 109 112 public String getUri() { 113 return uri; 114 } 115 116 119 public void setUri(String uri) { 120 this.uri = uri; 121 } 122 123 128 public void configureTarget(MessageExchange exchange, ComponentContext context) throws MessagingException { 129 if (_interface == null && service == null && uri == null) { 130 throw new MessagingException("interface, service or uri should be specified"); 131 } 132 if (uri != null) { 133 URIResolver.configureExchange(exchange, context, uri); 134 } 135 if (_interface != null) { 136 exchange.setInterfaceName(_interface); 137 } 138 if (operation != null) { 139 exchange.setOperation(operation); 140 } 141 if (service != null) { 142 exchange.setService(service); 143 if (endpoint != null) { 144 ServiceEndpoint se = context.getEndpoint(service, endpoint); 145 exchange.setEndpoint(se); 146 } 147 } 148 } 149 150 153 public void afterPropertiesSet() throws Exception { 154 if (_interface == null && service == null && uri == null) { 155 throw new MessagingException("interface, service or uri should be specified"); 156 } 157 } 158 159 } 160 | Popular Tags |