You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2008/02/12 19:20:10 UTC

svn commit: r620890 - /webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/ClientConfigurationFactory.java

Author: dims
Date: Tue Feb 12 10:20:07 2008
New Revision: 620890

URL: http://svn.apache.org/viewvc?rev=620890&view=rev
Log:
Fix for AXIS2-3507 - Writing JAXWS Clients - How to specify the axis2.xml and repository

Modified:
    webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/ClientConfigurationFactory.java

Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/ClientConfigurationFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/ClientConfigurationFactory.java?rev=620890&r1=620889&r2=620890&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/ClientConfigurationFactory.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/ClientConfigurationFactory.java Tue Feb 12 10:20:07 2008
@@ -19,6 +19,7 @@
 package org.apache.axis2.jaxws;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.engine.AxisConfigurator;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.deployment.DeploymentException;
@@ -34,6 +35,7 @@
 public class ClientConfigurationFactory {
     
     private static final Log log = LogFactory.getLog(ClientConfigurationFactory.class);
+    private ConfigurationContext configContext = null;
 
     /** Returns a ClientConfigurationFactory object. */
     public static ClientConfigurationFactory newInstance() {
@@ -41,25 +43,59 @@
     }
 
     /**
+     * Create a ConfigurationContext from the specified configurator 
+     * 
+     * @param configurator
+     */
+    public ClientConfigurationFactory(AxisConfigurator configurator) {
+        try {
+            configContext = ConfigurationContextFactory.createConfigurationContext(configurator);
+        } catch (AxisFault e) {
+            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("clientConfigCtxtErr", e.getMessage()));
+        }
+    }
+
+    /**
+     * Default constructor
+     */
+    public ClientConfigurationFactory() {
+    }
+
+    /**
      * Loads up a ConfigurationContext object using the configuration builder.
      *
      * @return a ConfigurationContext object that is suitable for the client environment
      */
     public synchronized ConfigurationContext getClientConfigurationContext() {
-        ConfigurationContext configContext = null;
+        // If the user has specified on use it.
+        if (configContext != null) {
+            return configContext;
+        }
+        
+        // Get the system properties for axis2.xml and the repository.
         String repoPath = System.getProperty(Constants.AXIS2_REPO_PATH);
         String axisConfigPath = System.getProperty(Constants.AXIS2_CONFIG_PATH);
-        if(log.isDebugEnabled()){
-        	log.debug("Axis2 repository path : "+repoPath);
-        	log.debug("Axis2 Config path : "+axisConfigPath);
+        if (log.isDebugEnabled()) {
+            log.debug("Axis2 repository path : " + repoPath);
+            log.debug("Axis2 Config path : " + axisConfigPath);
+        }
+        
+        // If they are not specified, create a default one from the axis2_default.xml inside the kernel jar.
+        if (repoPath == null && axisConfigPath == null) {
+            try {
+                configContext = ConfigurationContextFactory.createDefaultConfigurationContext();
+            } catch (Exception e) {
+                throw ExceptionFactory.makeWebServiceException(Messages.getMessage("clientConfigCtxtErr", e.getMessage()));
+            }
         }
+        
+        // Try the file system with the specified system properties.
         try {
-            configContext = ConfigurationContextFactory
+            return ConfigurationContextFactory
                     .createConfigurationContextFromFileSystem(repoPath, axisConfigPath);
         } catch (AxisFault e) {
         	throw ExceptionFactory.makeWebServiceException(Messages.getMessage("clientConfigCtxtErr",e.getMessage()));
         }
-        return configContext;
     }
 
     /**



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