This project has retired. For details please refer to its
Attic page.
ConnectionImpl xref
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.util.Properties;
21 import java.util.Set;
22
23 import javax.xml.registry.Connection;
24 import javax.xml.registry.InvalidRequestException;
25 import javax.xml.registry.JAXRException;
26 import javax.xml.registry.RegistryService;
27
28 import org.apache.commons.configuration.ConfigurationException;
29 import org.apache.commons.logging.Log;
30 import org.apache.commons.logging.LogFactory;
31 import org.apache.juddi.v3.client.config.UDDIClient;
32
33
34
35
36
37
38
39
40 public class ConnectionImpl implements Connection, Serializable
41 {
42 public static final String JUDDI_CLIENT_CONFIG_FILE = "scout.juddi.client.config.file";
43 public static final String DEFAULT_JUDDI_CLIENT_CONFIG_FILE = "META-INF/jaxr-uddi.xml";
44 public static final String DEFAULT_UDDI_VERSION = "2.0";
45
46 private static final long serialVersionUID = 3542404895814764176L;
47 private static Log log = LogFactory.getLog(ConnectionImpl.class);
48 private boolean closed = false;
49 private boolean synchronous = true;
50 private Set credentials;
51 private final IRegistryBase registry;
52 private final String postalScheme;
53 private final int maxRows;
54 private String uddiVersion;
55 UDDIClient manager = null;
56
57 public ConnectionImpl(Properties properties) throws InvalidRequestException
58 {
59 postalScheme = properties.getProperty(ConnectionFactoryImpl.POSTALADDRESSSCHEME_PROPERTY);
60 String val = properties.getProperty(ConnectionFactoryImpl.MAXROWS_PROPERTY);
61 maxRows = (val == null) ? -1 : Integer.valueOf(val);
62 uddiVersion = properties.getProperty(ConnectionFactoryImpl.UDDI_VERSION_PROPERTY, DEFAULT_UDDI_VERSION);
63
64
65 if (!properties.contains(ConnectionFactoryImpl.UDDI_VERSION_PROPERTY)
66 && (properties.contains(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY))
67 && properties.getProperty(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY).contains("v3") ) {
68 properties.setProperty(ConnectionFactoryImpl.UDDI_VERSION_PROPERTY, "3.0");
69 uddiVersion = "3.0";
70 String securityManager = properties.getProperty(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY).replace("publish", "security");
71 properties.setProperty(ConnectionFactoryImpl.SECURITYMANAGER_PROPERTY, securityManager);
72 }
73
74 String uddiConfigFile = properties.getProperty(JUDDI_CLIENT_CONFIG_FILE);
75 if (isUDDIv3(uddiVersion)) {
76 String nodeName = null;
77 String managerName = null;
78 if (manager==null && uddiConfigFile!=null) {
79 try {
80 manager = new UDDIClient(uddiConfigFile, properties);
81 manager.start();
82 } catch (ConfigurationException e) {
83 log.error(e.getMessage(),e);
84 }
85 }
86 if (manager !=null) {
87 try {
88 managerName = manager.getName();
89 nodeName = manager.getClientConfig().getHomeNode().getName();
90 } catch (ConfigurationException e) {
91 log.error(e.getMessage(),e);
92 }
93 }
94 registry = new RegistryV3Impl(properties, nodeName, managerName);
95 } else {
96 registry = new RegistryImpl(properties);
97 }
98
99
100
101
102 }
103
104 private boolean isUDDIv3(String version) {
105 if (version.startsWith("3")) return true;
106 return false;
107 }
108
109 public RegistryService getRegistryService() throws JAXRException
110 {
111 RegistryServiceImplryServiceImpl.html#RegistryServiceImpl">RegistryServiceImpl reg = new RegistryServiceImpl(registry, postalScheme, maxRows, uddiVersion);
112 reg.setConnection(this);
113 return reg;
114 }
115
116 public void close()
117 {
118 closed = true;
119 }
120
121 public boolean isClosed()
122 {
123 return closed;
124 }
125
126 public Set getCredentials()
127 {
128 return credentials;
129 }
130
131 public void setCredentials(Set credentials)
132 {
133 this.credentials = credentials;
134 }
135
136 public boolean isSynchronous()
137 {
138 return synchronous;
139 }
140
141 public void setSynchronous(boolean synchronous)
142 {
143 this.synchronous = synchronous;
144 }
145 }