axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntha...@apache.org
Subject svn commit: r515867 - in /webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description: DescriptionFactory.java DescriptionKey.java impl/DescriptionFactoryImpl.java impl/EndpointDescriptionImpl.java impl/ServiceDescriptionImpl.java
Date Thu, 08 Mar 2007 00:30:23 GMT
Author: nthaker
Date: Wed Mar  7 16:30:22 2007
New Revision: 515867

URL: http://svn.apache.org/viewvc?view=rev&rev=515867
Log:
Axis2-2299

Fix for caching ServiceDescription.

Added:
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionKey.java
Modified:
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java?view=diff&rev=515867&r1=515866&r2=515867
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java
Wed Mar  7 16:30:22 2007
@@ -25,6 +25,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.axis2.description.AxisService;
+import org.apache.axis2.jaxws.ClientConfigurationFactory;
 import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
 import org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl;
 
@@ -175,5 +176,11 @@
         return DescriptionFactoryImpl.createServiceDescriptionFromServiceImpl(serviceImplClass,
axisService);
     }
     
-
+    /**
+     * Creates Client ConfigurationFactory used to create AxisConfiguration.  
+     * @return A Client Configuration Factory's new instance. ClinetConfigurationFactory
is Singleton.
+    */
+    public static ClientConfigurationFactory createClientConfigurationFactory(){
+        return DescriptionFactoryImpl.getClientConfigurationFactory();
+    }
 }

Added: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionKey.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionKey.java?view=auto&rev=515867
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionKey.java
(added)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionKey.java
Wed Mar  7 16:30:22 2007
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.description;
+
+import java.net.URL;
+import javax.xml.namespace.QName;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.jaxws.ExceptionFactory;
+
+public class DescriptionKey {
+
+    private QName serviceName = null;
+
+    private URL wsdlUrl = null;
+
+    private Class serviceClass = null;
+
+    private ConfigurationContext configContext = null;
+
+    public DescriptionKey(QName serviceName, URL wsdlUrl, Class serviceClass,
+            ConfigurationContext configContext) {
+        super();
+        this.serviceName = serviceName;
+        this.wsdlUrl = wsdlUrl;
+        this.serviceClass = serviceClass;
+        this.configContext = configContext;
+
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+
+        if (!(o instanceof DescriptionKey)) {
+            return false;
+        }
+
+        DescriptionKey description = (DescriptionKey) o;
+
+        if (serviceName == null) {
+            throw ExceptionFactory
+                    .makeWebServiceException(org.apache.axis2.i18n.Messages
+                            .getMessage("DescriptionRegistryErr0"));
+        }
+
+        return description.serviceName.equals(this.serviceName)
+                && description.wsdlUrl !=null ? description.wsdlUrl.equals(this.wsdlUrl):
this.wsdlUrl == null
+                && description.serviceClass == this.serviceClass
+                && description.configContext == this.configContext;
+    }
+
+    @Override
+    public int hashCode() {
+
+        int hash = 1;
+        hash = 31 * hash + ((serviceName == null) ? 0 : serviceName.hashCode());
+        hash = hash + ((wsdlUrl == null) ? 0 : wsdlUrl.hashCode());
+        hash = hash + ((serviceClass == null) ? 0 : serviceClass.hashCode());
+        hash = hash + ((configContext == null) ? 0 : configContext.hashCode());
+        return hash;
+
+    }
+
+    public ConfigurationContext getConfigContext() {
+        return configContext;
+    }
+
+    public void setConfigContext(ConfigurationContext configContext) {
+        this.configContext = configContext;
+    }
+
+    public QName getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(QName serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public URL getWsdlUrl() {
+        return wsdlUrl;
+    }
+
+    public void setWsdlUrl(URL wsdlUrl) {
+        this.wsdlUrl = wsdlUrl;
+    }
+
+    public Class getServiceClass() {
+        return serviceClass;
+    }
+
+    public void setServiceClass(Class serviceClass) {
+        this.serviceClass = serviceClass;
+    }
+
+    public String printKey() {
+
+        String sName = (serviceName != null) ? serviceName.toString() : "";
+        String sWsdlURL = (wsdlUrl != null) ? wsdlUrl.toString() : "";
+        String sClass = (serviceClass != null) ? serviceClass.toString() : "";
+        String sConfig = (configContext != null) ? configContext.toString()
+                : "";
+        String key = sName + sWsdlURL + sClass + sConfig;
+        return key;
+    }
+}

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java?view=diff&rev=515867&r1=515866&r2=515867
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/DescriptionFactoryImpl.java
Wed Mar  7 16:30:22 2007
@@ -25,14 +25,19 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import javax.xml.namespace.QName;
 
+import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.description.AxisService;
+import org.apache.axis2.jaxws.ClientConfigurationFactory;
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.description.DescriptionFactory;
+import org.apache.axis2.jaxws.description.DescriptionKey;
 import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.description.ServiceDescription;
 import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
@@ -50,6 +55,8 @@
  */
 public class DescriptionFactoryImpl {
     private static final Log log = LogFactory.getLog(DescriptionFactoryImpl.class);
+    private static ClientConfigurationFactory clientConfigFactory = ClientConfigurationFactory.newInstance();
+    private static Map<DescriptionKey, ServiceDescription> cache = new Hashtable<DescriptionKey,
ServiceDescription>();
 
     /**
      * A DescrptionFactory can not be instantiated; all methods are static.
@@ -62,12 +69,42 @@
      */
     public static ServiceDescription createServiceDescription(URL wsdlURL,
             QName serviceQName, Class serviceClass) {
-        ServiceDescription serviceDesc = new ServiceDescriptionImpl(wsdlURL, serviceQName,
serviceClass);
-        
-        if (log.isDebugEnabled()) {
-            log.debug("ServiceDescription created with WSDL URL: " + wsdlURL + "; QName:
" + serviceQName + "; Class: " + serviceClass);
-            log.debug(serviceDesc.toString());
+        ConfigurationContext configContext = DescriptionFactory.createClientConfigurationFactory().getClientConfigurationContext();
+        DescriptionKey key = new DescriptionKey(serviceQName, wsdlURL, serviceClass, configContext);
+        if(log.isDebugEnabled()){
+            log.debug("Cache Map = "+ cache.toString());
+            if(key !=null)
+                log.debug("Description Key = " + key.printKey());
+            
+        }
+        ServiceDescription serviceDesc = cache.get(key);
+        if(log.isDebugEnabled()){
+            log.debug("Check to see if ServiceDescription is found in cache");
         }
+        if(serviceDesc !=null){
+            if(log.isDebugEnabled()){
+                log.debug("ServiceDescription found in the cache");
+                log.debug(serviceDesc.toString());
+            }
+        }
+        if(serviceDesc == null){
+            if(log.isDebugEnabled()){
+                log.debug("ServiceDescription not found in the cache");
+                log.debug(" creating new ServiceDescriptionImpl");
+            }
+            
+            serviceDesc = new ServiceDescriptionImpl(wsdlURL, serviceQName, serviceClass);
+            if (log.isDebugEnabled()) {
+                log.debug("ServiceDescription created with WSDL URL: " + wsdlURL + "; QName:
" + serviceQName + "; Class: " + serviceClass);
+                log.debug(serviceDesc.toString());
+            }
+            if(log.isDebugEnabled()){
+                log.debug("Caching new ServiceDescription in the cache");
+                
+            }
+            cache.put(key, serviceDesc);
+        }
+        
         return serviceDesc;
     }
 
@@ -179,6 +216,14 @@
             log.debug("EndpointDescription updated: " + endpointDesc);
         }
         return endpointDesc;
+    }
+    
+    public static ClientConfigurationFactory getClientConfigurationFactory() {
+        
+        if (clientConfigFactory == null ) {
+            clientConfigFactory = ClientConfigurationFactory.newInstance();
+        }
+        return clientConfigFactory;
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java?view=diff&rev=515867&r1=515866&r2=515867
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/EndpointDescriptionImpl.java
Wed Mar  7 16:30:22 2007
@@ -52,6 +52,7 @@
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.WSDL11ToAllAxisServicesBuilder;
 import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
+import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.java.security.AccessController;
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.description.EndpointDescription;
@@ -854,6 +855,10 @@
             if(serviceClient == null) {
                 ConfigurationContext configCtx = getServiceDescription().getAxisConfigContext();
                 AxisService axisSvc = getAxisService();
+                AxisConfiguration axisCfg = configCtx.getAxisConfiguration();
+                if(axisCfg.getService(axisSvc.getName()) != null) {
+                    axisSvc.setName(axisSvc.getName() + this.hashCode());
+                } 
                 serviceClient = new ServiceClient(configCtx, axisSvc);
             }
         } catch (AxisFault e) {

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?view=diff&rev=515867&r1=515866&r2=515867
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
(original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
Wed Mar  7 16:30:22 2007
@@ -520,7 +520,7 @@
     ClientConfigurationFactory getClientConfigurationFactory() {
         
         if (clientConfigFactory == null ) {
-            clientConfigFactory = ClientConfigurationFactory.newInstance();
+            clientConfigFactory = DescriptionFactory.createClientConfigurationFactory();
         }
         return clientConfigFactory;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message