geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r1084159 - in /geronimo/server/trunk/plugins/axis2: axis2/src/main/plan/ geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/ geronimo-axis2/src/main/java/org/apache/geronimo/axis2/ geronimo-axis2/src/main/java/org/apache...
Date Tue, 22 Mar 2011 13:10:18 GMT
Author: xuhaihong
Date: Tue Mar 22 13:10:17 2011
New Revision: 1084159

URL: http://svn.apache.org/viewvc?rev=1084159&view=rev
Log:
1. Enable Axis2 client modules discovery
2. Add GeronimoBundleFinder for runtime JAXB classes discovery

Added:
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2SystemInitializer.java
  (with props)
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/osgi/GeronimoBundleClassFinder.java
  (with props)
Modified:
    geronimo/server/trunk/plugins/axis2/axis2/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java
  (contents, props changed)
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ClientConfigurationFactory.java
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ConfigGBean.java
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/osgi/Axis2ModuleRegistry.java
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
  (contents, props changed)
    geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2Request.java

Modified: geronimo/server/trunk/plugins/axis2/axis2/src/main/plan/plan.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/axis2/src/main/plan/plan.xml?rev=1084159&r1=1084158&r2=1084159&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/axis2/src/main/plan/plan.xml (original)
+++ geronimo/server/trunk/plugins/axis2/axis2/src/main/plan/plan.xml Tue Mar 22 13:10:17 2011
@@ -20,4 +20,7 @@
 
 <module xmlns="http://geronimo.apache.org/xml/ns/deployment-${geronimoSchemaVersion}">
     <gbean name="Axis2ModuleRegistry" class="org.apache.geronimo.axis2.osgi.Axis2ModuleRegistry"/>
+
+    <gbean name="Axis2SystemInitializer" class="org.apache.geronimo.axis2.Axis2SystemInitializer"/>
+
 </module>

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java?rev=1084159&r1=1084158&r2=1084159&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java
Tue Mar 22 13:10:17 2011
@@ -18,6 +18,7 @@
 package org.apache.geronimo.axis2.builder;
 
 import java.net.URI;
+import java.util.Collections;
 import java.util.Map;
 
 import javax.xml.bind.JAXBException;
@@ -25,8 +26,10 @@ import javax.xml.namespace.QName;
 
 import org.apache.geronimo.axis2.client.Axis2ConfigGBean;
 import org.apache.geronimo.axis2.client.Axis2ServiceReference;
+import org.apache.geronimo.axis2.osgi.Axis2ModuleRegistry;
 import org.apache.geronimo.common.DeploymentException;
 import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.gbean.AbstractNameQuery;
 import org.apache.geronimo.gbean.GBeanData;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.annotation.GBean;
@@ -39,6 +42,7 @@ import org.apache.geronimo.jaxws.builder
 import org.apache.geronimo.jaxws.client.EndpointInfo;
 import org.apache.geronimo.kernel.GBeanAlreadyExistsException;
 import org.apache.geronimo.kernel.GBeanNotFoundException;
+import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
 import org.apache.openejb.jee.PortComponentRef;
@@ -88,15 +92,15 @@ public class Axis2ServiceRefBuilder exte
     private void registerConfigGBean(Module module) throws DeploymentException {
         EARContext context = module.getEarContext();
         AbstractName containerFactoryName = context.getNaming().createChildName(
-                module.getModuleName(), Axis2ConfigGBean.GBEAN_INFO.getName(),
+                module.getModuleName(), "Axis2ConfigGBean",
                 GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
 
         try {
             context.getGBeanInstance(containerFactoryName);
         } catch (GBeanNotFoundException e1) {
-            GBeanData configGBeanData = new GBeanData(containerFactoryName, Axis2ConfigGBean.GBEAN_INFO);
+            GBeanData configGBeanData = new GBeanData(containerFactoryName, Axis2ConfigGBean.class);
             configGBeanData.setAttribute("moduleName", module.getModuleName());
-
+            configGBeanData.setReferencePattern("axis2ModuleRegistry", new AbstractNameQuery(Artifact.create("org.apache.geronimo.configs/axis2//car"),
Collections.emptyMap(), Axis2ModuleRegistry.class.getName()));
             try {
                 context.addGBean(configGBeanData);
             } catch (GBeanAlreadyExistsException e) {

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2-builder/src/main/java/org/apache/geronimo/axis2/builder/Axis2ServiceRefBuilder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2SystemInitializer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2SystemInitializer.java?rev=1084159&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2SystemInitializer.java
(added)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2SystemInitializer.java
Tue Mar 22 13:10:17 2011
@@ -0,0 +1,73 @@
+/**
+ *  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;
+
+import org.apache.axis2.jaxws.message.factory.ClassFinderFactory;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+import org.apache.geronimo.axis2.osgi.GeronimoBundleClassFinder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * @version $Rev$ $Date$
+ */
+@GBean
+public class Axis2SystemInitializer implements GBeanLifecycle {
+
+    private BundleContext bundleContext;
+
+    private ServiceReference packageAdminServiceReference;
+
+    public Axis2SystemInitializer(@ParamSpecial(type = SpecialAttributeType.bundleContext)
BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+
+    @Override
+    public void doFail() {
+        try {
+            doStop();
+        } catch (Exception e) {
+        }
+    }
+
+    @Override
+    public void doStart() throws Exception {
+        packageAdminServiceReference = bundleContext.getServiceReference(PackageAdmin.class.getName());
+        PackageAdmin packageAdmin = (PackageAdmin) bundleContext.getService(packageAdminServiceReference);
+        ClassFinderFactory classFinderFactory = (ClassFinderFactory) FactoryRegistry.getFactory(ClassFinderFactory.class);
+        classFinderFactory.setClassFinder(new GeronimoBundleClassFinder(packageAdmin));
+    }
+
+    @Override
+    public void doStop() throws Exception {
+        ClassFinderFactory classFinderFactory = (ClassFinderFactory) FactoryRegistry.getFactory(ClassFinderFactory.class);
+        classFinderFactory.setClassFinder(null);
+        if (packageAdminServiceReference != null) {
+            try {
+                bundleContext.ungetService(packageAdminServiceReference);
+            } catch (Exception e) {
+            }
+        }
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2SystemInitializer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2SystemInitializer.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2SystemInitializer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java?rev=1084159&r1=1084158&r2=1084159&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/Axis2WebServiceContainer.java
Tue Mar 22 13:10:17 2011
@@ -18,15 +18,11 @@
 package org.apache.geronimo.axis2;
 
 import java.io.ByteArrayInputStream;
-import java.io.IOException;
 import java.io.PrintWriter;
 import java.net.HttpURLConnection;
 import java.net.URI;
 import java.net.URL;
-import java.util.Dictionary;
 import java.util.List;
-import java.util.Map;
-
 import javax.naming.Context;
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
@@ -45,15 +41,10 @@ import org.apache.axis2.context.Configur
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.OperationContext;
-import org.apache.axis2.deployment.DeploymentEngine;
-import org.apache.axis2.deployment.ModuleBuilder;
-import org.apache.axis2.description.AxisModule;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.description.Parameter;
 import org.apache.axis2.description.TransportInDescription;
 import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.description.Version;
-import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.engine.Handler.InvocationResponse;
 import org.apache.axis2.jaxws.addressing.util.EndpointContextMap;
@@ -69,8 +60,6 @@ import org.apache.axis2.jaxws.handler.li
 import org.apache.axis2.jaxws.registry.FactoryRegistry;
 import org.apache.axis2.jaxws.server.JAXWSMessageReceiver;
 import org.apache.axis2.jaxws.server.endpoint.lifecycle.factory.EndpointLifecycleManagerFactory;
-import org.apache.axis2.modules.Module;
-import org.apache.axis2.osgi.deployment.Registry;
 import org.apache.axis2.transport.OutTransportInfo;
 import org.apache.axis2.transport.RequestResponseTransport;
 import org.apache.axis2.transport.http.HTTPConstants;
@@ -79,7 +68,6 @@ import org.apache.axis2.transport.http.H
 import org.apache.axis2.transport.http.TransportHeaders;
 import org.apache.axis2.transport.http.util.RESTUtil;
 import org.apache.axis2.util.MessageContextBuilder;
-import org.apache.axis2.util.Utils;
 import org.apache.geronimo.axis2.client.Axis2ConfigGBean;
 import org.apache.geronimo.axis2.osgi.Axis2ModuleRegistry;
 import org.apache.geronimo.jaxws.JAXWSAnnotationProcessor;
@@ -137,12 +125,12 @@ public abstract class Axis2WebServiceCon
     public void init() throws Exception {
         this.endpointClass = bundle.loadClass(this.endpointClassName);
 
-        Axis2ConfigGBean.registerClientConfigurationFactory();
+        Axis2ConfigGBean.registerClientConfigurationFactory(axis2ModuleRegistry);
 
         GeronimoConfigurator configurator = new GeronimoConfigurator("META-INF/geronimo-axis2.xml");
         configurationContext = ConfigurationContextFactory.createConfigurationContext(configurator);
 
-        configureModules(configurationContext);
+        axis2ModuleRegistry.configureModules(configurationContext);
         // check to see if the wsdlLocation property is set in portInfo,
         // if not checking if wsdlLocation exists in annotation
         // if already set, annotation should not overwrite it.
@@ -522,58 +510,7 @@ public abstract class Axis2WebServiceCon
         DescriptionUtils.registerHandlerHeaders(desc.getAxisService(), this.binding.getHandlerChain());
     }
 
-    protected void configureModules(ConfigurationContext configurationContext) {
-        for (Map.Entry<Bundle, List<URL>> entry : axis2ModuleRegistry.getBundleModuleXmlURLsMap().entrySet())
{
-            Bundle bundle = entry.getKey();
-            for (URL url : entry.getValue()) {
-                try {
-                    AxisModule axismodule = new AxisModule();
-                    ClassLoader loader = new org.apache.axis2.osgi.deployment.BundleClassLoader(bundle,
Registry.class.getClassLoader());
-                    axismodule.setModuleClassLoader(loader);
-                    AxisConfiguration axisConfig = configurationContext.getAxisConfiguration();
-                    ModuleBuilder builder = new ModuleBuilder(url.openStream(), axismodule,
axisConfig);
-                    Dictionary headers = bundle.getHeaders();
-                    String bundleSymbolicName = (String) headers.get("Bundle-SymbolicName");
-                    if (bundleSymbolicName != null && bundleSymbolicName.length()
!= 0) {
-                        axismodule.setName(bundleSymbolicName);
-                    }
-                    String bundleVersion = (String) headers.get("Bundle-Version");
-                    if (bundleVersion != null && bundleVersion.length() != 0) {
-                        /*
-                            Bundle version is defined as
-                            version ::=
-                                major( '.' minor ( '.' micro ( '.' qualifier )? )? )?
-                                major ::= number
-                                minor ::= number
-                                micro ::= number
-                                qualifier ::= ( alphanum | ’_’ | '-' )+
-                         */
-                        String[] versionSplit = bundleVersion.split("\\.");
-                        int[] components = new int[Math.min(versionSplit.length, 3)];
-                        for (int i = 0; i < components.length; i++) {
-                            components[i] = Integer.parseInt(versionSplit[i]);
-                        }
-                        axismodule.setVersion(new Version(components, versionSplit.length
> 3 ? versionSplit[3] : null));
-                    }
-                    builder.populateModule();
-                    axismodule.setParent(axisConfig);
-                    AxisModule module = axisConfig.getModule(axismodule.getName());
-                    if (module == null) {
-                        DeploymentEngine.addNewModule(axismodule, axisConfig);
-                        //initialze the module if the module contains Module interface.
-                        Module moduleObj = axismodule.getModule();
-                        if (moduleObj != null) {
-                            moduleObj.init(configurationContext, axismodule);
-                        }
-                    }
-                    // set in default map if necessary
-                    Utils.calculateDefaultModuleVersion(axisConfig.getModules(), axisConfig);
-                } catch (IOException e) {
-                    LOG.error("Error while reading module.xml", e);
-                }
-            }
-        }
-    }
+
 
     private void logHandlers(HandlerChainsType handlerChains) {
         if (handlerChains == null || handlerChains.getHandlerChain() == null

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ClientConfigurationFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ClientConfigurationFactory.java?rev=1084159&r1=1084158&r2=1084159&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ClientConfigurationFactory.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ClientConfigurationFactory.java
Tue Mar 22 13:10:17 2011
@@ -24,6 +24,7 @@ import org.apache.axis2.context.Configur
 import org.apache.axis2.context.ConfigurationContextFactory;
 import org.apache.axis2.jaxws.ClientConfigurationFactory;
 import org.apache.geronimo.axis2.GeronimoConfigurator;
+import org.apache.geronimo.axis2.osgi.Axis2ModuleRegistry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,9 +36,11 @@ public class Axis2ClientConfigurationFac
         new Hashtable<ClassLoader, ConfigurationContext>();
 
     private boolean reuseConfigurationContext;
+    private Axis2ModuleRegistry axis2ModuleRegistry;
 
-    public Axis2ClientConfigurationFactory(boolean reuse) {
+    public Axis2ClientConfigurationFactory(Axis2ModuleRegistry axis2ModuleRegistry, boolean
reuse) {
         this.reuseConfigurationContext = reuse;
+        this.axis2ModuleRegistry = axis2ModuleRegistry;
     }
 
     public ConfigurationContext getClientConfigurationContext() {
@@ -59,6 +62,7 @@ public class Axis2ClientConfigurationFac
         ConfigurationContext context = this.contextCache.get(cl);
         if (context == null) {
             context = createConfigurationContext();
+            axis2ModuleRegistry.configureModules(context);
             this.contextCache.put(cl, context);
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Created new configuration context " + context + "  for " + cl);

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ConfigGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ConfigGBean.java?rev=1084159&r1=1084158&r2=1084159&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ConfigGBean.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/client/Axis2ConfigGBean.java
Tue Mar 22 13:10:17 2011
@@ -16,44 +16,49 @@
  */
 package org.apache.geronimo.axis2.client;
 
-import java.net.URL;
-
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.jaxws.ClientConfigurationFactory;
 import org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl;
 import org.apache.axis2.metadata.registry.MetadataFactoryRegistry;
+import org.apache.geronimo.axis2.osgi.Axis2ModuleRegistry;
 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.kernel.Kernel;
+import org.apache.geronimo.gbean.annotation.GBean;
+import org.apache.geronimo.gbean.annotation.ParamAttribute;
+import org.apache.geronimo.gbean.annotation.ParamReference;
+import org.apache.geronimo.gbean.annotation.ParamSpecial;
+import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+@GBean(name="Axis2ConfigGBean")
 public class Axis2ConfigGBean implements GBeanLifecycle {
 
     private final static Logger LOG = LoggerFactory.getLogger(Axis2ConfigGBean.class);
 
     private AbstractName moduleName;
     private ClassLoader classLoder;
+    private Axis2ModuleRegistry axis2ModuleRegistry;
 
-    public Axis2ConfigGBean(ClassLoader classLoader,
-                            Kernel kernel,
-                            URL configurationBaseUrl,
-                            AbstractName moduleName) {
+    public Axis2ConfigGBean(@ParamAttribute(name = "moduleName") AbstractName moduleName,
+                                                   @ParamReference(name = "axis2ModuleRegistry")
Axis2ModuleRegistry axis2ModuleRegistry,
+                                                   @ParamSpecial(type = SpecialAttributeType.classLoader)
ClassLoader classLoader) {
         this.moduleName = moduleName;
         this.classLoder = classLoader;
+        this.axis2ModuleRegistry = axis2ModuleRegistry;
     }
 
-    public synchronized static Axis2ClientConfigurationFactory registerClientConfigurationFactory()
{
+    public synchronized static Axis2ClientConfigurationFactory registerClientConfigurationFactory(Axis2ModuleRegistry
axis2ModuleRegistry) {
         ClientConfigurationFactory factory =
             (ClientConfigurationFactory)MetadataFactoryRegistry.getFactory(ClientConfigurationFactory.class);
         if (factory instanceof Axis2ClientConfigurationFactory) {
             return (Axis2ClientConfigurationFactory)factory;
         } else {
-            factory = new Axis2ClientConfigurationFactory(false);
+            factory = new Axis2ClientConfigurationFactory(axis2ModuleRegistry, false);
             MetadataFactoryRegistry.setFactory(ClientConfigurationFactory.class, factory);
-            LOG.debug("Registered client configuration factory: " + factory);
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Registered client configuration factory: " + factory);
+            }
             // ensure that the factory was installed at the right time
             if (factory != DescriptionFactoryImpl.getClientConfigurationFactory()) {
                 throw new RuntimeException("Client configuration factory was registered too
late");
@@ -63,35 +68,15 @@ public class Axis2ConfigGBean implements
     }
 
     public void doStart() throws Exception {
-        registerClientConfigurationFactory();
+        registerClientConfigurationFactory(axis2ModuleRegistry);
     }
 
     public void doStop() throws Exception {
         ConfigurationContext configContext =
-            registerClientConfigurationFactory().clearCache(this.classLoder);
+            registerClientConfigurationFactory(axis2ModuleRegistry).clearCache(this.classLoder);
         DescriptionFactoryImpl.clearServiceDescriptionCache(configContext);
     }
 
     public void doFail() {
     }
-
-    public static final GBeanInfo GBEAN_INFO;
-
-    static {
-        GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(Axis2ConfigGBean.class,
Axis2ConfigGBean.class, GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
-
-        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;
-    }
-
 }

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/osgi/Axis2ModuleRegistry.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/osgi/Axis2ModuleRegistry.java?rev=1084159&r1=1084158&r2=1084159&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/osgi/Axis2ModuleRegistry.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/osgi/Axis2ModuleRegistry.java
Tue Mar 22 13:10:17 2011
@@ -17,13 +17,25 @@
 
 package org.apache.geronimo.axis2.osgi;
 
+import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.deployment.DeploymentEngine;
+import org.apache.axis2.deployment.ModuleBuilder;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.description.Version;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.modules.Module;
+import org.apache.axis2.osgi.deployment.Registry;
+import org.apache.axis2.util.Utils;
 import org.apache.geronimo.gbean.GBeanLifecycle;
 import org.apache.geronimo.gbean.annotation.GBean;
 import org.apache.geronimo.gbean.annotation.OsgiService;
@@ -33,6 +45,8 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * @version $Rev$ $Date$
@@ -41,9 +55,11 @@ import org.osgi.framework.BundleListener
 @OsgiService
 public class Axis2ModuleRegistry implements BundleListener, GBeanLifecycle {
 
+    private static final Logger logger = LoggerFactory.getLogger(Axis2ModuleRegistry.class);
+
     private BundleContext bundleContext;
 
-    private final Map<Bundle, List<URL>> bundleModuleXmlURLsMap = new HashMap<Bundle,
List<URL>>();
+    private final Map<Bundle, List<URL>> bundleModuleXmlURLsMap = new ConcurrentHashMap<Bundle,
List<URL>>();
 
     public Axis2ModuleRegistry(@ParamSpecial(type = SpecialAttributeType.bundleContext) BundleContext
bundleContext) {
         this.bundleContext = bundleContext;
@@ -101,4 +117,57 @@ public class Axis2ModuleRegistry impleme
         bundleModuleXmlURLsMap.put(bundle, moduleXmls);
     }
 
+    public void configureModules(ConfigurationContext configurationContext) {
+        for (Map.Entry<Bundle, List<URL>> entry : bundleModuleXmlURLsMap.entrySet())
{
+            Bundle bundle = entry.getKey();
+            for (URL url : entry.getValue()) {
+                try {
+                    AxisModule axismodule = new AxisModule();
+                    ClassLoader loader = new org.apache.axis2.osgi.deployment.BundleClassLoader(bundle,
Registry.class.getClassLoader());
+                    axismodule.setModuleClassLoader(loader);
+                    AxisConfiguration axisConfig = configurationContext.getAxisConfiguration();
+                    ModuleBuilder builder = new ModuleBuilder(url.openStream(), axismodule,
axisConfig);
+                    Dictionary headers = bundle.getHeaders();
+                    String bundleSymbolicName = (String) headers.get("Bundle-SymbolicName");
+                    if (bundleSymbolicName != null && bundleSymbolicName.length()
!= 0) {
+                        axismodule.setName(bundleSymbolicName);
+                    }
+                    String bundleVersion = (String) headers.get("Bundle-Version");
+                    if (bundleVersion != null && bundleVersion.length() != 0) {
+                        /*
+                            Bundle version is defined as
+                            version ::=
+                                major( '.' minor ( '.' micro ( '.' qualifier )? )? )?
+                                major ::= number
+                                minor ::= number
+                                micro ::= number
+                                qualifier ::= ( alphanum | ’_’ | '-' )+
+                         */
+                        String[] versionSplit = bundleVersion.split("\\.");
+                        int[] components = new int[Math.min(versionSplit.length, 3)];
+                        for (int i = 0; i < components.length; i++) {
+                            components[i] = Integer.parseInt(versionSplit[i]);
+                        }
+                        axismodule.setVersion(new Version(components, versionSplit.length
> 3 ? versionSplit[3] : null));
+                    }
+                    builder.populateModule();
+                    axismodule.setParent(axisConfig);
+                    AxisModule module = axisConfig.getModule(axismodule.getName());
+                    if (module == null) {
+                        DeploymentEngine.addNewModule(axismodule, axisConfig);
+                        //initialze the module if the module contains Module interface.
+                        Module moduleObj = axismodule.getModule();
+                        if (moduleObj != null) {
+                            moduleObj.init(configurationContext, axismodule);
+                        }
+                    }
+                    // set in default map if necessary
+                    Utils.calculateDefaultModuleVersion(axisConfig.getModules(), axisConfig);
+                } catch (IOException e) {
+                    logger.error("Error while reading module.xml", e);
+                }
+            }
+        }
+    }
+
 }

Added: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/osgi/GeronimoBundleClassFinder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/osgi/GeronimoBundleClassFinder.java?rev=1084159&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/osgi/GeronimoBundleClassFinder.java
(added)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/osgi/GeronimoBundleClassFinder.java
Tue Mar 22 13:10:17 2011
@@ -0,0 +1,84 @@
+/**
+ *  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.osgi;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.axis2.jaxws.message.databinding.ClassFinder;
+import org.apache.xbean.osgi.bundle.util.BundleClassFinder;
+import org.apache.xbean.osgi.bundle.util.BundleClassLoader;
+import org.apache.xbean.osgi.bundle.util.ClassDiscoveryFilter;
+import org.apache.xbean.osgi.bundle.util.DiscoveryRange;
+import org.osgi.framework.Bundle;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class GeronimoBundleClassFinder implements ClassFinder {
+
+    private PackageAdmin packageAdmin;
+
+    public GeronimoBundleClassFinder(PackageAdmin packageAdmin) {
+        this.packageAdmin = packageAdmin;
+    }
+
+    @Override
+    public ArrayList<Class> getClassesFromJarFile(final String packageName, ClassLoader
cl) throws ClassNotFoundException {
+        if (!(cl instanceof BundleClassLoader)) {
+            return new ArrayList<Class>(0);
+        }
+        Bundle bundle = ((BundleClassLoader) cl).getBundle(true);
+        //TODO Do we need to limit the scanning scope in the target application ? As we share
one bundle for all the sub modules except for car
+        BundleClassFinder bundleClassFinder = new BundleClassFinder(packageAdmin, bundle,
new ClassDiscoveryFilter() {
+
+            @Override
+            public boolean directoryDiscoveryRequired(String directory) {
+                return true;
+            }
+
+            @Override
+            public boolean jarFileDiscoveryRequired(String jarFile) {
+                return true;
+            }
+
+            @Override
+            public boolean packageDiscoveryRequired(String p) {
+                return p.equals(packageName);
+            }
+
+            @Override
+            public boolean rangeDiscoveryRequired(DiscoveryRange discoveryRange) {
+                return discoveryRange == DiscoveryRange.BUNDLE_CLASSPATH;
+            }
+        });
+        Set<String> classNames = bundleClassFinder.find();
+        ArrayList<Class> clses = new ArrayList<Class>(classNames.size());
+        for (String className : classNames) {
+            clses.add(bundle.loadClass(className));
+        }
+        return clses;
+    }
+
+    //@Override
+    public void updateClassPath(String filePath, ClassLoader cl) throws Exception {
+    }
+
+}

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/osgi/GeronimoBundleClassFinder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/osgi/GeronimoBundleClassFinder.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/osgi/GeronimoBundleClassFinder.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java?rev=1084159&r1=1084158&r2=1084159&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
Tue Mar 22 13:10:17 2011
@@ -72,8 +72,6 @@ public class POJOWebServiceContainerFact
                      throws InstantiationException, IllegalAccessException, ClassNotFoundException
{
 
         if (componentContext != null) {
-
-            // The name should match WebServiceContextAnnotationHelper.RELATIVE_JNDI_NAME
             componentContext.put("comp/env/WebServiceContext", new WebServiceContextReference());
 
             GeronimoUserTransaction userTransaction = new GeronimoUserTransaction(transactionManager);

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/main/java/org/apache/geronimo/axis2/pojo/POJOWebServiceContainerFactoryGBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2Request.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2Request.java?rev=1084159&r1=1084158&r2=1084159&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2Request.java
(original)
+++ geronimo/server/trunk/plugins/axis2/geronimo-axis2/src/test/java/org/apache/geronimo/axis2/Axis2Request.java
Tue Mar 22 13:10:17 2011
@@ -44,7 +44,7 @@ class Axis2Request implements WebService
     private String remoteAddress;
 
     /**
-     * 
+     *
      */
     public Axis2Request(int contentLength, String contentType, InputStream in,
             int method, Map parameters, URI uri, Map headers,



Mime
View raw message