Coverage Report - org.apache.ws.scout.registry.ConnectionImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ConnectionImpl
0%
0/43
0%
0/12
1.778
 
 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.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.UDDIClerkManager;
 32  
 
 33  
 /**
 34  
  * Apache Scout Implementation of a JAXR Connection.
 35  
  * For futher details, look into the JAXR API Javadoc.
 36  
  *
 37  
  * @author Anil Saldhana  <anil@apache.org>
 38  
  * @author Tom Cunningham <tcunning@apache.org>
 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  0
         private static Log log = LogFactory.getLog(ConnectionImpl.class);
 48  0
         private boolean closed = false;
 49  0
     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  0
     UDDIClerkManager manager = null;
 56  
 
 57  
     public ConnectionImpl(Properties properties) throws InvalidRequestException
 58  0
     {
 59  0
         postalScheme = properties.getProperty(ConnectionFactoryImpl.POSTALADDRESSSCHEME_PROPERTY);
 60  0
         String val = properties.getProperty(ConnectionFactoryImpl.MAXROWS_PROPERTY);
 61  0
         maxRows = (val == null) ? -1 : Integer.valueOf(val);
 62  0
         uddiVersion = properties.getProperty(ConnectionFactoryImpl.UDDI_VERSION_PROPERTY, DEFAULT_UDDI_VERSION);
 63  
      
 64  0
         String uddiConfigFile      = properties.getProperty(JUDDI_CLIENT_CONFIG_FILE);// DEFAULT_JUDDI_CLIENT_CONFIG_FILE);
 65  0
         if (isUDDIv3(uddiVersion)) {
 66  0
             String nodeName = null;
 67  0
             String managerName = null;
 68  0
             if (manager==null && uddiConfigFile!=null) {
 69  
                 try {
 70  0
                     manager = new UDDIClerkManager(uddiConfigFile, properties);
 71  0
                     manager.start();
 72  0
                 } catch (ConfigurationException e) {
 73  0
                     log.error(e.getMessage(),e);
 74  0
                 }
 75  
             }
 76  0
             if (manager !=null) {
 77  
                 try {
 78  0
                     managerName = manager.getName();
 79  0
                     nodeName = manager.getClientConfig().getHomeNode().getName();
 80  0
                 } catch (ConfigurationException e) {
 81  0
                     log.error(e.getMessage(),e);
 82  0
                 }
 83  
             }
 84  0
             registry = new RegistryV3Impl(properties, nodeName, managerName);
 85  0
         } else {
 86  0
             registry = new RegistryImpl(properties);                   
 87  
         }
 88  
 
 89  
         //this.postalScheme = postalScheme;
 90  
         //this.maxRows = maxRows;
 91  
 
 92  0
     }
 93  
     
 94  
     private boolean isUDDIv3(String version) {
 95  0
         if (version.startsWith("3")) return true;
 96  0
         return false;
 97  
     }
 98  
 
 99  
     public RegistryService getRegistryService() throws JAXRException
 100  
     {
 101  0
         RegistryServiceImpl reg = new RegistryServiceImpl(registry, postalScheme, maxRows, uddiVersion);
 102  0
         reg.setConnection(this);
 103  0
         return reg;
 104  
     }
 105  
 
 106  
     public void close()
 107  
     {
 108  0
         closed = true;
 109  0
     }
 110  
 
 111  
     public boolean isClosed()
 112  
     {
 113  0
         return closed;
 114  
     }
 115  
 
 116  
     public Set getCredentials()
 117  
     {
 118  0
         return credentials;
 119  
     }
 120  
 
 121  
     public void setCredentials(Set credentials)
 122  
     {
 123  0
         this.credentials = credentials;
 124  0
     }
 125  
 
 126  
     public boolean isSynchronous()
 127  
     {
 128  0
         return synchronous;
 129  
     }
 130  
 
 131  
     public void setSynchronous(boolean synchronous)
 132  
     {
 133  0
         this.synchronous = synchronous;
 134  0
     }
 135  
 }