axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sami...@apache.org
Subject svn commit: r669633 - in /webservices/axis2/trunk/java/modules/osgi: resources/WEB-INF/ src/org/apache/axis2/extensions/osgi/ src/org/apache/axis2/osgi/deployment/
Date Thu, 19 Jun 2008 18:34:13 GMT
Author: saminda
Date: Thu Jun 19 11:34:12 2008
New Revision: 669633

URL: http://svn.apache.org/viewvc?rev=669633&view=rev
Log:
Added provision to register service. Cleanup the code. 

Added:
    webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiAxis2Constants.java
    webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServiceBuilder.java
    webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServiceGroupBuilder.java
    webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/ServiceRegistry.java
Removed:
    webservices/axis2/trunk/java/modules/osgi/resources/WEB-INF/
    webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/Activator.java
    webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/OSGiAxis2Servlet.java
    webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/ServiceRegistry.java
    webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/extensions/osgi/Version.java
Modified:
    webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/AbstractRegistry.java
    webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/ModuleRegistry.java
    webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java
    webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/Registry.java

Modified: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/AbstractRegistry.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/AbstractRegistry.java?rev=669633&r1=669632&r2=669633&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/AbstractRegistry.java
(original)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/AbstractRegistry.java
Thu Jun 19 11:34:12 2008
@@ -22,6 +22,8 @@
 import org.apache.axis2.context.ConfigurationContext;
 
 import java.util.Map;
+import java.util.List;
+import java.util.ArrayList;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
@@ -31,7 +33,9 @@
  */
 public abstract class AbstractRegistry<V> implements Registry {
 
-    protected Map<Bundle, V> bundleMap = new ConcurrentHashMap<Bundle, V>();
+    protected Map<Bundle, V> resolvedBundles = new ConcurrentHashMap<Bundle, V>();
+
+    protected List<Bundle> unreslovedBundles = new ArrayList<Bundle>();
 
     protected final Lock lock = new ReentrantLock();
 
@@ -61,8 +65,16 @@
                     break;
             }
         } catch (AxisFault e) {
+            //TODO: TDB use, log service error instead
+            e.printStackTrace();
             String msg = "Error while registering the bundle in AxisConfiguration";
             throw new RuntimeException(msg, e);
         }
     }
+
+    public void resolve() throws AxisFault {
+        for (Bundle bundle : unreslovedBundles) {
+            register(bundle);
+        }
+    }
 }

Modified: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/ModuleRegistry.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/ModuleRegistry.java?rev=669633&r1=669632&r2=669633&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/ModuleRegistry.java
(original)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/ModuleRegistry.java
Thu Jun 19 11:34:12 2008
@@ -27,6 +27,7 @@
 import java.io.IOException;
 import java.net.URL;
 import java.util.Enumeration;
+import java.util.Dictionary;
 
 /**
  * @see org.osgi.framework.BundleListener
@@ -34,15 +35,18 @@
  */
 public class ModuleRegistry extends AbstractRegistry<AxisModule> {
 
+    private Registry serviceRegistry;
 
-    public ModuleRegistry(BundleContext context, ConfigurationContext configCtx) {
+    public ModuleRegistry(BundleContext context, ConfigurationContext configCtx, Registry
serviceRegistry) {
         super(context, configCtx);
+        this.serviceRegistry = serviceRegistry;
     }
 
     public void register(Bundle bundle) throws AxisFault {
         lock.lock();
         try {
             addModules(bundle);
+            serviceRegistry.resolve();
         } finally {
             lock.unlock();
         }
@@ -52,9 +56,9 @@
     public void unRegister(Bundle bundle) throws AxisFault {
         lock.lock();
         try {
-            AxisModule module = bundleMap.get(bundle);
+            AxisModule module = resolvedBundles.get(bundle);
             if (module != null) {
-                bundleMap.remove(bundle);
+                resolvedBundles.remove(bundle);
                 configCtx.getAxisConfiguration()
                         .removeModule(module.getName(), module.getVersion());
                 System.out.println("[Axis2/OSGi] Stopping" + module.getName() + ":" +
@@ -67,13 +71,11 @@
     }
 
     private void addModules(Bundle bundle) throws AxisFault {
-        if (!bundleMap.containsKey(bundle)) {
+        if (!resolvedBundles.containsKey(bundle)) {
             try {
                 Enumeration enumeration = bundle.findEntries("META-INF", "module.xml", false);
                 while (enumeration != null && enumeration.hasMoreElements()) {
                     URL url = (URL) enumeration.nextElement();
-                    String urlString = url.toString();
-                    //                String shortFileName = urlString.substring(urlString.lastIndexOf('/'));
                     AxisModule axismodule = new AxisModule();
                     ClassLoader loader =
                             new BundleClassLoader(bundle, Registry.class.getClassLoader());
@@ -81,8 +83,12 @@
                     ModuleBuilder builder =
                             new ModuleBuilder(url.openStream(), axismodule,
                                               configCtx.getAxisConfiguration());
-                    //                axismodule.setName(org.apache.axis2.util.Utils.getModuleName(shortFileName));
-                    //                axismodule.setVersion(org.apache.axis2.util.Utils.getModuleVersion(shortFileName));
+                    Dictionary headers = bundle.getHeaders();
+                    String bundleSymbolicName = (String)headers.get("Bundle-SymbolicName");
+                    if (bundleSymbolicName != null && bundleSymbolicName.length()
!= 0) {
+                        axismodule.setName(bundleSymbolicName);
+                    }
+//                                    axismodule.setVersion(org.apache.axis2.util.Utils.getModuleVersion(shortFileName));
                     builder.populateModule();
                     axismodule.setParent(configCtx.getAxisConfiguration());
                     //                axismodule.setFileName(new URL(bundle.getLocation()));
@@ -96,7 +102,7 @@
                         if (moduleObj != null) {
                             moduleObj.init(configCtx, axismodule);
                         }
-                        bundleMap.put(bundle, axismodule);
+                        resolvedBundles.put(bundle, axismodule);
                         System.out.println("[Axis2/OSGi] Starting any modules in Bundle -
" +
                                            bundle.getSymbolicName());
                     } else {

Added: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiAxis2Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiAxis2Constants.java?rev=669633&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiAxis2Constants.java
(added)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiAxis2Constants.java
Thu Jun 19 11:34:12 2008
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.osgi.deployment;
+
+/**
+ *  Contains the list of constants
+ */
+public final class OSGiAxis2Constants {
+
+    public static String MODULE_NOT_FOUND_ERROR = "Error 1: Required module is not found";
+}

Modified: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java?rev=669633&r1=669632&r2=669633&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java
(original)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiConfigurationContextFactory.java
Thu Jun 19 11:34:12 2008
@@ -37,18 +37,27 @@
         // } then {
         //      // stat the bundle early
         // }
-        Registry moduleRegistry = new ModuleRegistry(context, configCtx);
+        Registry servicesRegistry = new ServiceRegistry(context, configCtx);
+        Registry moduleRegistry = new ModuleRegistry(context, configCtx, servicesRegistry);
         Bundle[] bundles = context.getBundles();
         if (bundles != null) {
             for (Bundle bundle : bundles) {
                 if (bundle != context.getBundle()) {
-                    moduleRegistry.register(bundle);
+                    if (bundle.getState() == Bundle.ACTIVE) {
+                        moduleRegistry.register(bundle);
+                    }
+                }
+            }
+            for (Bundle bundle : bundles) {
+                if (bundle != context.getBundle()) {
+                    if (bundle.getState() == Bundle.ACTIVE) {
+                        servicesRegistry.register(bundle);
+                    }
                 }
             }
         }
         context.addBundleListener(moduleRegistry);
-
-        //TODO: TBD, service listeners
+        context.addBundleListener(servicesRegistry);
 
         return configCtx;
 

Added: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServiceBuilder.java?rev=669633&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServiceBuilder.java
(added)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServiceBuilder.java
Thu Jun 19 11:34:12 2008
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.osgi.deployment;
+
+import org.apache.axis2.deployment.ServiceBuilder;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.deployment.DeploymentErrorMsgs;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.i18n.Messages;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAttribute;
+
+import static org.apache.axis2.osgi.deployment.OSGiAxis2Constants.MODULE_NOT_FOUND_ERROR;
+
+import javax.xml.namespace.QName;
+import java.io.InputStream;
+import java.util.Iterator;
+
+/**
+ * @see org.apache.axis2.deployment.ServiceBuilder
+ *      OSGiServiceBuilder builds AxisService from services.xml found
+ *      in a bundle. Builder would only success if the releationship between moduels and
services
+ *      would meet.
+ */
+public class OSGiServiceBuilder extends ServiceBuilder {
+
+    private AxisService service;
+
+    public OSGiServiceBuilder(ConfigurationContext configCtx, AxisService service) {
+        super(configCtx, service);
+        this.service = service;
+    }
+
+    public OSGiServiceBuilder(InputStream serviceInputStream, ConfigurationContext configCtx,
+                              AxisService service) {
+        super(serviceInputStream, configCtx, service);
+        this.service = service;
+    }
+
+    /**
+     * Gets the list of modules that is required to be engaged globally.
+     * If the required module is not found this will return the error code 1: which is
+     * "Error 1: Required module is not found"
+     *
+     * @param moduleRefs <code>java.util.Iterator</code>
+     * @throws org.apache.axis2.deployment.DeploymentException
+     *          <code>DeploymentException</code>
+     */
+    protected void processModuleRefs(Iterator moduleRefs)
+            throws DeploymentException {
+        while (moduleRefs.hasNext()) {
+            OMElement moduleref = (OMElement) moduleRefs.next();
+            OMAttribute moduleRefAttribute = moduleref
+                    .getAttribute(new QName(TAG_REFERENCE));
+
+            if (moduleRefAttribute != null) {
+                String refName = moduleRefAttribute.getAttributeValue();
+
+                if (axisConfig.getModule(refName) == null) {
+                    throw new DeploymentException(MODULE_NOT_FOUND_ERROR);
+                } else {
+                    service.addModuleref(refName);
+                }
+            }
+        }
+    }
+
+    /**
+     * If the required module is not found this will return the error code 1: which is
+     * "Error 1: Required module is not found"
+     *
+     * @param moduleRefs moduleRefs
+     * @param operation  operation
+     * @throws DeploymentException DeploymentException
+     */
+    protected void processOperationModuleRefs(Iterator moduleRefs,
+                                              AxisOperation operation) throws DeploymentException
{
+        while (moduleRefs.hasNext()) {
+            OMElement moduleref = (OMElement) moduleRefs.next();
+            OMAttribute moduleRefAttribute = moduleref
+                    .getAttribute(new QName(TAG_REFERENCE));
+
+            if (moduleRefAttribute != null) {
+                String refName = moduleRefAttribute.getAttributeValue();
+
+                if (axisConfig.getModule(refName) == null) {
+                    throw new DeploymentException(MODULE_NOT_FOUND_ERROR);
+                } else {
+                    operation.addModule(refName);
+                }
+            }
+        }
+    }
+
+
+}

Added: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServiceGroupBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServiceGroupBuilder.java?rev=669633&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServiceGroupBuilder.java
(added)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/OSGiServiceGroupBuilder.java
Thu Jun 19 11:34:12 2008
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.osgi.deployment;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.deployment.ServiceGroupBuilder;
+import org.apache.axis2.description.AxisServiceGroup;
+import static org.apache.axis2.osgi.deployment.OSGiAxis2Constants.MODULE_NOT_FOUND_ERROR;
+
+import javax.xml.namespace.QName;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * @see org.apache.axis2.deployment.ServiceGroupBuilder
+ *      OSGiServiceGroupBuilder builds AxisServiceGroup from services.xml found
+ *      in a bundle. Builder would only success if the releationship between moduels and
services
+ *      would meet.
+ */
+public class OSGiServiceGroupBuilder extends ServiceGroupBuilder {
+
+    public OSGiServiceGroupBuilder(OMElement service, HashMap wsdlServices,
+                                   ConfigurationContext configCtx) {
+        super(service, wsdlServices, configCtx);
+    }
+
+    /**
+     * Gets the list of modules that is required to be engaged globally.
+     * If the required module is not found this will return the error code 1: which is
+     * "Error 1: Required module is not found"
+     *
+     * @param moduleRefs <code>java.util.Iterator</code>
+     * @throws org.apache.axis2.deployment.DeploymentException
+     *          <code>DeploymentException</code>
+     */
+    protected void processModuleRefs(Iterator moduleRefs, AxisServiceGroup axisServiceGroup)
+            throws DeploymentException {
+        while (moduleRefs.hasNext()) {
+            OMElement moduleref = (OMElement) moduleRefs.next();
+            OMAttribute moduleRefAttribute = moduleref.getAttribute(new QName(TAG_REFERENCE));
+
+            if (moduleRefAttribute != null) {
+                String refName = moduleRefAttribute.getAttributeValue();
+
+                if (axisConfig.getModule(refName) == null) {
+                    throw new DeploymentException(MODULE_NOT_FOUND_ERROR);
+                } else {
+                    axisServiceGroup.addModuleref(refName);
+                }
+            }
+        }
+    }
+}

Modified: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/Registry.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/Registry.java?rev=669633&r1=669632&r2=669633&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/Registry.java
(original)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/Registry.java
Thu Jun 19 11:34:12 2008
@@ -28,4 +28,6 @@
     void register(Bundle bundle) throws AxisFault;
 
     void unRegister(Bundle bundle) throws AxisFault;
+
+    void resolve() throws AxisFault;
 }

Added: webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/ServiceRegistry.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/ServiceRegistry.java?rev=669633&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/ServiceRegistry.java
(added)
+++ webservices/axis2/trunk/java/modules/osgi/src/org/apache/axis2/osgi/deployment/ServiceRegistry.java
Thu Jun 19 11:34:12 2008
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * 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.osgi.deployment;
+
+import org.apache.axis2.description.AxisServiceGroup;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.deployment.*;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axiom.om.OMElement;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
+import javax.xml.stream.XMLStreamException;
+import java.util.*;
+import java.net.URL;
+import java.io.InputStream;
+import java.io.IOException;
+
+import static org.apache.axis2.osgi.deployment.OSGiAxis2Constants.MODULE_NOT_FOUND_ERROR;
+
+/**
+ * Creates proper AxisServiceGroup/AxisService looking into bundles
+ */
+public class ServiceRegistry extends AbstractRegistry<AxisServiceGroup> {
+
+    public ServiceRegistry(BundleContext context, ConfigurationContext configCtx) {
+        super(context, configCtx);
+    }
+
+    public void register(Bundle bundle) throws AxisFault {
+        lock.lock();
+        try {
+            addServices(bundle);
+        } finally {
+            lock.unlock();
+        }
+    }
+
+    private void addServices(Bundle bundle) throws AxisFault {
+        try {
+            Enumeration enumeration = bundle.findEntries("META-INF", "services.xml", false);
+            while (enumeration != null && enumeration.hasMoreElements()) {
+                URL url = (URL) enumeration.nextElement();
+                AxisServiceGroup serviceGroup =
+                        new AxisServiceGroup(configCtx.getAxisConfiguration());
+                serviceGroup.addParameter("last.updated", bundle.getLastModified());
+                ClassLoader loader =
+                        new BundleClassLoader(bundle, Registry.class.getClassLoader());
+                serviceGroup.setServiceGroupClassLoader(loader);
+                InputStream inputStream = url.openStream();
+                DescriptionBuilder builder = new DescriptionBuilder(inputStream, configCtx);
+                OMElement rootElement = builder.buildOM();
+                String elementName = rootElement.getLocalName();
+                Dictionary headers = bundle.getHeaders();
+                String bundleSymbolicName = (String) headers.get("Bundle-SymbolicName");
+                HashMap wsdlServicesMap = new HashMap();
+                if (DeploymentConstants.TAG_SERVICE.equals(elementName)) {
+                    AxisService axisService = new AxisService(bundleSymbolicName);
+                    axisService.setParent(serviceGroup);
+                    axisService.setClassLoader(loader);
+                    ServiceBuilder serviceBuilder = new ServiceBuilder(configCtx, axisService);
+                    serviceBuilder.setWsdlServiceMap(wsdlServicesMap);
+                    AxisService service = serviceBuilder.populateService(rootElement);
+                    configCtx.getAxisConfiguration().addService(service);
+                    //TODO: use OSGi log service from compendum.
+                    System.out.println("[Axis2/OSGi] Deployed axis2 service:" + service.getName()
+
+                                       " in Bundle: " +
+                                       bundle.getSymbolicName());
+                } else if (DeploymentConstants.TAG_SERVICE_GROUP.equals(elementName)) {
+                    ServiceGroupBuilder groupBuilder =
+                            new ServiceGroupBuilder(rootElement, wsdlServicesMap,
+                                                    configCtx);
+                    ArrayList serviceList = groupBuilder.populateServiceGroup(serviceGroup);
+                    DeploymentEngine.addServiceGroup(serviceGroup,
+                                                     serviceList,
+                                                     null,
+                                                     null,
+                                                     configCtx.getAxisConfiguration());
+                    System.out.println("[Axis2/OSGi] Deployed axis2 service group:" +
+                                       serviceGroup.getServiceGroupName() + " in Bundle:
" +
+                                       bundle.getSymbolicName());
+                }
+                resolvedBundles.put(bundle, serviceGroup);
+            }
+        } catch (Throwable e) {
+            //TODO: TBD log
+            String msg = "Error while reading from the bundle";
+            if (e instanceof DeploymentException) {
+                String message = e.getMessage();
+                if (message != null && message.length() != 0) {
+                    if (message.indexOf(MODULE_NOT_FOUND_ERROR) > -1) {
+                        if (!unreslovedBundles.contains(bundle)) {
+                            unreslovedBundles.add(bundle);
+                        }
+                    } else {
+                        throw new AxisFault(msg, e);
+                    }
+                } else {
+                    throw new AxisFault(msg, e);
+                }
+            } else {
+                throw new AxisFault(msg, e);
+            }
+        }
+    }
+
+    public void unRegister(Bundle bundle) throws AxisFault {
+        lock.lock();
+        try {
+            AxisServiceGroup axisServiceGroup = resolvedBundles.get(bundle);
+            if (axisServiceGroup != null) {
+                resolvedBundles.remove(bundle);
+                try {
+                    configCtx.getAxisConfiguration()
+                            .removeServiceGroup(axisServiceGroup.getServiceGroupName());
+                    System.out.println("[Axis2/OSGi] Stopping" +
+                                       axisServiceGroup.getServiceGroupName() +
+                                       " service group in Bundle - " +
+                                       bundle.getSymbolicName());
+                    for (Iterator iterator = axisServiceGroup.getServices(); iterator.hasNext();)
{
+                        AxisService service = (AxisService) iterator.next();
+                        System.out.println("[Axis2/OSGi]      Service - " + service.getName());
+                    }
+                } catch (AxisFault e) {
+                    String msg = "Error while removing the service group";
+                    throw new AxisFault(msg, e);
+                }
+            }
+        } finally {
+            lock.unlock();
+        }
+    }
+
+
+}



Mime
View raw message