001: /*
002: * Copyright 2001-2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.apache.ws.scout.registry;
018:
019: import java.io.Serializable;
020: import java.net.URI;
021: import java.util.Properties;
022: import java.util.Set;
023:
024: import javax.xml.registry.Connection;
025: import javax.xml.registry.JAXRException;
026: import javax.xml.registry.RegistryService;
027:
028: /**
029: * Apache Scout Implementation of a JAXR Connection.
030: * For futher details, look into the JAXR API Javadoc.
031: *
032: * @author Anil Saldhana <anil@apache.org>
033: */
034: public class ConnectionImpl implements Connection, Serializable {
035: private static final long serialVersionUID = 1L;
036: private boolean closed = false;
037: private boolean synchronous = true;
038: private Set credentials;
039: private final RegistryImpl registry;
040: private final String postalScheme;
041: private final int maxRows;
042:
043: public ConnectionImpl(URI queryManagerURI, URI lifeCycleManagerURI,
044: String transportClass, String postalScheme, int maxRows) {
045: Properties prop = new Properties();
046: /**
047: * If you want to override any of the properties
048: * juddi RegistryProxy uses, set the System property
049: * accordingly.
050: */
051: if (transportClass != null) {
052: prop.setProperty(
053: RegistryImpl.TRANSPORT_CLASS_PROPERTY_NAME,
054: transportClass);
055: } else {
056: String transport = System
057: .getProperty(RegistryImpl.TRANSPORT_CLASS_PROPERTY_NAME);
058: if (transport != null) {
059: prop.setProperty(
060: RegistryImpl.TRANSPORT_CLASS_PROPERTY_NAME,
061: transport);
062: }
063: }
064: /**
065: * Even if the properties passed contains no values,
066: * juddi takes default values
067: */
068: registry = new RegistryImpl(prop);
069: registry.setInquiryURI(queryManagerURI);
070: registry.setPublishURI(lifeCycleManagerURI);
071: this .postalScheme = postalScheme;
072: this .maxRows = maxRows;
073:
074: }
075:
076: public RegistryService getRegistryService() throws JAXRException {
077: RegistryServiceImpl reg = new RegistryServiceImpl(registry,
078: postalScheme, maxRows);
079: reg.setConnection(this );
080: return reg;
081: }
082:
083: public void close() {
084: closed = true;
085: }
086:
087: public boolean isClosed() {
088: return closed;
089: }
090:
091: public Set getCredentials() {
092: return credentials;
093: }
094:
095: public void setCredentials(Set credentials) {
096: this .credentials = credentials;
097: }
098:
099: public boolean isSynchronous() {
100: return synchronous;
101: }
102:
103: public void setSynchronous(boolean synchronous) {
104: this.synchronous = synchronous;
105: }
106: }
|