This project has retired. For details please refer to its Attic page.
InVMTransport xref
View Javadoc
1   /*
2    * Copyright 2001-2009 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   */
17  package org.apache.juddi.v3.client.transport;
18  
19  import org.apache.juddi.v3.client.config.UDDIClient;
20  import org.apache.juddi.v3.client.config.UDDIClientContainer;
21  import org.apache.juddi.v3_service.JUDDIApiPortType;
22  import org.uddi.v3_service.UDDICustodyTransferPortType;
23  import org.uddi.v3_service.UDDIInquiryPortType;
24  import org.uddi.v3_service.UDDIPublicationPortType;
25  import org.uddi.v3_service.UDDISecurityPortType;
26  import org.uddi.v3_service.UDDISubscriptionListenerPortType;
27  import org.uddi.v3_service.UDDISubscriptionPortType;
28  
29  /**
30   * InVM transport expects that the service urls are in fact fully qualified classnames
31     */
32  public class InVMTransport extends Transport {
33  
34  	private String nodeName = null;
35  	private String clientName = null;
36  	UDDIInquiryPortType inquiryService = null;
37  	UDDISecurityPortType securityService = null;
38  	UDDIPublicationPortType publishService = null;
39  	UDDISubscriptionPortType subscriptionService = null;
40  	UDDISubscriptionListenerPortType subscriptionListenerService = null;
41  	UDDICustodyTransferPortType custodyTransferService = null;
42  	JUDDIApiPortType publisherService = null;
43  
44  	public InVMTransport() {
45  		super();
46  		this.nodeName = Transport.DEFAULT_NODE_NAME;
47  	}
48  	
49  	public InVMTransport(String nodeName) {
50  		super();
51  		this.nodeName = nodeName;
52  	}
53  	
54  	public InVMTransport(String clientName, String nodeName) {
55  		super();
56  		this.nodeName = nodeName;
57  		this.clientName = clientName;
58  	}
59  	
60  	public UDDIInquiryPortType getUDDIInquiryService(String endpointURL) throws TransportException {
61  		if (inquiryService==null) {
62  			try {
63  				if (endpointURL==null) {
64  					UDDIClient client = UDDIClientContainer.getUDDIClient(clientName);
65  					endpointURL = client.getClientConfig().getUDDINode(nodeName).getInquiryUrl();
66  				}
67  				Class<?> c = Class.forName(endpointURL);
68  				inquiryService = (UDDIInquiryPortType) c.newInstance();
69  			} catch (Exception e) {
70  				throw new TransportException(e.getMessage(), e);
71  			}
72  		}
73  		return inquiryService;
74  	}
75  	
76  	public UDDISecurityPortType getUDDISecurityService(String endpointURL) throws TransportException {
77  		if (securityService==null) {
78  			try {
79  				if (endpointURL==null) {
80  					UDDIClient client = UDDIClientContainer.getUDDIClient(clientName);
81  					endpointURL = client.getClientConfig().getUDDINode(nodeName).getSecurityUrl();
82  				}
83  				Class<?> c = Class.forName(endpointURL);
84  				securityService = (UDDISecurityPortType) c.newInstance();
85  			} catch (Exception e) {
86  				throw new TransportException(e.getMessage(), e);
87  			}
88  		}
89  		return securityService;
90  	}
91  	
92  	public UDDIPublicationPortType getUDDIPublishService(String endpointURL) throws TransportException {
93  		if (publishService==null) {
94  			try {
95  				if (endpointURL==null) {
96  					UDDIClient client = UDDIClientContainer.getUDDIClient(clientName);
97  					endpointURL = client.getClientConfig().getUDDINode(nodeName).getPublishUrl();
98  				}
99  				Class<?> c = Class.forName(endpointURL);
100 				publishService = (UDDIPublicationPortType) c.newInstance();
101 			} catch (Exception e) {
102 				throw new TransportException(e.getMessage(), e);
103 			}
104 		}
105 		return publishService;
106 	}
107 	
108 	public UDDISubscriptionPortType getUDDISubscriptionService(String endpointURL) throws TransportException {
109 		if (subscriptionService==null) {
110 			try {
111 				if (endpointURL==null) {
112 					UDDIClient client = UDDIClientContainer.getUDDIClient(clientName);
113 					endpointURL = client.getClientConfig().getUDDINode(nodeName).getSubscriptionUrl();
114 				}
115 				Class<?> c = Class.forName(endpointURL);
116 				subscriptionService = (UDDISubscriptionPortType) c.newInstance();
117 			} catch (Exception e) {
118 				throw new TransportException(e.getMessage(), e);
119 			}
120 		}
121 		return subscriptionService;
122 	}
123 	
124 	public UDDISubscriptionListenerPortType getUDDISubscriptionListenerService(String endpointURL) throws TransportException {
125 		if (subscriptionListenerService==null) {
126 			try {
127 				if (endpointURL==null) {
128 					UDDIClient client = UDDIClientContainer.getUDDIClient(clientName);
129 					endpointURL = client.getClientConfig().getUDDINode(nodeName).getSubscriptionListenerUrl();
130 				}
131 				Class<?> c = Class.forName(endpointURL);
132 				subscriptionListenerService = (UDDISubscriptionListenerPortType) c.newInstance();
133 			} catch (Exception e) {
134 				throw new TransportException(e.getMessage(), e);
135 			}
136 		}
137 		return subscriptionListenerService;
138 	}
139 	
140 	public UDDICustodyTransferPortType getUDDICustodyTransferService(String endpointURL) throws TransportException {
141 		if (custodyTransferService==null) {
142 			try {
143 				if (endpointURL==null) {
144 					UDDIClient client = UDDIClientContainer.getUDDIClient(clientName);
145 					endpointURL = client.getClientConfig().getUDDINode(nodeName).getCustodyTransferUrl();
146 				}
147 				Class<?> c = Class.forName(endpointURL);
148 				custodyTransferService = (UDDICustodyTransferPortType) c.newInstance();
149 			} catch (Exception e) {
150 				throw new TransportException(e.getMessage(), e);
151 			}
152 		}
153 		return custodyTransferService;
154 	}
155 	
156 	public JUDDIApiPortType getJUDDIApiService(String endpointURL) throws TransportException {
157 		if (publisherService==null) {
158 			try {
159 				if (endpointURL==null) {
160 					UDDIClient client = UDDIClientContainer.getUDDIClient(clientName);
161 					endpointURL = client.getClientConfig().getUDDINode(nodeName).getJuddiApiUrl();
162 				}
163 				Class<?> c = Class.forName(endpointURL);
164 				publisherService = (JUDDIApiPortType) c.newInstance();
165 			} catch (Exception e) {
166 				throw new TransportException(e.getMessage(), e);
167 			}
168 		}
169 		return publisherService;
170 	}
171 
172 
173 }