View Javadoc
1   /*
2    * Copyright 2001-2010 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.config;
18  
19  import java.io.Serializable;
20  import java.util.Properties;
21  
22  import org.apache.juddi.api_v3.Node;
23  import org.apache.juddi.v3.client.ClassUtil;
24  import org.apache.juddi.v3.client.transport.Transport;
25  import org.apache.juddi.v3.client.transport.TransportException;
26  
27  /**
28   * Connection information to a UDDI node.
29   * 
30   * @author kstam
31   *
32   */
33  public class UDDINode implements Serializable {
34  
35  	private static final long serialVersionUID = 5721040459195558161L;
36  	private Properties properties=new Properties();
37          private transient Transport transport;
38  	
39  	private boolean isHomeJUDDI;
40  	private String name;
41  	private String clientName;
42  	private String description;
43  	private String custodyTransferUrl;
44  	private String inquiryUrl;
45  	private String inquiryRESTUrl;
46  	private String publishUrl;
47  	private String securityUrl;
48          private String replicationUrl;
49  	private String subscriptionUrl;
50  	private String subscriptionListenerUrl;
51  	private String juddiApiUrl;
52  	private String proxyTransport;
53  	private String factoryInitial;
54  	private String factoryURLPkgs;
55  	private String factoryNamingProvider;
56  	
57  	
58  	public UDDINode() {
59  		super();
60  	}
61  	
62  	public UDDINode(Node node) {
63  		super();
64  		name = node.getName();
65  		clientName = node.getClientName();
66  		description = node.getDescription();
67  		custodyTransferUrl = node.getCustodyTransferUrl();
68  		inquiryUrl = node.getInquiryUrl();
69                  //TODO need juddi schema updat inquiryRESTUrl = node.getInquiryRESTUrl()
70  		publishUrl = node.getPublishUrl();
71  		securityUrl = node.getSecurityUrl();
72  		subscriptionUrl = node.getSubscriptionUrl();
73  		subscriptionListenerUrl = node.getSubscriptionListenerUrl();
74                  replicationUrl=node.getReplicationUrl();
75  		juddiApiUrl = node.getJuddiApiUrl();
76  		proxyTransport = node.getProxyTransport();
77  		factoryInitial = node.getFactoryInitial();
78  		factoryURLPkgs = node.getFactoryURLPkgs();
79  		factoryNamingProvider = node.getFactoryNamingProvider();
80  	}
81  
82  	public Properties getProperties() {
83  		return properties;
84  	}
85  
86  	public void setProperties(Properties properties) {
87  		this.properties = properties;
88  	}
89  	
90  	public Node getApiNode() {
91  		Node apiNode = new Node();
92  		apiNode.setClientName(clientName);
93                  apiNode.setCustodyTransferUrl(custodyTransferUrl);
94  		apiNode.setDescription(description);
95  		apiNode.setFactoryInitial(factoryInitial);
96  		apiNode.setFactoryNamingProvider(factoryNamingProvider);
97  		apiNode.setFactoryURLPkgs(factoryURLPkgs);
98  		apiNode.setInquiryUrl(inquiryUrl);
99                  //no mapping for this apiNode.setInquiryRESTUrl(name);
100 		apiNode.setJuddiApiUrl(juddiApiUrl);
101 		
102 		apiNode.setName(name);
103 		apiNode.setProxyTransport(proxyTransport);
104 		apiNode.setPublishUrl(publishUrl);
105                 apiNode.setReplicationUrl(replicationUrl);
106 		apiNode.setSecurityUrl(securityUrl);
107 		apiNode.setSubscriptionUrl(subscriptionUrl);
108                 apiNode.setSubscriptionListenerUrl(subscriptionListenerUrl);
109 		return apiNode;
110 	}
111 	
112 	
113 	public Transport getTransport() throws TransportException {
114 		if (transport==null) {
115                         String clazz = getProxyTransport();
116 			try {
117 				
118 				Class<?> transportClass = ClassUtil.forName(clazz,this.getClass());
119 				transport = (Transport) transportClass.getConstructor(String.class,String.class).newInstance(clientName,name);
120 			} catch (Exception e) {
121 				throw new TransportException(e.getMessage() + " node " + name + " transport class: " + clazz,e);
122 			}
123 		}
124 		return transport;
125 	}
126 
127 	public String getName() {
128 		return name;
129 	}
130 
131 	public void setName(String name) {
132 		this.name = name;
133 	}
134 
135 	public String getClientName() {
136 		return clientName;
137 	}
138 
139 	public void setClientName(String clientName) {
140 		this.clientName = clientName;
141 	}
142 
143 	public String getDescription() {
144 		return description;
145 	}
146 
147 	public void setDescription(String description) {
148 		this.description = description;
149 	}
150 
151 	public String getCustodyTransferUrl() {
152 		return custodyTransferUrl;
153 	}
154 
155 	public void setCustodyTransferUrl(String custodyTransferUrl) {
156 		this.custodyTransferUrl = custodyTransferUrl;
157 	}
158 
159 	public String getInquiryUrl() {
160 		return inquiryUrl;
161 	}
162         /**
163          * @since 3.2.1
164          * @return 
165          */
166         public String getReplicationUrl() {
167 		return replicationUrl;
168 	}
169         /**
170          * @since 3.2.1
171          * @param value 
172          */
173         public void setReplicationUrl(String value) {
174 		replicationUrl=value;
175 	}
176         
177         /**
178          * used ONLY for UDDI's HTTP GET (REST) endpoint
179          * @since 3.2
180          * @param url 
181          */
182         public void setInquiryRESTUrl(String url){
183                 this.inquiryRESTUrl = url;
184         }
185         /**
186          * used ONLY for jUDDI's HTTP GET (REST) endpoint
187          * @since 3.2
188          * @return the REST url for the Inquiry, not supported by all registries 
189          */
190         public String getInquiry_REST_Url() {
191 		return inquiryRESTUrl;
192 	}
193 
194 	public void setInquiryUrl(String inquiryUrl) {
195 		this.inquiryUrl = inquiryUrl;
196 	}
197 
198 	public String getPublishUrl() {
199 		return publishUrl;
200 	}
201 
202 	public void setPublishUrl(String publishUrl) {
203 		this.publishUrl = publishUrl;
204 	}
205 
206 	public String getSecurityUrl() {
207 		return securityUrl;
208 	}
209 
210 	public void setSecurityUrl(String securityUrl) {
211 		this.securityUrl = securityUrl;
212 	}
213 
214 	public String getSubscriptionUrl() {
215 		return subscriptionUrl;
216 	}
217 
218 	public void setSubscriptionUrl(String subscriptionUrl) {
219 		this.subscriptionUrl = subscriptionUrl;
220 	}
221 
222 	public String getSubscriptionListenerUrl() {
223 		return subscriptionListenerUrl;
224 	}
225 
226 	public void setSubscriptionListenerUrl(String subscriptionListenerUrl) {
227 		this.subscriptionListenerUrl = subscriptionListenerUrl;
228 	}
229 
230 	public String getJuddiApiUrl() {
231 		return juddiApiUrl;
232 	}
233 
234 	public void setJuddiApiUrl(String juddiApiUrl) {
235 		this.juddiApiUrl = juddiApiUrl;
236 	}
237 
238 	public String getProxyTransport() {
239 		return proxyTransport;
240 	}
241 
242 	public void setProxyTransport(String proxyTransport) {
243 		this.proxyTransport = proxyTransport;
244 	}
245 
246 	public String getFactoryInitial() {
247 		return factoryInitial;
248 	}
249 
250 	public void setFactoryInitial(String factoryInitial) {
251 		this.factoryInitial = factoryInitial;
252 	}
253 
254 	public String getFactoryURLPkgs() {
255 		return factoryURLPkgs;
256 	}
257 
258 	public void setFactoryURLPkgs(String factoryURLPkgs) {
259 		this.factoryURLPkgs = factoryURLPkgs;
260 	}
261 
262 	public String getFactoryNamingProvider() {
263 		return factoryNamingProvider;
264 	}
265 
266 	public void setFactoryNamingProvider(String factoryNamingProvider) {
267 		this.factoryNamingProvider = factoryNamingProvider;
268 	}
269 
270 	public boolean isHomeJUDDI() {
271 		return isHomeJUDDI;
272 	}
273 
274 	public void setHomeJUDDI(boolean isHomeJUDDI) {
275 		this.isHomeJUDDI = isHomeJUDDI;
276 	}
277 }