geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r561152 - in /geronimo/server/branches/2.0/modules: geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/ geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/
Date Mon, 30 Jul 2007 22:18:33 GMT
Author: gawor
Date: Mon Jul 30 15:18:32 2007
New Revision: 561152

URL: http://svn.apache.org/viewvc?view=rev&rev=561152
Log:
let each module have its own ClientConfiguration (might need to scope it more in the future)

Added:
    geronimo/server/branches/2.0/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ClientConfigurationFactory.java
    geronimo/server/branches/2.0/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ConfigGBean.java
Modified:
    geronimo/server/branches/2.0/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java

Modified: geronimo/server/branches/2.0/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java?view=diff&rev=561152&r1=561151&r2=561152
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java
(original)
+++ geronimo/server/branches/2.0/modules/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java
Mon Jul 30 15:18:32 2007
@@ -18,13 +18,19 @@
 package org.apache.geronimo.axis2.builder;
 
 import org.apache.geronimo.jaxws.builder.JAXWSServiceRefBuilder;
+import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
+import org.apache.geronimo.kernel.GBeanNotFoundException;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.xbeans.javaee.PortComponentRefType;
 import org.apache.geronimo.xbeans.javaee.ServiceRefType;
 import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
+import org.apache.geronimo.j2ee.deployment.EARContext;
 import org.apache.geronimo.j2ee.deployment.Module;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.axis2.client.Axis2ConfigGBean;
 import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.naming.deployment.ServiceRefBuilder;
@@ -48,11 +54,32 @@
                                 Module module, ClassLoader cl, Class serviceInterfaceClass,
                                 QName serviceQName, URI wsdlURI, Class serviceReferenceType,
                                 Map<Class, PortComponentRefType> portComponentRefMap)
throws DeploymentException {
+        registerConfigGBean(module);
         return this.axis2Builder.createService(serviceInterfaceClass, serviceReferenceType,
wsdlURI,
                                              serviceQName, portComponentRefMap, serviceRef.getHandlerChains(),
                                              gerServiceRef, module, cl);
     }
 
+    private void registerConfigGBean(Module module) throws DeploymentException {
+        EARContext context = module.getEarContext();
+        AbstractName containerFactoryName = context.getNaming().createChildName(
+                module.getModuleName(), Axis2ConfigGBean.GBEAN_INFO.getName(),
+                NameFactory.GERONIMO_SERVICE);
+
+        try {
+            context.getGBeanInstance(containerFactoryName);
+        } catch (GBeanNotFoundException e1) {
+            GBeanData configGBeanData = new GBeanData(containerFactoryName, Axis2ConfigGBean.GBEAN_INFO);
+            configGBeanData.setAttribute("moduleName", module.getModuleName());
+            
+            try {
+                context.addGBean(configGBeanData);
+            } catch (GBeanAlreadyExistsException e) {
+                throw new DeploymentException("Could not add config gbean", e);
+            }
+        }
+    }
+    
     public static final GBeanInfo GBEAN_INFO;
 
     static {

Added: geronimo/server/branches/2.0/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ClientConfigurationFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ClientConfigurationFactory.java?view=auto&rev=561152
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ClientConfigurationFactory.java
(added)
+++ geronimo/server/branches/2.0/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ClientConfigurationFactory.java
Mon Jul 30 15:18:32 2007
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.geronimo.axis2.client;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.ConfigurationContextFactory;
+import org.apache.axis2.jaxws.ClientConfigurationFactory;
+import org.apache.axis2.jaxws.util.ClassLoaderUtils;
+import org.apache.axis2.jaxws.util.Constants;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class Axis2ClientConfigurationFactory extends ClientConfigurationFactory {
+
+    private static final Log LOG = LogFactory.getLog(Axis2ClientConfigurationFactory.class);
+    
+    private Map<ClassLoader, ConfigurationContext> contextCache = 
+        new Hashtable<ClassLoader, ConfigurationContext>();
+
+    private boolean reuseConfigurationContext;
+    
+    public Axis2ClientConfigurationFactory(boolean reuse) {
+        this.reuseConfigurationContext = reuse;
+    }
+    
+    public ConfigurationContext getClientConfigurationContext() {
+        ClassLoader cl = ClassLoaderUtils.getContextClassLoader();
+        if (cl == null) {
+            if (this.reuseConfigurationContext) {
+                cl = ClientConfigurationFactory.class.getClassLoader();
+            } else {
+                return createConfigurationContext();
+            }
+        }
+
+        synchronized (cl) {
+            return getConfigurationContext(cl);
+        }
+    }
+    
+    private ConfigurationContext getConfigurationContext(ClassLoader cl) {
+        ConfigurationContext context = this.contextCache.get(cl);
+        if (context == null) {            
+            context = createConfigurationContext();
+            this.contextCache.put(cl, context);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Created new configuration context " + context + "  for " + cl);
+            }
+        } else {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Configuration context " + context + " reused for " + cl);
+            }
+        }
+        return context;
+    }
+    
+    private ConfigurationContext removeConfigurationContext(ClassLoader cl) {
+        return this.contextCache.remove(cl);
+    }
+    
+    public void clearCache() {
+        this.contextCache.clear();
+    }
+    
+    public void clearCache(ClassLoader cl) {
+        synchronized(cl) {
+            ConfigurationContext context = removeConfigurationContext(cl);
+            if (LOG.isDebugEnabled()) {                
+                LOG.debug("Removed configuration context " + context + " for " + cl);
+            }
+        }
+    }
+    
+    private ConfigurationContext createConfigurationContext() {
+        String repoPath = System.getProperty(Constants.AXIS2_REPO_PATH);
+        String axisConfigPath = System.getProperty(Constants.AXIS2_CONFIG_PATH);
+        try {
+            return ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,
axisConfigPath);
+        } catch (AxisFault e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+    }
+
+}

Added: geronimo/server/branches/2.0/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ConfigGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/branches/2.0/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ConfigGBean.java?view=auto&rev=561152
==============================================================================
--- geronimo/server/branches/2.0/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ConfigGBean.java
(added)
+++ geronimo/server/branches/2.0/modules/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ConfigGBean.java
Mon Jul 30 15:18:32 2007
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.geronimo.axis2.client;
+
+import java.net.URL;
+
+import org.apache.axis2.jaxws.ClientConfigurationFactory;
+import org.apache.axis2.metadata.registry.MetadataFactoryRegistry;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.Kernel;
+
+public class Axis2ConfigGBean implements GBeanLifecycle {
+
+    private static final Log LOG = LogFactory.getLog(Axis2ConfigGBean.class);
+    
+    private AbstractName moduleName;
+    private ClassLoader classLoder;   
+
+    public Axis2ConfigGBean(ClassLoader classLoader,                          
+                            Kernel kernel,                          
+                            URL configurationBaseUrl,
+                            AbstractName moduleName) {
+        this.moduleName = moduleName;
+        this.classLoder = classLoader;
+    }
+
+    private synchronized static Axis2ClientConfigurationFactory registerClientConfigurationFactory()
{
+        ClientConfigurationFactory factory =
+            (ClientConfigurationFactory)MetadataFactoryRegistry.getFactory(ClientConfigurationFactory.class);
+        if (factory instanceof Axis2ClientConfigurationFactory) {
+            return (Axis2ClientConfigurationFactory)factory;
+        } else {
+            factory = new Axis2ClientConfigurationFactory(false);
+            MetadataFactoryRegistry.setFactory(ClientConfigurationFactory.class, factory);
+            LOG.debug("Registered client configuration factory: " + factory);
+            return (Axis2ClientConfigurationFactory)factory;
+        }
+    }
+    
+    public void doStart() throws Exception {
+        registerClientConfigurationFactory();
+    }
+    
+    public void doStop() throws Exception {             
+        registerClientConfigurationFactory().clearCache(this.classLoder);
+    }
+
+    public void doFail() {
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(Axis2ConfigGBean.class,
Axis2ConfigGBean.class, NameFactory.GERONIMO_SERVICE);
+                
+        infoFactory.addAttribute("classLoader", ClassLoader.class, false);
+        infoFactory.addAttribute("kernel", Kernel.class, false);
+        infoFactory.addAttribute("configurationBaseUrl", URL.class, true);
+        infoFactory.addAttribute("moduleName", AbstractName.class, true);
+        
+        infoFactory.setConstructor(new String[]{"classLoader", "kernel", "configurationBaseUrl",
"moduleName"});
+        
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+
+}



Mime
View raw message