geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: rev 54090 - geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis
Date Fri, 08 Oct 2004 15:15:56 GMT
Author: dims
Date: Fri Oct  8 08:15:55 2004
New Revision: 54090

Added:
   geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/DependancyManager.java
   geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/J2EEManager.java
   geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/WebServiceManager.java
Log:
Oops...Add missing files

Added: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/DependancyManager.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/DependancyManager.java	Fri
Oct  8 08:15:55 2004
@@ -0,0 +1,217 @@
+/*
+ * Copyright 2001-2004 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.geronimo.axis;
+
+import org.apache.axis.utils.ClassUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.deployment.DeploymentException;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.jmx.GBeanMBean;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.config.Configuration;
+import org.apache.geronimo.kernel.jmx.JMXUtil;
+import org.openejb.ContainerIndex;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Vector;
+
+/**
+ * Class DependancyEJBManager
+ */
+public class DependancyManager {
+    protected final Log log = LogFactory.getLog(getClass());
+    /**
+     * Field j2eeServerObjectName
+     */
+    private ObjectName j2eeServerObjectName;
+
+    /**
+     * Field j2eeDomainName
+     */
+    private static final String j2eeDomainName =
+            AxisGeronimoConstants.J2EE_DOMAIN_NAME;
+
+    /**
+     * Field j2eeServerName
+     */
+    private static final String j2eeServerName =
+            AxisGeronimoConstants.J2EE_SERVER_PREFIX;
+
+    /**
+     * Field transactionManagerObjectName
+     */
+    private static final ObjectName transactionManagerObjectName =
+            JMXUtil.getObjectName(j2eeDomainName + ":type=TransactionManager");
+
+    /**
+     * Field connectionTrackerObjectName
+     */
+    private static final ObjectName connectionTrackerObjectName =
+            JMXUtil.getObjectName(j2eeDomainName + ":type=ConnectionTracker");
+
+    /**
+     * Field containerIndexObjectName
+     */
+    private ObjectName containerIndexObjectName;
+
+    /**
+     * Field serverInfoObjectName
+     */
+    private ObjectName serverInfoObjectName;
+
+    /**
+     * Field configStore
+     */
+    private File configStore;
+
+    /**
+     * Field dependedEJBs
+     */
+    private static Vector dependedEJBs;
+
+    /**
+     * Field kernel
+     */
+    private final Kernel kernel;
+
+    /**
+     * Constructor DependancyEJBManager
+     *
+     * @param kernel
+     */
+    public DependancyManager(Kernel kernel) throws MalformedObjectNameException, DeploymentException
{
+        this.kernel = kernel;
+        configStore = new File(AxisGeronimoConstants.AXIS_CONFIG_STORE);
+        log.debug("configuration Store is " + configStore.getAbsolutePath());
+        dependedEJBs = new Vector();
+    }
+
+    /**
+     * Method stopDependancies
+     *
+     * @throws DeploymentException
+     */
+    public void stopDependancies() throws DeploymentException {
+        // stop strated ejbs
+        for (int i = 0; i < dependedEJBs.size(); i++) {
+            ObjectName gbeanName = (ObjectName) dependedEJBs.get(i);
+            AxisGeronimoUtils.stopGBean(gbeanName, kernel);
+            System.out.println("stop the dependent EJB name=" + gbeanName);
+            log.debug("stop the dependent EJB name=" + gbeanName);
+        }
+    }
+
+    /**
+     * Method startDependancy
+     *
+     * @param unpackedDir
+     * @param service
+     * @throws DeploymentException
+     */
+    public static ClassLoader startDependancy(File unpackedDir,
+                                              ObjectName service,
+                                              File configStore,
+                                              Kernel kernel)
+            throws DeploymentException {
+        try {
+            // load the configuration
+            GBeanMBean config = loadConfig(unpackedDir);
+            System.out.println("Context Loader " + Thread.currentThread().getContextClassLoader());
+            ObjectName objectName = service;
+
+            dependedEJBs.add(objectName);
+            kernel.loadGBean(objectName, config);
+            config.setAttribute("baseURL", unpackedDir.toURL());
+
+            // start the configuration
+            kernel.startRecursiveGBean(objectName);
+
+            ClassLoader cl = (ClassLoader) kernel.getAttribute(objectName, "classLoader");
+
+            System.out.println("start dependent EJB name=" + objectName
+                    + " dir=" + unpackedDir.getAbsolutePath() + "the config CL =" + cl);
+            return cl;
+        } catch (DeploymentException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new DeploymentException(e);
+        }
+    }
+
+    /**
+     * Method startContainerIndex
+     *
+     * @throws DeploymentException
+     * @throws MalformedObjectNameException
+     */
+    private void startContainerIndex()
+            throws DeploymentException, MalformedObjectNameException {
+        GBeanMBean containerIndexGBean =
+                new GBeanMBean(ContainerIndex.GBEAN_INFO);
+
+        containerIndexObjectName = ObjectName.getInstance(j2eeDomainName
+                + ":type=ContainerIndex");
+
+        Set ejbContainerNames = new HashSet();
+
+        ejbContainerNames.add(ObjectName.getInstance(j2eeDomainName
+                + ":j2eeType=StatelessSessionBean,*"));
+        ejbContainerNames.add(ObjectName.getInstance(j2eeDomainName
+                + ":j2eeType=StatefulSessionBean,*"));
+        ejbContainerNames.add(ObjectName.getInstance(j2eeDomainName
+                + ":j2eeType=EntityBean,*"));
+        containerIndexGBean.setReferencePatterns("EJBContainers",
+                ejbContainerNames);
+        AxisGeronimoUtils.startGBean(containerIndexObjectName,
+                containerIndexGBean, kernel);
+    }
+
+    /**
+     * Method loadConfig
+     *
+     * @param unpackedCar
+     * @return
+     * @throws Exception
+     */
+    private static GBeanMBean loadConfig(File unpackedCar) throws Exception {
+        InputStream in = new FileInputStream(new File(unpackedCar,
+                "META-INF/config.ser"));
+
+        try {
+            ObjectInputStream ois =
+                    new ObjectInputStream(new BufferedInputStream(in));
+            GBeanInfo gbeanInfo = Configuration.GBEAN_INFO;
+            GBeanMBean config = new GBeanMBean(gbeanInfo, ClassUtils.getDefaultClassLoader());
+            Configuration.loadGMBeanState(config, ois);
+            return config;
+        } finally {
+            in.close();
+        }
+    }
+
+    public static void addDependentEJB(ObjectName serviceName) {
+        dependedEJBs.add(serviceName);
+    }
+}

Added: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/J2EEManager.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/J2EEManager.java	Fri Oct
 8 08:15:55 2004
@@ -0,0 +1,230 @@
+/*
+ * Copyright 2001-2004 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.geronimo.axis;
+
+import org.apache.axis.AxisFault;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator;
+import org.apache.geronimo.gbean.jmx.GBeanMBean;
+import org.apache.geronimo.j2ee.management.impl.J2EEServerImpl;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.pool.ThreadPool;
+import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.geronimo.timer.vm.VMStoreThreadPooledNonTransactionalTimer;
+import org.apache.geronimo.timer.vm.VMStoreThreadPooledTransactionalTimer;
+import org.apache.geronimo.transaction.GeronimoTransactionManager;
+import org.apache.geronimo.transaction.context.TransactionContextManager;
+
+import javax.management.ObjectName;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+public class J2EEManager {
+    public static final Log log = LogFactory.getLog(J2EEManager.class);
+
+    public void init() throws AxisFault {
+    }
+
+    public void startJ2EEContainer(Kernel kernel) throws AxisFault {
+        try {
+            String str =
+                    System.getProperty(javax.naming.Context.URL_PKG_PREFIXES);
+            if (str == null) {
+                str = ":org.apache.geronimo.naming";
+            } else {
+                str = str + ":org.apache.geronimo.naming";
+            }
+
+            System.setProperty(javax.naming.Context.URL_PKG_PREFIXES, str);
+
+            setUpTransactionManager(kernel);
+            setUpTimer(kernel);
+
+            GBeanMBean serverInfoGBean = new GBeanMBean(ServerInfo.GBEAN_INFO);
+            serverInfoGBean.setAttribute("baseDirectory", ".");
+            AxisGeronimoUtils.startGBeanOnlyIfNotStarted(AxisGeronimoConstants.J2EE_SERVER_INFO,
serverInfoGBean, kernel);
+
+            GBeanMBean j2eeServerGBean = new GBeanMBean(J2EEServerImpl.GBEAN_INFO);
+            j2eeServerGBean.setReferencePatterns("ServerInfo", Collections.singleton(AxisGeronimoConstants.J2EE_SERVER_INFO));
+            AxisGeronimoUtils.startGBeanOnlyIfNotStarted(AxisGeronimoConstants.J2EE_SERVER_NAME,
j2eeServerGBean, kernel);
+                    
+
+            // //load mock resource adapter for mdb
+            // setUpResourceAdapter(kernel);
+            startEJBContainer(kernel);
+            startWebContainer(kernel);
+
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
+        }
+
+    }
+
+    public void stopJ2EEContainer(Kernel kernel) throws AxisFault {
+        try {
+            stopWebContainer(kernel);
+            stopEJBContainer(kernel);
+            stopTransactionManager(kernel);
+            stopTimer(kernel);
+            AxisGeronimoUtils.stopGBean(AxisGeronimoConstants.J2EE_SERVER_INFO, kernel);
+            AxisGeronimoUtils.stopGBean(AxisGeronimoConstants.J2EE_SERVER_NAME, kernel);
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
+        }
+
+    }
+
+    private void setUpTransactionManager(Kernel kernel) throws AxisFault {
+        try {
+            GBeanMBean tmGBean = new GBeanMBean(GeronimoTransactionManager.GBEAN_INFO);
+            Set rmpatterns = new HashSet();
+            rmpatterns.add(ObjectName.getInstance("geronimo.server:j2eeType=JCAManagedConnectionFactory,*"));
+            tmGBean.setReferencePatterns("ResourceManagers", rmpatterns);
+            AxisGeronimoUtils.startGBeanOnlyIfNotStarted(AxisGeronimoConstants.TRANSACTION_MANAGER_NAME,
tmGBean, kernel);
+
+            GBeanMBean tcmGBean = new GBeanMBean(TransactionContextManager.GBEAN_INFO);
+            tcmGBean.setReferencePattern("TransactionManager", AxisGeronimoConstants.TRANSACTION_MANAGER_NAME);
+            AxisGeronimoUtils.startGBeanOnlyIfNotStarted(AxisGeronimoConstants.TRANSACTION_CONTEXT_MANAGER_NAME,
tcmGBean, kernel);
+
+            GBeanMBean trackedConnectionAssociator = new GBeanMBean(ConnectionTrackingCoordinator.GBEAN_INFO);
+            AxisGeronimoUtils.startGBeanOnlyIfNotStarted(AxisGeronimoConstants.TRACKED_CONNECTION_ASSOCIATOR_NAME,
trackedConnectionAssociator, kernel);
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
+        }
+    }
+
+    private void stopTransactionManager(Kernel kernel) throws AxisFault {
+        try {
+            AxisGeronimoUtils.stopGBean(AxisGeronimoConstants.TRANSACTION_MANAGER_NAME, kernel);
+            AxisGeronimoUtils.stopGBean(AxisGeronimoConstants.TRANSACTION_CONTEXT_MANAGER_NAME,
kernel);
+            AxisGeronimoUtils.stopGBean(AxisGeronimoConstants.TRACKED_CONNECTION_ASSOCIATOR_NAME,
kernel);
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
+        }
+    }
+
+    public static void setUpTimer(Kernel kernel) throws Exception {
+        GBeanMBean threadPoolGBean = new GBeanMBean(ThreadPool.GBEAN_INFO);
+        threadPoolGBean.setAttribute("keepAliveTime", new Integer(5000));
+        threadPoolGBean.setAttribute("poolSize", new Integer(5));
+        threadPoolGBean.setAttribute("poolName", "DefaultThreadPool");
+        AxisGeronimoUtils.startGBeanOnlyIfNotStarted(AxisGeronimoConstants.THREADPOOL_NAME,
threadPoolGBean, kernel);
+
+        GBeanMBean transactionalTimerGBean = new GBeanMBean(VMStoreThreadPooledTransactionalTimer.GBEAN_INFO);
+        transactionalTimerGBean.setAttribute("repeatCount", new Integer(5));
+        transactionalTimerGBean.setReferencePattern("TransactionContextManager", AxisGeronimoConstants.TRANSACTION_CONTEXT_MANAGER_NAME);
+        transactionalTimerGBean.setReferencePattern("ThreadPool", AxisGeronimoConstants.THREADPOOL_NAME);
+        AxisGeronimoUtils.startGBeanOnlyIfNotStarted(AxisGeronimoConstants.TRANSACTIONAL_TIMER_NAME,
transactionalTimerGBean, kernel);
+
+        GBeanMBean nonTransactionalTimerGBean = new GBeanMBean(VMStoreThreadPooledNonTransactionalTimer.GBEAN_INFO);
+        nonTransactionalTimerGBean.setReferencePattern("ThreadPool", AxisGeronimoConstants.THREADPOOL_NAME);
+        AxisGeronimoUtils.startGBeanOnlyIfNotStarted(AxisGeronimoConstants.NONTRANSACTIONAL_TIMER_NAME,
nonTransactionalTimerGBean, kernel);
+    }
+
+    private void stopTimer(Kernel kernel) throws AxisFault {
+        try {
+            AxisGeronimoUtils.stopGBean(AxisGeronimoConstants.THREADPOOL_NAME, kernel);
+            AxisGeronimoUtils.stopGBean(AxisGeronimoConstants.TRANSACTIONAL_TIMER_NAME, kernel);
+            AxisGeronimoUtils.stopGBean(AxisGeronimoConstants.NONTRANSACTIONAL_TIMER_NAME,
kernel);
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
+        }
+    }
+
+//    public void setUpResourceAdapter(Kernel kernel) throws Exception {
+//        GBeanMBean geronimoWorkManagerGBean = new GBeanMBean(GeronimoWorkManager.getGBeanInfo());
+//        geronimoWorkManagerGBean.setAttribute("syncMaximumPoolSize", new Integer(5));
+//        geronimoWorkManagerGBean.setAttribute("startMaximumPoolSize", new Integer(5));
+//        geronimoWorkManagerGBean.setAttribute("scheduledMaximumPoolSize", new Integer(5));
+//        geronimoWorkManagerGBean.setReferencePattern("XAServices", AxisGeronimoConstants.TRANSACTION_MANAGER_NAME);
+//        AxisGeronimoUtils.startGBeanOnlyIfNotStarted(AxisGeronimoConstants.WORKMANAGER_NAME,
geronimoWorkManagerGBean,kernel);
+//
+//        GBeanMBean resourceAdapterGBean = new GBeanMBean(ResourceAdapterWrapper.getGBeanInfo());
+//        Map activationSpecInfoMap = new HashMap();
+////        ActivationSpecInfo activationSpecInfo = new ActivationSpecInfo(MockActivationSpec.class,
ActivationSpecWrapper.getGBeanInfo());
+////        activationSpecInfoMap.put(MockActivationSpec.class.getName(), activationSpecInfo);
+////        resourceAdapterGBean.setAttribute("resourceAdapterClass", MockResourceAdapter.class);
+////        resourceAdapterGBean.setAttribute("activationSpecInfoMap", activationSpecInfoMap);
+//        resourceAdapterGBean.setReferencePattern("WorkManager", AxisGeronimoConstants.WORKMANAGER_NAME);
+//        AxisGeronimoUtils.startGBeanOnlyIfNotStarted(AxisGeronimoConstants.RESOURCE_ADAPTER_NAME,
resourceAdapterGBean,kernel);
+//
+//        GBeanMBean activationSpecGBean = new GBeanMBean(ActivationSpecWrapper.getGBeanInfo());
+////        activationSpecGBean.setAttribute("activationSpecClass", MockActivationSpec.class);
+//        activationSpecGBean.setAttribute("containerId", AxisGeronimoConstants.CONTAINER_NAME.getCanonicalName());
+//        activationSpecGBean.setReferencePattern("ResourceAdapterWrapper", AxisGeronimoConstants.RESOURCE_ADAPTER_NAME);
+//        AxisGeronimoUtils.startGBeanOnlyIfNotStarted(AxisGeronimoConstants.ACTIVATIONSPEC_NAME,
activationSpecGBean,kernel);
+//    }
+//    
+//    private void stopResourceAdapter(Kernel kernel) throws AxisFault{
+//        try{
+//            AxisGeronimoUtils.stopGBean(AxisGeronimoConstants.WORKMANAGER_NAME, kernel);
+//            AxisGeronimoUtils.stopGBean(AxisGeronimoConstants.RESOURCE_ADAPTER_NAME, kernel);
+//            AxisGeronimoUtils.stopGBean(AxisGeronimoConstants.ACTIVATIONSPEC_NAME, kernel);
+//        }catch(Exception e){
+//            throw AxisFault.makeFault(e);
+//        }
+//    }
+
+    public void startWebContainer(Kernel kernel) throws Exception {
+        Set containerPatterns = Collections.singleton(AxisGeronimoConstants.WEB_CONTAINER_NAME);
+        GBeanMBean container = new GBeanMBean("org.apache.geronimo.jetty.JettyContainerImpl");
+        GBeanMBean connector = new GBeanMBean("org.apache.geronimo.jetty.connector.HTTPConnector");
+        connector.setAttribute("port", new Integer(AxisGeronimoConstants.AXIS_SERVICE_PORT));
+        connector.setReferencePatterns("JettyContainer", containerPatterns);
+
+        AxisGeronimoUtils.startGBeanOnlyIfNotStarted(AxisGeronimoConstants.WEB_CONTAINER_NAME,
container, kernel);
+        AxisGeronimoUtils.startGBeanOnlyIfNotStarted(AxisGeronimoConstants.WEB_CONNECTOR_NAME,
connector, kernel);
+    }
+
+    private void stopWebContainer(Kernel kernel) throws AxisFault {
+        try {
+            AxisGeronimoUtils.stopGBean(AxisGeronimoConstants.WEB_CONNECTOR_NAME, kernel);
+            AxisGeronimoUtils.stopGBean(AxisGeronimoConstants.WEB_CONTAINER_NAME, kernel);
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
+        }
+    }
+
+    public void startEJBContainer(Kernel kernel) throws Exception {
+        GBeanMBean containerIndexGBean = new GBeanMBean("org.openejb.ContainerIndex");
+
+        Set ejbContainerNames = new HashSet();
+
+        ejbContainerNames.add(ObjectName.getInstance(AxisGeronimoConstants.J2EE_DOMAIN_NAME
+                + ":j2eeType=StatelessSessionBean,*"));
+        ejbContainerNames.add(ObjectName.getInstance(AxisGeronimoConstants.J2EE_DOMAIN_NAME
+                + ":j2eeType=StatefulSessionBean,*"));
+        ejbContainerNames.add(ObjectName.getInstance(AxisGeronimoConstants.J2EE_DOMAIN_NAME
+                + ":j2eeType=EntityBean,*"));
+        containerIndexGBean.setReferencePatterns("EJBContainers",
+                ejbContainerNames);
+
+        AxisGeronimoUtils.startGBeanOnlyIfNotStarted(AxisGeronimoConstants.EJB_CONTAINER_NAME,
+                containerIndexGBean, kernel);
+    }
+
+    private void stopEJBContainer(Kernel kernel) throws AxisFault {
+        try {
+            AxisGeronimoUtils.stopGBean(AxisGeronimoConstants.EJB_CONTAINER_NAME, kernel);
+        } catch (Exception e) {
+            throw AxisFault.makeFault(e);
+        }
+    }
+
+}

Added: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/WebServiceManager.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/WebServiceManager.java	Fri
Oct  8 08:15:55 2004
@@ -0,0 +1,215 @@
+/*
+ * Copyright 2001-2004 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.geronimo.axis;
+
+import org.apache.axis.utils.ClassUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.deployment.DeploymentException;
+import org.apache.geronimo.gbean.jmx.GBeanMBean;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.transaction.UserTransactionImpl;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import java.io.File;
+import java.io.FileInputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Properties;
+import java.util.Set;
+import java.util.zip.ZipFile;
+
+/**
+ * Class WebServiceContainer
+ */
+public class WebServiceManager {
+    protected final Log log = LogFactory.getLog(getClass());
+    /**
+     * Field kernel
+     */
+    private final Kernel kernel;
+
+    /**
+     * Field containerName
+     */
+    private ObjectName containerName;
+
+    /**
+     * Field mbServer
+     */
+    private MBeanServer mbServer;
+
+    /**
+     * Field containerPatterns
+     */
+    private Set containerPatterns;
+
+    /**
+     * Field appName
+     */
+    private ObjectName appName;
+
+    /**
+     * Field ejbManager
+     */
+    private DependancyManager ejbManager;
+
+    /**
+     * Constructor WebServiceContainer
+     *
+     * @param kernel
+     */
+    public WebServiceManager(Kernel kernel) {
+        this.kernel = kernel;
+        mbServer = kernel.getMBeanServer();
+
+        containerName = AxisGeronimoConstants.WEB_CONTAINER_NAME;
+        containerPatterns = Collections.singleton(containerName);
+        appName = AxisGeronimoConstants.APPLICATION_NAME;
+    }
+
+    /**
+     * Method init
+     */
+    public void init() {
+    }
+
+    /**
+     * Method doStart
+     *
+     * @throws Exception
+     */
+    public void doStart() throws Exception {
+        ejbManager = new DependancyManager(kernel);
+        //This code is taken from the org.apache.geronimo.jetty.ApplicationTest in the 
+        //jetty module tests .. If something is not working we got to test wheather the 
+        //test has changed
+        ClassUtils.setDefaultClassLoader(Thread.currentThread().getContextClassLoader());
+        loadDeployedWebservices();
+
+        GBeanMBean app = new GBeanMBean("org.apache.geronimo.jetty.JettyWebAppContext");
+        URL url =
+                Thread.currentThread().getContextClassLoader().getResource("deployables/axis/");
+
+        app.setAttribute("uri", URI.create(url.toString()));
+        app.setAttribute("contextPath", "/axis");
+        app.setAttribute("componentContext", null);
+        UserTransactionImpl userTransaction = new UserTransactionImpl();
+        app.setAttribute("userTransaction", userTransaction);
+        app.setReferencePatterns("Configuration", Collections.EMPTY_SET);
+        app.setReferencePatterns("JettyContainer", containerPatterns);
+        app.setReferencePattern("TransactionContextManager", AxisGeronimoConstants.TRANSACTION_CONTEXT_MANAGER_NAME);
+        app.setReferencePattern("TrackedConnectionAssociator", AxisGeronimoConstants.TRACKED_CONNECTION_ASSOCIATOR_NAME);
+
+        start(appName, app);
+        log.debug("Axis started as a web application inside Jetty");
+    }
+
+    /**
+     * Method doStop
+     *
+     * @throws Exception
+     */
+    public void doStop() throws Exception {
+        ejbManager.stopDependancies();
+    }
+
+    /**
+     * Method start
+     *
+     * @param name
+     * @param instance
+     * @throws Exception
+     */
+    private void start(ObjectName name, Object instance) throws Exception {
+        mbServer.registerMBean(instance, name);
+        mbServer.invoke(name, "start", null, null);
+    }
+
+    /**
+     * Method stop
+     *
+     * @param name
+     * @throws Exception
+     */
+    private void stop(ObjectName name) throws Exception {
+        mbServer.invoke(name, "stop", null, null);
+        mbServer.unregisterMBean(name);
+    }
+
+    /**
+     * Method loadDeployedWebservices
+     *
+     * @throws MalformedURLException
+     */
+    public void loadDeployedWebservices()
+            throws MalformedURLException, DeploymentException {
+        try {
+            File configStroe = new File(AxisGeronimoConstants.AXIS_CONFIG_STORE);
+            File[] apps = configStroe.listFiles();
+            ClassLoader classloader;
+            if (apps != null) {
+                for (int i = 0; i < apps.length; i++) {
+                    File f = new File(apps[i], "axis.properties");
+                    if (f.exists()) {
+                        Properties p = new Properties();
+                        FileInputStream in = new FileInputStream(f);
+                        p.load(in);
+                        in.close();  
+                        //that mean this a Web Service
+                        String dir = f.getName();
+                        String serviceName = (String) p.get(dir);
+                        String style = (String) p.get("style");
+                        File module = null;
+
+                        File[] jars = f.listFiles();
+                        if (jars != null) {
+                            for (int j = 0; j < jars.length; j++) {
+                                if (jars[i].getAbsolutePath().endsWith(".jar")) {
+                                    module = jars[i];
+                                    log.debug("found a jar" + jars[i].getAbsolutePath());
+                                    break;
+                                }
+                            }
+                        }
+
+                        if ("ejb".equals(style)) {
+                            ObjectName serviceobjectName = ObjectName.getInstance("test:configuration="
+                                    + serviceName);
+                            classloader = DependancyManager.startDependancy(apps[i], serviceobjectName,
configStroe, kernel);
+                        } else {
+                            classloader = new URLClassLoader(new URL[]{module.toURL()});
+                        }
+
+                        ArrayList classList = AxisGeronimoUtils.getClassFileList(new ZipFile(module));
+                        for (int j = 0; j < classList.size(); j++) {
+                            String className = (String) classList.get(i);
+                            System.out.println(className);
+                            ClassUtils.setClassLoader(className, classloader);
+                        }
+                    }
+                }
+            }
+        } catch (Exception e) {
+            throw new DeploymentException(e);
+        }
+    }
+}

Mime
View raw message