You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2006/02/06 21:29:03 UTC

svn commit: r375355 - in /incubator/servicemix/trunk: servicemix-common/src/main/java/org/apache/servicemix/common/ servicemix-core/src/main/java/org/apache/servicemix/jbi/container/ servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ se...

Author: gnodet
Date: Mon Feb  6 12:29:00 2006
New Revision: 375355

URL: http://svn.apache.org/viewcvs?rev=375355&view=rev
Log:
SM-126: JBI Component undeploy fails to remove wdir folders

Added:
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClassLoaderUtil.java
Modified:
    incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationContextImpl.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/LocalComponentConnector.java
    incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContext.java
    incubator/servicemix/trunk/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181LifeCycle.java

Modified: incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java?rev=375355&r1=375354&r2=375355&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java (original)
+++ incubator/servicemix/trunk/servicemix-common/src/main/java/org/apache/servicemix/common/BaseLifeCycle.java Mon Feb  6 12:29:00 2006
@@ -126,7 +126,13 @@
             }
         }
         // Obtain or create the work manager
-        this.workManager = findWorkManager();
+        // When using the WorkManager from ServiceMix,
+        // some class loader problems can appear when
+        // trying to uninstall the components.
+        // Some threads owned by the work manager have a 
+        // security context referencing the component class loader
+        // so that every loaded classes are locked
+        //this.workManager = findWorkManager();
         if (this.workManager == null) {
             this.workManagerCreated = true;
             this.workManager = createWorkManager();

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java?rev=375355&r1=375354&r2=375355&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/EnvironmentContext.java Mon Feb  6 12:29:00 2006
@@ -471,15 +471,10 @@
      * @param connector
      * @param doDelete true if component is to be deleted
      */
-    public void unreregister(LocalComponentConnector connector, boolean doDelete) {
+    public void unreregister(LocalComponentConnector connector) {
         ComponentEnvironment ce = (ComponentEnvironment) envMap.remove(connector);
         if (ce != null) {
             ce.close();
-        }
-        if (doDelete) {
-            //remove Component directory structure
-            String name = connector.getComponentNameSpace().getName();
-            removeComponentRootDirectory(name);
         }
     }
 

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java?rev=375355&r1=375354&r2=375355&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/JBIContainer.java Mon Feb  6 12:29:00 2006
@@ -717,7 +717,7 @@
         	lcc.getComponentMBean().shutDown();
         	lcc.unregisterMbeans(managementContext);
             registry.deregisterComponent(component);
-            environmentContext.unreregister(lcc, true);
+            environmentContext.unreregister(lcc);
             log.info("Deactivating component for name: " + id + " component: " + component);
         }
         else {

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java?rev=375355&r1=375354&r2=375355&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java Mon Feb  6 12:29:00 2006
@@ -263,6 +263,9 @@
             container.getBroker().suspend();
             if ("component".equals(entry.type)) {
                 log.info("Uninstalling component: " + entry.name);
+                // Ensure installer is loaded
+                installationService.loadInstaller(entry.name);
+                // Uninstall and delete component
                 installationService.unloadInstaller(entry.name,true);
             } 
             if ("library".equals(entry.type)) {

Added: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClassLoaderUtil.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClassLoaderUtil.java?rev=375355&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClassLoaderUtil.java (added)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ClassLoaderUtil.java Mon Feb  6 12:29:00 2006
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2005-2006 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.servicemix.jbi.framework;
+
+import java.util.Map;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+
+/**
+ * Utility methods for class loader manipulation in a server environment.
+ *
+ * @author Dain Sundstrom
+ * @version $Id$
+ * @since 2.0
+ * 
+ * TODO: this has been copied from xbean-server 
+ */
+public final class ClassLoaderUtil {
+    private ClassLoaderUtil() {
+    }
+
+    /**
+     * Cleans well known class loader leaks in VMs and libraries.  There is a lot of bad code out there and this method
+     * will clear up the know problems.  This method should only be called when the class loader will no longer be used.
+     * It this method is called two often it can have a serious impact on preformance.
+     * @param classLoader the class loader to destroy
+     */
+    public static void destroy(ClassLoader classLoader) {
+        releaseCommonsLoggingCache(classLoader);
+        clearSunSoftCache(ObjectInputStream.class, "subclassAudits");
+        clearSunSoftCache(ObjectOutputStream.class, "subclassAudits");
+        clearSunSoftCache(ObjectStreamClass.class, "localDescs");
+        clearSunSoftCache(ObjectStreamClass.class, "reflectors");
+    }
+
+    /**
+     * Clears the caches maintained by the SunVM object stream implementation.  This method uses reflection and
+     * setAccessable to obtain access to the Sun cache.  The cache is locked with a synchronize monitor and cleared.
+     * This method completely clears the class loader cache which will impact preformance of object serialization.
+     * @param clazz the name of the class containing the cache field
+     * @param fieldName the name of the cache field
+     */
+    public static void clearSunSoftCache(Class clazz, String fieldName) {
+        Map cache = null;
+        try {
+            Field field = clazz.getDeclaredField(fieldName);
+            field.setAccessible(true);
+            cache = (Map) field.get(null);
+        } catch (Throwable ignored) {
+            // there is nothing a user could do about this anyway
+        }
+
+        if (cache != null) {
+            synchronized (cache) {
+                cache.clear();
+            }
+        }
+    }
+
+    /**
+     * Releases the specified classloader from the Apache Jakarta Commons Logging class loader cache using reflection.
+     * @param classLoader the class loader to release
+     */
+    public static void releaseCommonsLoggingCache(ClassLoader classLoader) {
+        try {
+            Class logFactory = classLoader.loadClass("org.apache.commons.logging.LogFactory");
+            Method release = logFactory.getMethod("release", new Class[] {ClassLoader.class});
+            release.invoke(null, new Object[] {classLoader});
+        } catch (Throwable ignored) {
+            // there is nothing a user could do about this anyway
+        }
+    }
+
+}

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java?rev=375355&r1=375354&r2=375355&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/ComponentMBeanImpl.java Mon Feb  6 12:29:00 2006
@@ -158,6 +158,7 @@
      * @exception javax.jbi.JBIException if the item fails to shut down.
      */
     public void doShutDown() throws javax.jbi.JBIException {
+        doStop();
         // Transition from UNKNOWN to SHUTDOWN is done at installation time
         // In this case or if the component is already shut down, do nothing
         if (!getCurrentState().equals(UNKNOWN) && !getCurrentState().equals(SHUTDOWN)) {

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationContextImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationContextImpl.java?rev=375355&r1=375354&r2=375355&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationContextImpl.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationContextImpl.java Mon Feb  6 12:29:00 2006
@@ -112,7 +112,7 @@
      * 
      * @return Return the install root
      */
-    public File getinstallRootAsDir(){
+    public File getInstallRootAsDir(){
         return installRoot;
     }
 

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java?rev=375355&r1=375354&r2=375355&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java Mon Feb  6 12:29:00 2006
@@ -62,6 +62,7 @@
     private ManagementContext managementContext;
     private ClassLoaderService classLoaderService=new ClassLoaderService();
     private Map installers=new ConcurrentHashMap();
+    private Map nonLoadedInstallers = new ConcurrentHashMap();
 
     /**
      * Get Description
@@ -129,66 +130,70 @@
     public ObjectName loadInstaller(String aComponentName) {
         InstallerMBeanImpl installer = (InstallerMBeanImpl) installers.get(aComponentName);
         if (installer == null) {
-            LocalComponentConnector cnn = container.getLocalComponentConnector(aComponentName);
-            if (cnn == null) {
-                throw new RuntimeException("Could not find Component : " + aComponentName);
-            }
-            try {
-                ComponentContextImpl context = cnn.getContext();
-                File installationDir = environmentContext.getInstallationDirectory(aComponentName);
-                Descriptor root = AutoDeploymentService.buildDescriptor(installationDir);
-                Component descriptor = root.getComponent();
-
-                String name = descriptor.getIdentification().getName();
-                InstallationContextImpl installationContext = new InstallationContextImpl();
-                installationContext.setInstall(false);
-                installationContext.setComponentName(name);
-                installationContext.setComponentDescription(descriptor.getIdentification().getDescription());
-                installationContext.setInstallRoot(installationDir);
-                installationContext.setComponentClassName(descriptor.getComponentClassName());
-                ClassPath cp = descriptor.getComponentClassPath();
-                if (cp != null) {
-                    installationContext.setClassPathElements(cp.getPathElements());
-                }
-                // now build the ComponentContext
-                installationContext.setContext(context);
-                InstallationDescriptorExtension desc = descriptor.getDescriptorExtension();
-                if (desc != null) {
-                    installationContext.setDescriptorExtension(desc.getDescriptorExtension());
-                }
-                installationContext.setBinding(descriptor.isBindingComponent());
-                installationContext.setEngine(descriptor.isServiceEngine());
-                // now we must initialize the boot strap class
-                String bootstrapClassName = descriptor.getBootstrapClassName();
-                ClassPath bootStrapClassPath = descriptor.getBootstrapClassPath();
-                InstallationClassLoader bootstrapLoader = null;
-                if (bootstrapClassName != null && bootstrapClassName.length() > 0) {
-                    boolean parentFirst = descriptor.isBootstrapClassLoaderDelegationParentFirst();
-                    bootstrapLoader = classLoaderService.buildClassLoader(
-                            installationDir, bootStrapClassPath.getPathElements(), parentFirst);
+            installer = (InstallerMBeanImpl) nonLoadedInstallers.get(aComponentName);
+            if (installer != null) {
+                try {
+                    // create an MBean for the installer
+                    ObjectName objectName = managementContext.createCustomComponentMBeanName("Installer", aComponentName);
+                    installer.setObjectName(objectName);
+                    managementContext.registerMBean(objectName, installer,
+                            InstallerMBean.class,
+                            "standard installation controls for a Component");
+                } catch (Exception e) {
+                    throw new RuntimeException("Could not load installer", e);
                 }
-                SharedLibraryList[] lists = descriptor.getSharedLibraries();
-                String componentClassName = descriptor.getComponentClassName();
-                ClassPath componentClassPath = descriptor.getComponentClassPath();
-                boolean parentFirst = descriptor.isComponentClassLoaderDelegationParentFirst();
-                ClassLoader componentClassLoader = classLoaderService.buildClassLoader(installationDir, componentClassPath
-                                .getPathElements(), parentFirst, lists);
-                installer = new InstallerMBeanImpl(container,
-                        installationContext, componentClassLoader,
-                        componentClassName, bootstrapLoader,
-                        bootstrapClassName, true);
-                // create an MBean for the installer
-                ObjectName objectName = managementContext.createCustomComponentMBeanName("Installer", name);
-                installer.setObjectName(objectName);
-                managementContext.registerMBean(objectName, installer,
-                        InstallerMBean.class,
-                        "standard installation controls for a Component");
-            } catch (Exception e) {
-                throw new RuntimeException("Could not load installer", e);
+                return installer.getObjectName();
             }
         }
-        ObjectName result = installer.getObjectName();
-        return result;
+        return null;
+    }
+    
+    private InstallerMBeanImpl createInstaller(String componentName) throws IOException, DeploymentException {
+        File installationDir = environmentContext.getInstallationDirectory(componentName);
+        Descriptor root = AutoDeploymentService.buildDescriptor(installationDir);
+        Component descriptor = root.getComponent();
+
+        String name = descriptor.getIdentification().getName();
+        InstallationContextImpl installationContext = new InstallationContextImpl();
+        installationContext.setInstall(false);
+        installationContext.setComponentName(name);
+        installationContext.setComponentDescription(descriptor.getIdentification().getDescription());
+        installationContext.setInstallRoot(installationDir);
+        installationContext.setComponentClassName(descriptor.getComponentClassName());
+        ClassPath cp = descriptor.getComponentClassPath();
+        if (cp != null) {
+            installationContext.setClassPathElements(cp.getPathElements());
+        }
+        // now build the ComponentContext
+        File componentRoot = environmentContext.getComponentRootDirectory(componentName);
+        ComponentContextImpl context = buildComponentContext(componentRoot, componentName);
+        installationContext.setContext(context);
+        InstallationDescriptorExtension desc = descriptor.getDescriptorExtension();
+        if (desc != null) {
+            installationContext.setDescriptorExtension(desc.getDescriptorExtension());
+        }
+        installationContext.setBinding(descriptor.isBindingComponent());
+        installationContext.setEngine(descriptor.isServiceEngine());
+        // now we must initialize the boot strap class
+        String bootstrapClassName = descriptor.getBootstrapClassName();
+        ClassPath bootStrapClassPath = descriptor.getBootstrapClassPath();
+        InstallationClassLoader bootstrapLoader = null;
+        if (bootstrapClassName != null && bootstrapClassName.length() > 0) {
+            boolean parentFirst = descriptor.isBootstrapClassLoaderDelegationParentFirst();
+            bootstrapLoader = classLoaderService.buildClassLoader(
+                    installationDir, bootStrapClassPath.getPathElements(), parentFirst);
+        }
+        SharedLibraryList[] lists = descriptor.getSharedLibraries();
+        String componentClassName = descriptor.getComponentClassName();
+        ClassPath componentClassPath = descriptor.getComponentClassPath();
+        boolean parentFirst = descriptor.isComponentClassLoaderDelegationParentFirst();
+        ClassLoader componentClassLoader = classLoaderService.buildClassLoader(installationDir, componentClassPath
+                        .getPathElements(), parentFirst, lists);
+        InstallerMBeanImpl installer = new InstallerMBeanImpl(container,
+                installationContext, componentClassLoader,
+                componentClassName, bootstrapLoader,
+                bootstrapClassName, true);
+        return installer;
     }
 
     /**
@@ -200,22 +205,24 @@
      *            true if the component is to be deleted as well.
      * @return - true if the operation was successful, otherwise false.
      */
-    public boolean unloadInstaller(String componentName,boolean isToBeDeleted){
+    public boolean unloadInstaller(String componentName, boolean isToBeDeleted){
         boolean result=false;
-        try{
+        try {
             container.getBroker().suspend();
-            InstallerMBeanImpl installer=(InstallerMBeanImpl) installers.remove(componentName);
-            result=installer!=null;
-            if(result){
+            InstallerMBeanImpl installer = (InstallerMBeanImpl) installers.remove(componentName);
+            result = installer != null;
+            if(result) {
                 container.getManagementContext().unregisterMBean(installer);
-                if(isToBeDeleted){
+                if (isToBeDeleted) {
                     installer.uninstall();
+                } else {
+                    nonLoadedInstallers.put(componentName, installer);
                 }
             }
-        }catch(JBIException e){
-            String errStr="problem shutting down Component: "+componentName;
-            log.error(errStr,e);
-        }finally{
+        } catch(JBIException e) {
+            String errStr = "problem shutting down Component: " + componentName;
+            log.error(errStr, e);
+        } finally {
             container.getBroker().resume();
         }
         return result;
@@ -608,35 +615,10 @@
     protected void buildComponent(File componentDirectory)
             throws DeploymentException {
         try {
-            File installationDirectory = environmentContext
-                    .getInstallationDirectory(componentDirectory.getName());
-            if (installationDirectory != null && installationDirectory.exists()) {
-                Descriptor root = AutoDeploymentService
-                        .buildDescriptor(installationDirectory);
-                if (root != null) {
-                    Component descriptor = root.getComponent();
-                    if (descriptor != null) {
-                        String componentName = descriptor.getIdentification().getName();
-                        File componentRoot = environmentContext.getComponentRootDirectory(componentName);
-                        ComponentContextImpl context = buildComponentContext(componentRoot, componentName);
-                        ClassLoader componentClassLoader = classLoaderService.buildClassLoader(installationDirectory,
-                                descriptor.getComponentClassPath().getPathElements(),
-                                descriptor.isComponentClassLoaderDelegationParentFirst(), 
-                                descriptor.getSharedLibraries());
-                        Class componentClass = componentClassLoader.loadClass(descriptor.getComponentClassName());
-                        if (componentClass != null) {
-                            Object component = componentClass.newInstance();
-                            container.activateComponent(installationDirectory,
-                                    (javax.jbi.component.Component) component, descriptor.getIdentification().getDescription(), context,
-                                    descriptor.isBindingComponent(), descriptor.isServiceEngine());
-                        } else {
-                            String err = "component class " + descriptor.getComponentClassName() + " not found";
-                            log.error(err);
-                            throw new DeploymentException(err);
-                        }
-                    }
-                }
-            }
+            String componentName = componentDirectory.getName();
+            InstallerMBeanImpl installer = createInstaller(componentName); 
+            installer.activateComponent();
+            nonLoadedInstallers.put(componentName, installer);
         } catch (Throwable e) {
             log.error("Failed to deploy component: "
                     + componentDirectory.getName(), e);

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java?rev=375355&r1=375354&r2=375355&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallerMBeanImpl.java Mon Feb  6 12:29:00 2006
@@ -131,15 +131,24 @@
         }
         ObjectName result = null;
         try {
+            result = activateComponent();
+            installed = true;
+        } finally {
+            if (bootstrap != null) {
+                bootstrap.cleanUp();
+            }
+        }
+        return result;
+    }
+    
+    public ObjectName activateComponent() throws JBIException {
+        ObjectName result = null;
+        try {
             Class componentClass = componentClassLoader.loadClass(context.getComponentClassName());
             if (componentClass != null){
                 Component component = (Component) componentClass.newInstance();
-                result = container.activateComponent(context.getinstallRootAsDir(), component,context.getComponentDescription(),(ComponentContextImpl) context.getContext(), context
+                result = container.activateComponent(context.getInstallRootAsDir(), component, context.getComponentDescription(),(ComponentContextImpl) context.getContext(), context
                         .isBinding(), context.isEngine());
-                installed = true;
-                if (bootstrap != null) {
-                    bootstrap.cleanUp();
-                }
             }
             else {
                 String err = "component class " + context.getComponentClassName() + " not found";
@@ -181,11 +190,20 @@
         if (bootstrap != null){
             bootstrap.onUninstall();
         }
-        container.deactivateComponent(context.getComponentName());
+        String componentName = context.getComponentName();
+        container.deactivateComponent(componentName);
         installed = false;
         if (bootstrap != null){
             bootstrap.cleanUp();
         }
+        ClassLoaderUtil.destroy(componentClassLoader);
+        ClassLoaderUtil.destroy(bootstrapClassLoader);
+        componentClassLoader = null;
+        bootstrapClassLoader = null;
+        bootstrap = null;
+        context = null;
+        System.gc();
+        container.getEnvironmentContext().removeComponentRootDirectory(componentName);
     }
 
     /**

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/LocalComponentConnector.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/LocalComponentConnector.java?rev=375355&r1=375354&r2=375355&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/LocalComponentConnector.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/LocalComponentConnector.java Mon Feb  6 12:29:00 2006
@@ -283,7 +283,13 @@
      */
     public void init() throws JBIException {
         if (context != null && component != null) {
-            getLifeCycle().init(context);
+            ClassLoader loader = Thread.currentThread().getContextClassLoader();
+            try {
+                Thread.currentThread().setContextClassLoader(getLifeCycle().getClass().getClassLoader());
+                getLifeCycle().init(context);
+            } finally {
+                Thread.currentThread().setContextClassLoader(loader);
+            }
         }
     }
 

Modified: incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContext.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContext.java?rev=375355&r1=375354&r2=375355&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContext.java (original)
+++ incubator/servicemix/trunk/servicemix-core/src/main/java/org/apache/servicemix/jbi/management/ManagementContext.java Mon Feb  6 12:29:00 2006
@@ -573,6 +573,7 @@
     public void unregisterMBean(ObjectName name) throws JBIException {
         try{
             mbeanServerContext.unregisterMBean(name);
+            beanMap.remove(name);
         }catch(JMException e){
             log.error("Failed to unregister mbean: " + name,e);
             throw new JBIException(e);

Modified: incubator/servicemix/trunk/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181LifeCycle.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181LifeCycle.java?rev=375355&r1=375354&r2=375355&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181LifeCycle.java (original)
+++ incubator/servicemix/trunk/servicemix-jsr181/src/main/java/org/apache/servicemix/jsr181/Jsr181LifeCycle.java Mon Feb  6 12:29:00 2006
@@ -18,8 +18,8 @@
 import org.apache.servicemix.common.BaseComponent;
 import org.apache.servicemix.common.BaseLifeCycle;
 import org.apache.servicemix.jsr181.xfire.JbiTransport;
+import org.codehaus.xfire.DefaultXFire;
 import org.codehaus.xfire.XFire;
-import org.codehaus.xfire.XFireFactory;
 import org.codehaus.xfire.transport.Transport;
 
 public class Jsr181LifeCycle extends BaseLifeCycle {
@@ -60,7 +60,7 @@
         super.doInit();
         configuration.setRootDir(context.getWorkspaceRoot());
         configuration.load();
-        xfire = XFireFactory.newInstance().getXFire();
+        xfire = new DefaultXFire();
         Object[] transports = xfire.getTransportManager().getTransports().toArray();
         for (int i = 0; i < transports.length; i++) {
             xfire.getTransportManager().unregister((Transport) transports[i]);