[jboss-cvs] JBossAS SVN: r93656 - in projects/jboss-jca/trunk: fungal/src/main/java/org/jboss/jca/fungal/api and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 17 14:23:34 EDT 2009


Author: jesper.pedersen
Date: 2009-09-17 14:23:34 -0400 (Thu, 17 Sep 2009)
New Revision: 93656

Added:
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/BeanDeployment.java
Modified:
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/Kernel.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/Deployment.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/DeploymentDeployer.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java
   projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/MainDeployer.java
   projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/Main.java
Log:
[JBJCA-166] undeploy() with some caveats

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java	2009-09-17 18:04:37 UTC (rev 93655)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java	2009-09-17 18:23:34 UTC (rev 93656)
@@ -275,7 +275,7 @@
          
          // Activate deployment
 
-         return new RADeployment(f, cl);
+         return new RADeployment(url, cl);
       }
       catch (Throwable t)
       {

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java	2009-09-17 18:04:37 UTC (rev 93655)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployment.java	2009-09-17 18:23:34 UTC (rev 93656)
@@ -25,8 +25,8 @@
 import org.jboss.jca.fungal.deployers.Deployment;
 
 import java.io.Closeable;
-import java.io.File;
 import java.io.IOException;
+import java.net.URL;
 
 import org.jboss.logging.Logger;
 
@@ -40,7 +40,7 @@
    private static boolean trace = log.isTraceEnabled();
 
    /** The resource adapter file */
-   private File adapter;
+   private URL adapter;
 
    /** The classloader */
    private ClassLoader cl;
@@ -50,19 +50,19 @@
     * @param adapter The adapter
     * @param cl The classloader for the deployment
     */
-   public RADeployment(File adapter, ClassLoader cl)
+   public RADeployment(URL adapter, ClassLoader cl)
    {
       this.adapter = adapter;
       this.cl = cl;
    }
 
    /**
-    * Get the name
-    * @return The name
+    * Get the unique URL for the deployment
+    * @return The URL
     */
-   public String getName()
+   public URL getURL()
    {
-      return adapter.getName();
+      return adapter;
    }
 
    /**
@@ -79,7 +79,7 @@
     */
    public void destroy()
    {
-      log.info("Undeploying: " + adapter.getAbsolutePath());
+      log.info("Undeploying: " + adapter.toExternalForm());
 
       if (cl != null && cl instanceof Closeable)
       {

Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/Kernel.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/Kernel.java	2009-09-17 18:04:37 UTC (rev 93655)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/api/Kernel.java	2009-09-17 18:23:34 UTC (rev 93656)
@@ -38,11 +38,13 @@
 
    /**
     * Startup
+    * @exception Throwable Thrown if an error occurs
     */
-   public void startup();
+   public void startup() throws Throwable;
 
    /**
     * Shutdown
+    * @exception Throwable Thrown if an error occurs
     */
-   public void shutdown();
+   public void shutdown() throws Throwable;
 }

Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/Deployment.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/Deployment.java	2009-09-17 18:04:37 UTC (rev 93655)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/deployers/Deployment.java	2009-09-17 18:23:34 UTC (rev 93656)
@@ -22,6 +22,8 @@
 
 package org.jboss.jca.fungal.deployers;
 
+import java.net.URL;
+
 /**
  * The deployment interface for JCA/Fungal
  * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
@@ -29,10 +31,10 @@
 public interface Deployment
 {
    /**
-    * Get the name
-    * @return The name
+    * Get the unique URL for the deployment
+    * @return The URL
     */
-   public String getName();
+   public URL getURL();
 
    /**
     * Get the classloader

Added: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/BeanDeployment.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/BeanDeployment.java	                        (rev 0)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/BeanDeployment.java	2009-09-17 18:23:34 UTC (rev 93656)
@@ -0,0 +1,123 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.fungal.impl;
+
+import org.jboss.jca.fungal.deployers.Deployment;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * A bean deployment for JCA/Fungal
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class BeanDeployment implements Deployment
+{
+   /** The deployment */
+   private URL deployment;
+
+   /** The bean names */
+   private List<String> beans;
+
+   /** The kernel */
+   private KernelImpl kernel;
+
+   /**
+    * Constructor
+    * @param deployment The deployment
+    * @param beans The list of bean names for the deployment
+    * @param kernel The kernel
+    */
+   public BeanDeployment(URL deployment, List<String> beans, KernelImpl kernel)
+   {
+      this.deployment = deployment;
+      this.beans = beans;
+      this.kernel = kernel;
+   }
+
+   /**
+    * Get the unique URL for the deployment
+    * @return The URL
+    */
+   public URL getURL()
+   {
+      return deployment;
+   }
+
+   /**
+    * Get the classloader
+    * @return The classloader
+    */
+   public ClassLoader getClassLoader()
+   {
+      return null;
+   }
+
+   /**
+    * Stop
+    */
+   public void stop()
+   {
+      List<String> shutdownBeans = new LinkedList<String>(beans);
+      Collections.reverse(shutdownBeans);
+
+      for (String name : shutdownBeans)
+      {
+         kernel.setBeanStatus(name, ServiceLifecycle.STOPPING);
+
+         Object bean = kernel.getBean(name);
+
+         try
+         {
+            Method stopMethod = bean.getClass().getMethod("stop", (Class[])null);
+            stopMethod.invoke(bean, (Object[])null);
+         }
+         catch (Exception e)
+         {
+            // No stop method
+         }
+
+         try
+         {
+            Method destroyMethod = bean.getClass().getMethod("destroy", (Class[])null);
+            destroyMethod.invoke(bean, (Object[])null);
+         }
+         catch (Exception e)
+         {
+            // No destroy method
+         }
+
+         kernel.removeBean(name);
+      }
+   }
+
+   /**
+    * Destroy
+    */
+   public void destroy()
+   {
+   }
+}

Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/DeploymentDeployer.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/DeploymentDeployer.java	2009-09-17 18:04:37 UTC (rev 93655)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/DeploymentDeployer.java	2009-09-17 18:23:34 UTC (rev 93656)
@@ -87,6 +87,8 @@
       if (url == null || !url.toString().endsWith(".xml"))
          return null;
 
+      List<String> beans = new ArrayList<String>(1);
+
       try
       {
          JAXBContext deploymentJc = JAXBContext.newInstance("org.jboss.jca.fungal.deployment");
@@ -100,7 +102,7 @@
 
             for (BeanType bt : deployment.getBean())
             {
-               Runnable r = new ServiceRunnable(bt, kernel, beansLatch, parent);
+               Runnable r = new ServiceRunnable(bt, beans, kernel, beansLatch, parent);
                kernel.getExecutorService().execute(r);
             }
 
@@ -112,7 +114,7 @@
          error(t.getMessage(), t);
       }
 
-      return null;
+      return new BeanDeployment(url, beans, kernel);
    }
 
    /**
@@ -123,6 +125,9 @@
       /** The bean */
       private BeanType bt;
 
+      /** The bean names */
+      private List<String> beans;
+
       /** The kernel */
       private KernelImpl kernel;
 
@@ -135,13 +140,19 @@
       /**
        * Constructor
        * @param bt The bean
+       * @param beans The list of bean names
        * @param kernel The kernel
        * @param beansLatch The beans latch
        * @param classLoader The class loader
        */
-      public ServiceRunnable(BeanType bt, KernelImpl kernel, CountDownLatch beansLatch, ClassLoader classLoader)
+      public ServiceRunnable(BeanType bt, 
+                             List<String> beans,
+                             KernelImpl kernel,
+                             CountDownLatch beansLatch,
+                             ClassLoader classLoader)
       {
          this.bt = bt;
+         this.beans = beans;
          this.kernel = kernel;
          this.beansLatch = beansLatch;
          this.classLoader = classLoader;
@@ -181,6 +192,7 @@
                Object bean = createBean(bt, classLoader);
 
                kernel.addBean(bt.getName(), bean);
+               beans.add(bt.getName());
 
                kernel.setBeanStatus(bt.getName(), ServiceLifecycle.STARTED);
             }

Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java	2009-09-17 18:04:37 UTC (rev 93655)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/KernelImpl.java	2009-09-17 18:23:34 UTC (rev 93656)
@@ -109,137 +109,108 @@
 
    /**
     * Startup
+    * @exception Throwable Thrown if an error occurs
     */
-   public void startup()
+   public void startup() throws Throwable
    {
-      try
-      {
-         ThreadGroup tg = kernelConfiguration.getThreadGroup();
-         if (tg == null)
-            tg = new ThreadGroup("jboss");
-         ThreadFactory tf = new FungalThreadFactory(tg);
-         executorService = Executors.newCachedThreadPool(tf);
+      ThreadGroup tg = kernelConfiguration.getThreadGroup();
+      if (tg == null)
+         tg = new ThreadGroup("jboss");
+      ThreadFactory tf = new FungalThreadFactory(tg);
+      executorService = Executors.newCachedThreadPool(tf);
 
-         File root = null;
+      File root = null;
 
-         if (kernelConfiguration.getHome() != null)
+      if (kernelConfiguration.getHome() != null)
+      {
+         root = new File(kernelConfiguration.getHome().toURI());
+         SecurityActions.setSystemProperty("jboss.jca.home", root.getAbsolutePath());
+      }
+      else
+      {
+         File tmp = new File(SecurityActions.getSystemProperty("java.io.tmpdir"));
+         root = new File(tmp, "jboss-jca");
+
+         if (root.exists())
          {
-            root = new File(kernelConfiguration.getHome().toURI());
-            SecurityActions.setSystemProperty("jboss.jca.home", root.getAbsolutePath());
+            recursiveDelete(root);
          }
-         else
-         {
-            File tmp = new File(SecurityActions.getSystemProperty("java.io.tmpdir"));
-            root = new File(tmp, "jboss-jca");
 
-            if (root.exists())
-            {
-               try
-               {
-                  recursiveDelete(root);
-               }
-               catch (Throwable t)
-               {
-                  // TODO
-                  error(t.getMessage(), t);
-               }
-            }
+         if (!root.mkdirs())
+            throw new IOException("Could not create directory " + root.getAbsolutePath());
 
-            if (!root.mkdirs())
-               throw new IOException("Could not create directory " + root.getAbsolutePath());
+         SecurityActions.setSystemProperty("jboss.jca.home", root.getAbsolutePath());
+         
+         temporaryEnvironment = true;
+      }
 
-            SecurityActions.setSystemProperty("jboss.jca.home", root.getAbsolutePath());
+      File libDirectory = null;
+      File configDirectory = null;
+      File deployDirectory = null;
 
-            temporaryEnvironment = true;
-         }
+      if (root != null && root.exists())
+      {
+         libDirectory = new File(root, "/lib/");
+         configDirectory = new File(root, "/config/");
+         deployDirectory = new File(root, "/deploy/");
+      }
 
-         File libDirectory = null;
-         File configDirectory = null;
-         File deployDirectory = null;
+      oldClassLoader = SecurityActions.getThreadContextClassLoader();
 
-         if (root != null)
-         {
-            libDirectory = new File(root, "/lib/");
-            configDirectory = new File(root, "/config/");
-            deployDirectory = new File(root, "/deploy/");
-         }
+      URL[] libUrls = getUrls(libDirectory);
+      URL[] confUrls = getUrls(configDirectory);
 
-         oldClassLoader = SecurityActions.getThreadContextClassLoader();
+      URL[] urls = mergeUrls(libUrls, confUrls);
 
-         URL[] libUrls = getUrls(libDirectory);
-         URL[] confUrls = getUrls(configDirectory);
+      kernelClassLoader = SecurityActions.createKernelClassLoader(urls, oldClassLoader);
+      SecurityActions.setThreadContextClassLoader(kernelClassLoader);
 
-         URL[] urls = mergeUrls(libUrls, confUrls);
+      SecurityActions.setSystemProperty("xb.builder.useUnorderedSequence", "true");
+      SecurityActions.setSystemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
 
-         kernelClassLoader = SecurityActions.createKernelClassLoader(urls, oldClassLoader);
-         SecurityActions.setThreadContextClassLoader(kernelClassLoader);
+      if (kernelConfiguration.getBindAddress() != null)
+         SecurityActions.setSystemProperty("jboss.jca.bindaddress", kernelConfiguration.getBindAddress().trim());
 
-         SecurityActions.setSystemProperty("xb.builder.useUnorderedSequence", "true");
-         SecurityActions.setSystemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager");
+      // Init logging
+      initLogging(kernelClassLoader);
 
-         if (kernelConfiguration.getBindAddress() != null)
-            SecurityActions.setSystemProperty("jboss.jca.bindaddress", kernelConfiguration.getBindAddress().trim());
+      // Create MBeanServer
+      mbeanServer = MBeanServerFactory.createMBeanServer("jboss.jca");
 
-         // Init logging
-         initLogging(kernelClassLoader);
+      // Main deployer
+      mainDeployer = new MainDeployer(this);
+      ObjectName mainDeployerObjectName = new ObjectName("jboss.jca:name=MainDeployer");
+      mbeanServer.registerMBean(mainDeployer, mainDeployerObjectName);
 
-         // Create MBeanServer
-         mbeanServer = MBeanServerFactory.createMBeanServer("jboss.jca");
+      // Add the deployment deployer
+      mainDeployer.addDeployer(new DeploymentDeployer(this));
 
-         // Main deployer
-         mainDeployer = new MainDeployer(this);
-         ObjectName mainDeployerObjectName = new ObjectName("jboss.jca:name=MainDeployer");
-         mbeanServer.registerMBean(mainDeployer, mainDeployerObjectName);
+      // Add the kernel bean reference
+      addBean("Kernel", this);
+      setBeanStatus("Kernel", ServiceLifecycle.STARTED);
 
-         // Add the deployment deployer
-         mainDeployer.addDeployer(new DeploymentDeployer(this));
+      // Start all URLs defined in bootstrap.xml
+      if (configDirectory != null && configDirectory.exists() && configDirectory.isDirectory())
+      {
+         File bootXml = new File(configDirectory, "bootstrap.xml");
+         JAXBContext bootJc = JAXBContext.newInstance("org.jboss.jca.fungal.bootstrap");
+         Unmarshaller bootU = bootJc.createUnmarshaller();
+         org.jboss.jca.fungal.bootstrap.Bootstrap boot = 
+            (org.jboss.jca.fungal.bootstrap.Bootstrap)bootU.unmarshal(bootXml);
 
-         // Add the kernel bean reference
-         addBean("Kernel", this);
-         setBeanStatus("Kernel", ServiceLifecycle.STARTED);
-
-         // Start all URLs defined in bootstrap.xml
-         if (configDirectory != null && configDirectory.exists() && configDirectory.isDirectory())
+         // Boot urls
+         if (boot != null)
          {
-            File bootXml = new File(configDirectory, "bootstrap.xml");
-            JAXBContext bootJc = JAXBContext.newInstance("org.jboss.jca.fungal.bootstrap");
-            Unmarshaller bootU = bootJc.createUnmarshaller();
-            org.jboss.jca.fungal.bootstrap.Bootstrap boot = 
-               (org.jboss.jca.fungal.bootstrap.Bootstrap)bootU.unmarshal(bootXml);
-
-            // Boot urls
-            if (boot != null)
+            for (String url : boot.getUrl())
             {
-               for (String url : boot.getUrl())
-               {
-                  try
-                  {
-                     URL fullPath = new URL(configDirectory.toURI().toURL().toExternalForm() + url);
-
-                     if (isDebugEnabled())
-                        debug("URL=" + fullPath.toString());
-
-                     mainDeployer.deploy(fullPath, kernelClassLoader);
-                  }
-                  catch (Throwable deployThrowable)
-                  {
-                     error(deployThrowable.getMessage(), deployThrowable);
-                  }
-               }
-            }
-         }
-
-         // Deploy all files in deploy/
-         if (deployDirectory != null && deployDirectory.exists() && deployDirectory.isDirectory())
-         {
-            for (File f : deployDirectory.listFiles())
-            {
                try
                {
+                  URL fullPath = new URL(configDirectory.toURI().toURL().toExternalForm() + url);
+
                   if (isDebugEnabled())
-                     debug("URL=" + f.toURI().toURL().toExternalForm());
+                     debug("URL=" + fullPath.toString());
 
-                  mainDeployer.deploy(f.toURI().toURL(), kernelClassLoader);
+                  mainDeployer.deploy(fullPath, kernelClassLoader);
                }
                catch (Throwable deployThrowable)
                {
@@ -248,100 +219,65 @@
             }
          }
       }
-      catch (Throwable t)
+
+      // Deploy all files in deploy/
+      if (deployDirectory != null && deployDirectory.exists() && deployDirectory.isDirectory())
       {
-         error(t.getMessage(), t);
+         for (File f : deployDirectory.listFiles())
+         {
+            try
+            {
+               if (isDebugEnabled())
+                  debug("URL=" + f.toURI().toURL().toExternalForm());
+
+               mainDeployer.deploy(f.toURI().toURL(), kernelClassLoader);
+            }
+            catch (Throwable deployThrowable)
+            {
+               error(deployThrowable.getMessage(), deployThrowable);
+            }
+         }
       }
    }
 
    /**
     * Shutdown
+    * @exception Throwable Thrown if an error occurs
     */
-   public void shutdown()
+   public void shutdown() throws Throwable
    {
       SecurityActions.setThreadContextClassLoader(kernelClassLoader);
 
+      // Shutdown thread pool
       executorService.shutdown();
 
+      // Shutdown all deployments
       List<Deployment> shutdownDeployments = new LinkedList<Deployment>(deployments);
       Collections.reverse(shutdownDeployments);
 
       for (Deployment deployment : shutdownDeployments)
       {
-         try
-         {
-            Method stopMethod = deployment.getClass().getMethod("stop", (Class[])null);
-            stopMethod.invoke(deployment, (Object[])null);
-         }
-         catch (Exception e)
-         {
-            // No stop method
-         }
-
-         try
-         {
-            Method destroyMethod = deployment.getClass().getMethod("destroy", (Class[])null);
-            destroyMethod.invoke(deployment, (Object[])null);
-         }
-         catch (Exception e)
-         {
-            // No destroy method
-         }
+         shutdownDeployment(deployment);
       }
 
-      List<String> shutdownServices = new LinkedList<String>(startup);
-      Collections.reverse(shutdownServices);
+      // Remove kernel bean
+      removeBean("Kernel");
 
-      for (String name : shutdownServices)
-      {
-         setBeanStatus(name, ServiceLifecycle.STOPPING);
-
-         Object service = services.get(name);
-
-         try
-         {
-            Method stopMethod = service.getClass().getMethod("stop", (Class[])null);
-            stopMethod.invoke(service, (Object[])null);
-         }
-         catch (Exception e)
-         {
-            // No stop method
-         }
-
-         try
-         {
-            Method destroyMethod = service.getClass().getMethod("destroy", (Class[])null);
-            destroyMethod.invoke(service, (Object[])null);
-         }
-         catch (Exception e)
-         {
-            // No destroy method
-         }
-
-         setBeanStatus(name, ServiceLifecycle.NOT_STARTED);
-      }
-
       // Release MBeanServer
       MBeanServerFactory.releaseMBeanServer(mbeanServer);
 
       info("Shutdown complete");
 
+      // Cleanup temporary environment
       if (temporaryEnvironment)
       {
          File tmp = new File(SecurityActions.getSystemProperty("java.io.tmpdir"));
          File root = new File(tmp, "jboss-jca");
 
-         try
-         {
-            recursiveDelete(root);
-         }
-         catch (Throwable t)
-         {
-            // TODO
-            error(t.getMessage(), t);
-         }
+         recursiveDelete(root);
       }
 
+      // Reset class loader
       if (kernelClassLoader != null && kernelClassLoader instanceof Closeable)
       {
          try
@@ -358,6 +294,57 @@
    }
 
    /**
+    * Find a deployment unit
+    * @param url The unique URL for a deployment
+    * @return The deployment unit; <code>null</code> if no unit is found
+    */
+   Deployment findDeployment(URL url)
+   {
+      if (deployments != null)
+      {
+         for (Deployment deployment : deployments)
+         {
+            if (deployment.getURL().equals(url))
+               return deployment;
+         }
+      }
+
+      return null;
+   }
+
+   /**
+    * Shutdown a deployment unit
+    * @param deployment The deployment unit
+    * @exception Throwable If an error occurs
+    */
+   void shutdownDeployment(Deployment deployment) throws Throwable
+   {
+      SecurityActions.setThreadContextClassLoader(kernelClassLoader);
+
+      try
+      {
+         Method stopMethod = deployment.getClass().getMethod("stop", (Class[])null);
+         stopMethod.invoke(deployment, (Object[])null);
+      }
+      catch (Exception e)
+      {
+         // No stop method
+      }
+
+      try
+      {
+         Method destroyMethod = deployment.getClass().getMethod("destroy", (Class[])null);
+         destroyMethod.invoke(deployment, (Object[])null);
+      }
+      catch (Exception e)
+      {
+         // No destroy method
+      }
+
+      deployments.remove(deployment);
+   }
+
+   /**
     * Get the kernel class loader
     * @return The class loader
     */
@@ -407,6 +394,18 @@
    }
 
    /**
+    * Remove a bean
+    * @param name The name of the bean
+    * @param bean The bean
+    */
+   synchronized void removeBean(String name)
+   {
+      startup.remove(name);
+      services.remove(name);
+      servicesStatus.remove(name);
+   }
+
+   /**
     * Get a bean
     * @param name The name of the bean
     * @return The bean

Modified: projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/MainDeployer.java
===================================================================
--- projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/MainDeployer.java	2009-09-17 18:04:37 UTC (rev 93655)
+++ projects/jboss-jca/trunk/fungal/src/main/java/org/jboss/jca/fungal/impl/MainDeployer.java	2009-09-17 18:23:34 UTC (rev 93656)
@@ -117,6 +117,9 @@
     */
    public synchronized void undeploy(URL url, ClassLoader classLoader) throws Throwable
    {
+      Deployment deployment = kernel.findDeployment(url);
+      if (deployment != null)
+         kernel.shutdownDeployment(deployment);
    }
 
    /**

Modified: projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/Main.java
===================================================================
--- projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/Main.java	2009-09-17 18:04:37 UTC (rev 93655)
+++ projects/jboss-jca/trunk/sjc/src/main/java/org/jboss/jca/sjc/Main.java	2009-09-17 18:23:34 UTC (rev 93656)
@@ -278,8 +278,15 @@
             @Override
             public void run()
             {
-               if (kernel != null)
-                  kernel.shutdown();
+               try
+               {
+                  if (kernel != null)
+                     kernel.shutdown();
+               }
+               catch (Throwable t)
+               {
+                  error(t.getMessage(), t);
+               }
             }
          });
 




More information about the jboss-cvs-commits mailing list