PageRenderTime 48ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/ojc-core/jmsbc/jmsbcimpl/src/com/sun/jbi/jmsbc/EndpointImpl.java

https://bitbucket.org/pymma/openesb-components
Java | 308 lines | 183 code | 63 blank | 62 comment | 5 complexity | 69bd0e2b8bc2b91cfce30a50cd6125c1 MD5 | raw file
  1. /*
  2. * BEGIN_HEADER - DO NOT EDIT
  3. *
  4. * The contents of this file are subject to the terms
  5. * of the Common Development and Distribution License
  6. * (the "License"). You may not use this file except
  7. * in compliance with the License.
  8. *
  9. * You can obtain a copy of the license at
  10. * https://open-jbi-components.dev.java.net/public/CDDLv1.0.html.
  11. * See the License for the specific language governing
  12. * permissions and limitations under the License.
  13. *
  14. * When distributing Covered Code, include this CDDL
  15. * HEADER in each file and include the License file at
  16. * https://open-jbi-components.dev.java.net/public/CDDLv1.0.html.
  17. * If applicable add the following below this CDDL HEADER,
  18. * with the fields enclosed by brackets "[]" replaced with
  19. * your own identifying information: Portions Copyright
  20. * [year] [name of copyright owner]
  21. */
  22. /*
  23. * @(#)EndpointImpl.java
  24. *
  25. * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
  26. *
  27. * END_HEADER - DO NOT EDIT
  28. */
  29. package com.sun.jbi.jmsbc;
  30. import java.io.Serializable;
  31. import java.util.HashMap;
  32. import java.util.Map;
  33. import javax.jbi.servicedesc.ServiceEndpoint;
  34. import javax.wsdl.Definition;
  35. import javax.wsdl.Port;
  36. import javax.wsdl.PortType;
  37. import javax.wsdl.Service;
  38. import javax.xml.namespace.QName;
  39. import org.w3c.dom.Document;
  40. import com.sun.jbi.common.qos.ServiceQuality;
  41. import com.sun.jbi.eManager.provider.EndpointStatus;
  42. import com.sun.jbi.jmsbc.Endpoint.EndpointType;
  43. import com.sun.jbi.jmsbc.Endpoint.EndpointState;
  44. import com.sun.jbi.jmsbc.extensions.JMSAddress;
  45. import com.sun.jbi.jmsbc.extensions.JMSBinding;
  46. import com.sun.jbi.jmsbc.extensions.JMSOperation;
  47. import com.sun.jbi.jmsbc.extensions.JMSInput;
  48. import com.sun.jbi.jmsbc.extensions.JMSOutput;
  49. public class EndpointImpl
  50. implements Endpoint, Serializable {
  51. private QName mServiceName;
  52. private String mEndpointName;
  53. private Definition mDefinition;
  54. private PortType mPortType; // lazily initialized
  55. private int mEndpointState;
  56. private EndpointStatus mEndpointStatus;
  57. private int mEndpointType;
  58. private ServiceEndpoint mServiceEndpoint;
  59. private Document mServiceDescription;
  60. private JMSAddress mJMSAddress;
  61. private JMSBinding mJMSBinding;
  62. private Map mOperations; // <QName, JMSOperation>
  63. private Map mOperationInput; // <JMSOperation, JMSInput>
  64. private Map mOperationOutput; // <JMSOperation, JMSOutput>
  65. private Map mPartMapping; // <QName+partname, encoder>
  66. private String mServiceUnitID;
  67. private String mConfig;
  68. private ServiceQuality[] mQos;
  69. private ServiceUnit serviceUnit;
  70. public EndpointImpl() {
  71. mOperations = new HashMap();
  72. mOperationInput = new HashMap();
  73. mOperationOutput = new HashMap();
  74. mPartMapping = new HashMap();
  75. }
  76. ////////
  77. //
  78. // Binding and Port Information Methods
  79. //
  80. ////////
  81. public QName getServiceName() {
  82. return mServiceName;
  83. }
  84. public void setServiceName(QName serviceName) {
  85. mServiceName = serviceName;
  86. }
  87. public String getEndpointName() {
  88. return mEndpointName;
  89. }
  90. public void setEndpointName(String endpointName) {
  91. mEndpointName = endpointName;
  92. }
  93. public Definition getDefinition() {
  94. return mDefinition;
  95. }
  96. public void setDefinition(Definition definition) {
  97. mDefinition = definition;
  98. }
  99. ////////
  100. //
  101. // State Information Methods
  102. //
  103. ////////
  104. public int getState() {
  105. return mEndpointState;
  106. }
  107. public void setState(int state) {
  108. mEndpointState = state;
  109. }
  110. public void setEndpointStatus(EndpointStatus val) {
  111. mEndpointStatus = val;
  112. }
  113. public EndpointStatus getEndpointStatus() {
  114. return mEndpointStatus;
  115. }
  116. ////////
  117. //
  118. // Outbound (provider) or inbound (consumer) - with respect to SE
  119. //
  120. ////////
  121. public int getEndpointType() {
  122. return mEndpointType;
  123. }
  124. public void setEndpointType(int type) {
  125. mEndpointType = type;
  126. }
  127. ////////
  128. //
  129. // JBI-representation of Endpoint
  130. //
  131. ////////
  132. public ServiceEndpoint getServiceEndpoint() {
  133. return mServiceEndpoint;
  134. }
  135. public void setServiceEndpoint(ServiceEndpoint serviceEndpoint) {
  136. mServiceEndpoint = serviceEndpoint;
  137. }
  138. public Document getServiceDescription() {
  139. return mServiceDescription;
  140. }
  141. public void setServiceDescription(Document serviceDescription) {
  142. mServiceDescription = serviceDescription;
  143. }
  144. ////////
  145. //
  146. // JMS-specific Endpoint. These should probably be refactored
  147. // out in a better way so as to maintain their original
  148. // hierarchical structure
  149. //
  150. ////////
  151. public JMSAddress getJMSAddress() {
  152. return mJMSAddress;
  153. }
  154. public void setJMSAddress(JMSAddress address) {
  155. mJMSAddress = address;
  156. }
  157. public JMSBinding getJMSBinding() {
  158. return mJMSBinding;
  159. }
  160. public void setJMSBinding(JMSBinding binding) {
  161. mJMSBinding = binding;
  162. }
  163. public Map getJMSOperations() {
  164. return mOperations;
  165. }
  166. public void setJMSOperations(Map operations) {
  167. mOperations = operations;
  168. }
  169. public JMSInput getJMSOperationInput(JMSOperation operation) {
  170. return (JMSInput)mOperationInput.get(operation);
  171. }
  172. public void setJMSOperationInput(JMSOperation operation,
  173. JMSInput operationInput) {
  174. mOperationInput.put(operation, operationInput);
  175. }
  176. public JMSOutput getJMSOperationOutput(JMSOperation operation) {
  177. return (JMSOutput) mOperationOutput.get(operation);
  178. }
  179. public void setJMSOperationOutput(JMSOperation operation,
  180. JMSOutput operationOutput) {
  181. mOperationOutput.put(operation, operationOutput);
  182. }
  183. public static String endpointTypeToString (int endpointType) {
  184. if (endpointType == Endpoint.EndpointType.INBOUND) {
  185. return Endpoint.EndpointType.INBOUND_STR;
  186. } else {
  187. return Endpoint.EndpointType.OUTBOUND_STR;
  188. }
  189. }
  190. ////////
  191. //
  192. // Encoder mappings
  193. //
  194. ////////
  195. public void setMessagePartEncoderMapping(Map partMapping) {
  196. mPartMapping = partMapping;
  197. }
  198. public Map getMessagePartEncoderMapping() {
  199. return mPartMapping;
  200. }
  201. public QName createOperationAddress(String operationName) {
  202. if (mPortType == null) {
  203. Map services = mDefinition.getServices();
  204. // DO NOT use the getService() method.
  205. // It checks all imported WSDLs.
  206. Service svc = (Service)services.get(mServiceName);
  207. Port port = svc.getPort(QName.valueOf(mEndpointName).getLocalPart());
  208. mPortType = port.getBinding().getPortType();
  209. }
  210. return new QName(mPortType.getQName().getNamespaceURI(), operationName);
  211. }
  212. public void setServiceUnitID (String serviceUnitID) {
  213. this.mServiceUnitID = serviceUnitID;
  214. }
  215. public String getServiceUnitID () {
  216. return mServiceUnitID;
  217. }
  218. public String getKey() {
  219. return mServiceUnitID +
  220. getServiceName().toString() +
  221. getEndpointName() +
  222. endpointTypeToString(getEndpointType());
  223. }
  224. public String getApplicationConfigurationName() {
  225. return mConfig;
  226. }
  227. public void setApplicationConfigurationName(String config) {
  228. mConfig = config;
  229. }
  230. public ServiceQuality[] getServiceQualities() {
  231. return mQos;
  232. }
  233. public void setServiceQualities(ServiceQuality[] qos) {
  234. mQos = qos;
  235. }
  236. public ServiceUnit getServiceUnit() {
  237. return serviceUnit;
  238. }
  239. public void setServiceUnit(ServiceUnit su) {
  240. serviceUnit = su;
  241. }
  242. public String toString(){
  243. return getKey();
  244. }
  245. }