Coverage Report - org.apache.ws.scout.registry.ConnectionImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ConnectionImpl
84%
31/37
80%
8/10
1.625
 
 1  
 /*
 2  
  * Copyright 2001-2004 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.ws.scout.registry;
 18  
 
 19  
 import java.io.Serializable;
 20  
 import java.net.URI;
 21  
 import java.util.Properties;
 22  
 import java.util.Set;
 23  
 
 24  
 import javax.xml.registry.Connection;
 25  
 import javax.xml.registry.JAXRException;
 26  
 import javax.xml.registry.RegistryService;
 27  
 
 28  
 /**
 29  
  * Apache Scout Implementation of a JAXR Connection.
 30  
  * For futher details, look into the JAXR API Javadoc.
 31  
  *
 32  
  * @author Anil Saldhana  <anil@apache.org>
 33  
  * @author Tom Cunningham <tcunning@apache.org>
 34  
  */
 35  
 public class ConnectionImpl implements Connection, Serializable
 36  
 {
 37  
         private static final long serialVersionUID = 3542404895814764176L;
 38  348
         private boolean closed = false;
 39  348
     private boolean synchronous = true;
 40  
     private Set credentials;
 41  
     private final IRegistryBase registry;
 42  
     private final String postalScheme;
 43  
     private final int maxRows;
 44  
     private String uddiVersion;
 45  
 
 46  
     public ConnectionImpl(URI queryManagerURI, URI lifeCycleManagerURI, URI securityManagerURI, String transportClass, String postalScheme, int maxRows,
 47  
             String uddiNamespace, String uddiVersion)
 48  348
     {
 49  348
         Properties prop = new Properties();
 50  
         /**
 51  
          * If you want to override any of the properties
 52  
          * juddi RegistryProxy uses, set the System property
 53  
          * accordingly.
 54  
          */
 55  348
                 this.uddiVersion = uddiVersion;
 56  348
                 if (uddiVersion != null) {
 57  336
                         prop.setProperty(RegistryImpl.UDDI_VERSION_PROPERTY_NAME, uddiVersion);
 58  
                 } else {
 59  12
                     prop.setProperty(RegistryImpl.UDDI_VERSION_PROPERTY_NAME, RegistryImpl.DEFAULT_UDDI_VERSION);
 60  
                 }
 61  
                         
 62  348
                 if (uddiNamespace!=null) {
 63  336
                     prop.setProperty(RegistryImpl.UDDI_NAMESPACE_PROPERTY_NAME, uddiNamespace);
 64  
                 } else {
 65  12
                         prop.setProperty(RegistryImpl.UDDI_NAMESPACE_PROPERTY_NAME, RegistryImpl.DEFAULT_UDDI_NAMESPACE);
 66  
                 }
 67  
                 
 68  348
         if (transportClass!=null) {
 69  336
                     prop.setProperty(RegistryImpl.TRANSPORT_CLASS_PROPERTY_NAME, transportClass);
 70  
         } else {
 71  12
                     String transport = SecurityActions.getProperty(RegistryImpl.TRANSPORT_CLASS_PROPERTY_NAME);
 72  12
                     if (transport != null) {
 73  0
                             prop.setProperty(RegistryImpl.TRANSPORT_CLASS_PROPERTY_NAME, transport);
 74  
                     }
 75  
         }
 76  
         /**
 77  
          * Even if the properties passed contains no values,
 78  
          * juddi takes default values
 79  
          */
 80  348
         if ("3.0".equals(uddiVersion)) {
 81  0
                 registry = new RegistryV3Impl(prop);
 82  
         } else {
 83  348
             registry = new RegistryImpl(prop);                   
 84  
         }
 85  348
         registry.setInquiryURI(queryManagerURI);
 86  348
         registry.setPublishURI(lifeCycleManagerURI);
 87  348
         registry.setSecurityURI(securityManagerURI);
 88  348
         this.postalScheme = postalScheme;
 89  348
         this.maxRows = maxRows;
 90  
 
 91  348
     }
 92  
 
 93  
     public RegistryService getRegistryService() throws JAXRException
 94  
     {
 95  270
         RegistryServiceImpl reg = new RegistryServiceImpl(registry, postalScheme, maxRows, uddiVersion);
 96  270
         reg.setConnection(this);
 97  270
         return reg;
 98  
     }
 99  
 
 100  
     public void close()
 101  
     {
 102  186
         closed = true;
 103  186
     }
 104  
 
 105  
     public boolean isClosed()
 106  
     {
 107  0
         return closed;
 108  
     }
 109  
 
 110  
     public Set getCredentials()
 111  
     {
 112  450
         return credentials;
 113  
     }
 114  
 
 115  
     public void setCredentials(Set credentials)
 116  
     {
 117  222
         this.credentials = credentials;
 118  222
     }
 119  
 
 120  
     public boolean isSynchronous()
 121  
     {
 122  0
         return synchronous;
 123  
     }
 124  
 
 125  
     public void setSynchronous(boolean synchronous)
 126  
     {
 127  0
         this.synchronous = synchronous;
 128  0
     }
 129  
 }