1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.apache.ws.scout.registry; |
18 | |
|
19 | |
import java.io.Serializable; |
20 | |
import java.net.URI; |
21 | |
import java.net.URISyntaxException; |
22 | |
import java.util.Collection; |
23 | |
import java.util.Properties; |
24 | |
|
25 | |
import javax.xml.registry.Connection; |
26 | |
import javax.xml.registry.ConnectionFactory; |
27 | |
import javax.xml.registry.FederatedConnection; |
28 | |
import javax.xml.registry.InvalidRequestException; |
29 | |
import javax.xml.registry.JAXRException; |
30 | |
import javax.xml.registry.UnsupportedCapabilityException; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
public class ConnectionFactoryImpl extends ConnectionFactory implements Serializable |
42 | |
{ |
43 | |
private static final long serialVersionUID = -6902106826496922256L; |
44 | |
private static final String QUERYMANAGER_PROPERTY = "javax.xml.registry.queryManagerURL"; |
45 | |
private static final String LIFECYCLEMANAGER_PROPERTY = "javax.xml.registry.lifeCycleManagerURL"; |
46 | |
private static final String SECURITYMANAGER_PROPERTY = "javax.xml.registry.securityManagerURL"; |
47 | |
private static final String SEMANTICEQUIVALENCES_PROPERTY = "javax.xml.registry.semanticEquivalences"; |
48 | |
private static final String POSTALADDRESSSCHEME_PROPERTY = "javax.xml.registry.postalAddressScheme"; |
49 | |
private static final String AUTHENTICATIONMETHOD_PROPERTY = "javax.xml.registry.security.authenticationMethod"; |
50 | |
private static final String MAXROWS_PROPERTY = "javax.xml.registry.uddi.maxRows"; |
51 | |
|
52 | |
private String queryManagerURL; |
53 | |
private String lifeCycleManagerURL; |
54 | |
private String securityManagerURL; |
55 | |
private String transportClass; |
56 | |
private String semanticEquivalences; |
57 | |
private String authenticationMethod; |
58 | |
private Integer maxRows; |
59 | |
private String postalAddressScheme; |
60 | |
private String uddiNamespace; |
61 | |
private String uddiVersion; |
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
public ConnectionFactoryImpl() |
68 | 288 | { |
69 | 288 | } |
70 | |
|
71 | |
public Connection createConnection() throws JAXRException |
72 | |
{ |
73 | 354 | if (queryManagerURL == null) |
74 | |
{ |
75 | 6 | throw new InvalidRequestException("queryManager is not set"); |
76 | |
} |
77 | |
URI queryManager; |
78 | |
URI lifeCycleManager; |
79 | 348 | URI securityManager = null; |
80 | |
try |
81 | |
{ |
82 | 348 | queryManager = new URI(queryManagerURL); |
83 | 0 | } catch (URISyntaxException e) |
84 | |
{ |
85 | 0 | throw new InvalidRequestException("Invalid queryManagerURL: " + queryManagerURL, e); |
86 | 348 | } |
87 | |
try |
88 | |
{ |
89 | 348 | lifeCycleManager = lifeCycleManagerURL == null ? queryManager : new URI(lifeCycleManagerURL); |
90 | 0 | } catch (URISyntaxException e) |
91 | |
{ |
92 | 0 | throw new InvalidRequestException("Invalid lifeCycleManagerURL: " + lifeCycleManagerURL, e); |
93 | 348 | } |
94 | |
try |
95 | |
{ |
96 | 348 | if (securityManagerURL != null) { |
97 | 0 | securityManager = new URI(securityManagerURL); |
98 | |
} |
99 | 0 | } catch (URISyntaxException e) { |
100 | 0 | securityManager = null; |
101 | 348 | } |
102 | 348 | return new ConnectionImpl(queryManager, lifeCycleManager, securityManager, transportClass, null, maxRows == null ? -1 : maxRows.intValue(), |
103 | |
uddiNamespace, uddiVersion); |
104 | |
} |
105 | |
|
106 | |
public FederatedConnection createFederatedConnection(Collection collection) throws JAXRException |
107 | |
{ |
108 | 6 | throw new UnsupportedCapabilityException("FederatedConnections are not supported in this release"); |
109 | |
} |
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
public Properties getProperties() |
119 | |
{ |
120 | 72 | Properties props = new Properties(); |
121 | 72 | if (queryManagerURL != null) |
122 | |
{ |
123 | 6 | props.put(QUERYMANAGER_PROPERTY, queryManagerURL); |
124 | |
} |
125 | 72 | if (lifeCycleManagerURL != null) |
126 | |
{ |
127 | 6 | props.put(LIFECYCLEMANAGER_PROPERTY, lifeCycleManagerURL); |
128 | |
} |
129 | 72 | if (securityManagerURL != null) |
130 | |
{ |
131 | 0 | props.put(SECURITYMANAGER_PROPERTY, securityManagerURL); |
132 | |
} |
133 | 72 | if (semanticEquivalences != null) |
134 | |
{ |
135 | 6 | props.put(SEMANTICEQUIVALENCES_PROPERTY, semanticEquivalences); |
136 | |
} |
137 | 72 | if (postalAddressScheme != null) |
138 | |
{ |
139 | 6 | props.put(POSTALADDRESSSCHEME_PROPERTY, postalAddressScheme); |
140 | |
} |
141 | 72 | if (authenticationMethod != null) |
142 | |
{ |
143 | 6 | props.put(AUTHENTICATIONMETHOD_PROPERTY, authenticationMethod); |
144 | |
} |
145 | 72 | if (maxRows != null) |
146 | |
{ |
147 | 6 | props.put(MAXROWS_PROPERTY, maxRows.toString()); |
148 | |
} |
149 | 72 | if (uddiNamespace != null) { |
150 | 0 | props.put(RegistryImpl.UDDI_NAMESPACE_PROPERTY_NAME, uddiNamespace); |
151 | |
} |
152 | 72 | if (uddiVersion != null) { |
153 | 0 | props.put(RegistryImpl.UDDI_VERSION_PROPERTY_NAME, uddiVersion); |
154 | |
} |
155 | |
|
156 | 72 | return props; |
157 | |
} |
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
public void setProperties(Properties properties) |
165 | |
{ |
166 | 168 | queryManagerURL = properties.getProperty(QUERYMANAGER_PROPERTY); |
167 | 168 | lifeCycleManagerURL = properties.getProperty(LIFECYCLEMANAGER_PROPERTY); |
168 | 168 | securityManagerURL = properties.getProperty(SECURITYMANAGER_PROPERTY); |
169 | |
|
170 | 168 | transportClass = properties.getProperty(RegistryImpl.TRANSPORT_CLASS_PROPERTY_NAME); |
171 | 168 | semanticEquivalences = properties.getProperty(SEMANTICEQUIVALENCES_PROPERTY); |
172 | 168 | authenticationMethod = properties.getProperty(AUTHENTICATIONMETHOD_PROPERTY); |
173 | 168 | postalAddressScheme = properties.getProperty(POSTALADDRESSSCHEME_PROPERTY); |
174 | 168 | uddiVersion = properties.getProperty(RegistryImpl.UDDI_VERSION_PROPERTY_NAME); |
175 | 168 | uddiNamespace = properties.getProperty(RegistryImpl.UDDI_NAMESPACE_PROPERTY_NAME); |
176 | |
|
177 | 168 | String val = properties.getProperty(MAXROWS_PROPERTY); |
178 | 168 | maxRows = (val == null) ? null : Integer.valueOf(val); |
179 | 168 | } |
180 | |
|
181 | |
public static ConnectionFactory newInstance() |
182 | |
{ |
183 | 0 | return new ConnectionFactoryImpl(); |
184 | |
} |
185 | |
|
186 | |
public String getAuthenticationMethod() |
187 | |
{ |
188 | 6 | return authenticationMethod; |
189 | |
} |
190 | |
|
191 | |
public void setAuthenticationMethod(String authenticationMethod) |
192 | |
{ |
193 | 12 | this.authenticationMethod = authenticationMethod; |
194 | 12 | } |
195 | |
|
196 | |
public String getLifeCycleManagerURL() |
197 | |
{ |
198 | 6 | return lifeCycleManagerURL; |
199 | |
} |
200 | |
|
201 | |
public void setLifeCycleManagerURL(String lifeCycleManagerURL) |
202 | |
{ |
203 | 24 | this.lifeCycleManagerURL = lifeCycleManagerURL; |
204 | 24 | } |
205 | |
|
206 | |
public Integer getMaxRows() |
207 | |
{ |
208 | 6 | return maxRows; |
209 | |
} |
210 | |
|
211 | |
public void setMaxRows(Integer maxRows) |
212 | |
{ |
213 | 12 | this.maxRows = maxRows; |
214 | 12 | } |
215 | |
|
216 | |
public String getPostalAddressScheme() |
217 | |
{ |
218 | 6 | return postalAddressScheme; |
219 | |
} |
220 | |
|
221 | |
public void setPostalAddressScheme(String postalAddressScheme) |
222 | |
{ |
223 | 12 | this.postalAddressScheme = postalAddressScheme; |
224 | 12 | } |
225 | |
|
226 | |
public String getQueryManagerURL() |
227 | |
{ |
228 | 6 | return queryManagerURL; |
229 | |
} |
230 | |
|
231 | |
public void setQueryManagerURL(String queryManagerURL) |
232 | |
{ |
233 | 24 | this.queryManagerURL = queryManagerURL; |
234 | 24 | } |
235 | |
|
236 | |
public String getSemanticEquivalences() |
237 | |
{ |
238 | 6 | return semanticEquivalences; |
239 | |
} |
240 | |
|
241 | |
public void setSemanticEquivalences(String semanticEquivalences) |
242 | |
{ |
243 | 12 | this.semanticEquivalences = semanticEquivalences; |
244 | 12 | } |
245 | |
|
246 | |
public String getTransportClass() { |
247 | 0 | return transportClass; |
248 | |
} |
249 | |
|
250 | |
public void setTransportClass(String transportClass) { |
251 | 0 | this.transportClass = transportClass; |
252 | 0 | } |
253 | |
} |