| 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 | 2 | private static Log log = LogFactory.getLog(ConnectionImpl.class); |
| 48 | 116 | private boolean closed = false; |
| 49 | 116 | 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 | 116 | UDDIClient manager = null; |
| 56 | |
|
| 57 | |
public ConnectionImpl(Properties properties) throws InvalidRequestException |
| 58 | 116 | { |
| 59 | 116 | postalScheme = properties.getProperty(ConnectionFactoryImpl.POSTALADDRESSSCHEME_PROPERTY); |
| 60 | 116 | String val = properties.getProperty(ConnectionFactoryImpl.MAXROWS_PROPERTY); |
| 61 | 116 | maxRows = (val == null) ? -1 : Integer.valueOf(val); |
| 62 | 116 | uddiVersion = properties.getProperty(ConnectionFactoryImpl.UDDI_VERSION_PROPERTY, DEFAULT_UDDI_VERSION); |
| 63 | |
|
| 64 | |
|
| 65 | 116 | if (!properties.contains(ConnectionFactoryImpl.UDDI_VERSION_PROPERTY) |
| 66 | 116 | && (properties.contains(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY)) |
| 67 | 0 | && properties.getProperty(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY).contains("v3") ) { |
| 68 | 0 | properties.setProperty(ConnectionFactoryImpl.UDDI_VERSION_PROPERTY, "3.0"); |
| 69 | 0 | uddiVersion = "3.0"; |
| 70 | 0 | String securityManager = properties.getProperty(ConnectionFactoryImpl.LIFECYCLEMANAGER_PROPERTY).replace("publish", "security"); |
| 71 | 0 | properties.setProperty(ConnectionFactoryImpl.SECURITYMANAGER_PROPERTY, securityManager); |
| 72 | |
} |
| 73 | |
|
| 74 | 116 | String uddiConfigFile = properties.getProperty(JUDDI_CLIENT_CONFIG_FILE); |
| 75 | 116 | if (isUDDIv3(uddiVersion)) { |
| 76 | 0 | String nodeName = null; |
| 77 | 0 | String managerName = null; |
| 78 | 0 | if (manager==null && uddiConfigFile!=null) { |
| 79 | |
try { |
| 80 | 0 | manager = new UDDIClient(uddiConfigFile, properties); |
| 81 | 0 | manager.start(); |
| 82 | 0 | } catch (ConfigurationException e) { |
| 83 | 0 | log.error(e.getMessage(),e); |
| 84 | 0 | } |
| 85 | |
} |
| 86 | 0 | if (manager !=null) { |
| 87 | |
try { |
| 88 | 0 | managerName = manager.getName(); |
| 89 | 0 | nodeName = manager.getClientConfig().getHomeNode().getName(); |
| 90 | 0 | } catch (ConfigurationException e) { |
| 91 | 0 | log.error(e.getMessage(),e); |
| 92 | 0 | } |
| 93 | |
} |
| 94 | 0 | registry = new RegistryV3Impl(properties, nodeName, managerName); |
| 95 | 0 | } else { |
| 96 | 116 | registry = new RegistryImpl(properties); |
| 97 | |
} |
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
|
| 102 | 116 | } |
| 103 | |
|
| 104 | |
private boolean isUDDIv3(String version) { |
| 105 | 116 | if (version.startsWith("3")) return true; |
| 106 | 116 | return false; |
| 107 | |
} |
| 108 | |
|
| 109 | |
public RegistryService getRegistryService() throws JAXRException |
| 110 | |
{ |
| 111 | 136 | RegistryServiceImpl reg = new RegistryServiceImpl(registry, postalScheme, maxRows, uddiVersion); |
| 112 | 136 | reg.setConnection(this); |
| 113 | 136 | return reg; |
| 114 | |
} |
| 115 | |
|
| 116 | |
public void close() |
| 117 | |
{ |
| 118 | 62 | closed = true; |
| 119 | 62 | } |
| 120 | |
|
| 121 | |
public boolean isClosed() |
| 122 | |
{ |
| 123 | 0 | return closed; |
| 124 | |
} |
| 125 | |
|
| 126 | |
public Set getCredentials() |
| 127 | |
{ |
| 128 | 202 | return credentials; |
| 129 | |
} |
| 130 | |
|
| 131 | |
public void setCredentials(Set credentials) |
| 132 | |
{ |
| 133 | 118 | this.credentials = credentials; |
| 134 | 118 | } |
| 135 | |
|
| 136 | |
public boolean isSynchronous() |
| 137 | |
{ |
| 138 | 0 | return synchronous; |
| 139 | |
} |
| 140 | |
|
| 141 | |
public void setSynchronous(boolean synchronous) |
| 142 | |
{ |
| 143 | 0 | this.synchronous = synchronous; |
| 144 | 0 | } |
| 145 | |
} |