servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject svn commit: r1164362 - in /servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework: AdminCommandsService.java InstallationService.java
Date Fri, 02 Sep 2011 06:43:45 GMT
Author: jbonofre
Date: Fri Sep  2 06:43:45 2011
New Revision: 1164362

URL: http://svn.apache.org/viewvc?rev=1164362&view=rev
Log:
[SM-2117] Fix components uninstall after container restart

Modified:
    servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java
    servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java

Modified: servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java?rev=1164362&r1=1164361&r2=1164362&view=diff
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java
(original)
+++ servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AdminCommandsService.java
Fri Sep  2 06:43:45 2011
@@ -82,6 +82,10 @@ public class AdminCommandsService extend
         if (!comp.isShutDown()) {
             throw ManagementSupport.failure("uninstallComponent", "Component '" + name +
"' is not shut down.");
         }
+        // taken from org.apache.servicemix.jbi.framework.AutoDeploymentService#removeArchive
+        // ensure installer is loaded
+        container.getInstallationService().loadInstaller(name);
+        // uninstall and delete component
         boolean success = container.getInstallationService().unloadInstaller(name, true);
         if (success) {
             return ManagementSupport.createSuccessMessage("uninstallComponent", name);
@@ -276,9 +280,10 @@ public class AdminCommandsService extend
      * Prints information about all components (Service Engine or Binding
      * Component) installed
      * 
-     * @param serviceEngines
-     * @param bindingComponents
-     * @param state
+     * @param excludeSEs
+     * @param excludeBCs
+     * @param excludePojos
+     * @param requiredState
      * @param sharedLibraryName
      * @param serviceAssemblyName
      * @return list of components in an XML blob

Modified: servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java?rev=1164362&r1=1164361&r2=1164362&view=diff
==============================================================================
--- servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java
(original)
+++ servicemix/smx3/trunk/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/InstallationService.java
Fri Sep  2 06:43:45 2011
@@ -90,24 +90,22 @@ public class InstallationService extends
             ObjectName result = null;
             LOGGER.debug("Loading new installer from {}", installJarURL);
             File tmpDir = AutoDeploymentService.unpackLocation(environmentContext.getTmpDir(),
installJarURL);
-            if (tmpDir != null) {
-                Descriptor root = DescriptorFactory.buildDescriptor(tmpDir);
-                if (root != null && root.getComponent() != null) {
-                    String componentName = root.getComponent().getIdentification().getName();
-                    if (!installers.containsKey(componentName)) {
-                        InstallerMBeanImpl installer = doInstallArchive(tmpDir, root);
-                        if (installer != null) {
-                            result = installer.getObjectName();
-                            installers.put(componentName, installer);
-                        }
-                    } else {
-                        throw new RuntimeException("An installer already exists for " + componentName);
-                    }
-                } else {
-                    throw new RuntimeException("Could not find Component from: " + installJarURL);
-                }
-            } else {
-                throw new RuntimeException("location: " + installJarURL + " isn't valid");
+            if (tmpDir == null) {
+                throw new RuntimeException("loation " + installJarURL + " isn't valid");
+            }
+            Descriptor root = DescriptorFactory.buildDescriptor(tmpDir);
+            if (root == null || root.getComponent() == null) {
+                throw new RuntimeException("Could not find Component from " + installJarURL);
+            }
+            String componentName = root.getComponent().getIdentification().getName();
+            if (installers.containsKey(componentName)) {
+                throw new RuntimeException("An installer already exists for " + componentName);
+            }
+            InstallerMBeanImpl installer = doInstallArchive(tmpDir, root);
+            if (installer != null) {
+                result = installer.getObjectName();
+                LOGGER.debug("Registering installer as loaded for component {}", componentName);
+                installers.put(componentName, installer);
             }
             return result;
         } catch (Throwable t) {
@@ -132,10 +130,14 @@ public class InstallationService extends
      *         existing installation context.
      */
     public ObjectName loadInstaller(String aComponentName) {
+        LOGGER.debug("Going to load installer for component {}", aComponentName);
         InstallerMBeanImpl installer = installers.get(aComponentName);
+        LOGGER.debug("Found installer for component {}", aComponentName);
         if (installer == null) {
+            LOGGER.debug("Loaded installer for component {} was not found. Trying non-loaded
installers", aComponentName);
             installer = nonLoadedInstallers.get(aComponentName);
             if (installer != null) {
+                LOGGER.debug("Found non-loaded installer for component {}", aComponentName);
                 try {
                     // create an MBean for the installer
                     ObjectName objectName = managementContext.createCustomComponentMBeanName("Installer",
aComponentName);
@@ -146,6 +148,8 @@ public class InstallationService extends
                     throw new RuntimeException("Could not load installer", e);
                 }
                 return installer.getObjectName();
+            } else {
+                LOGGER.debug("Did not found any installer for component " + aComponentName);
             }
         }
         return null;
@@ -176,20 +180,26 @@ public class InstallationService extends
      * @return - true if the operation was successful, otherwise false.
      */
     public boolean unloadInstaller(String componentName, boolean isToBeDeleted) {
+        LOGGER.debug("Going to unload installer for component {}", componentName);
         boolean result = false;
         try {
             InstallerMBeanImpl installer = installers.remove(componentName);
             result = installer != null;
             if (result) {
+                LOGGER.debug("Found installer for component {}", componentName);
                 container.getManagementContext().unregisterMBean(installer);
                 if (isToBeDeleted) {
+                    LOGGER.debug("Uninstalling component {}", componentName);
                     installer.uninstall();
                 } else {
+                    LOGGER.debug("Registering installer as non-loaded for component {}",
componentName);
                     nonLoadedInstallers.put(componentName, installer);
                 }
+            } else {
+                LOGGER.debug("Did not found installer for component {}", componentName);
             }
         } catch (JBIException e) {
-            String errStr = "Problem shutting down Component: " + componentName;
+            String errStr = "Problem unloading installer for component " + componentName;
             LOGGER.error(errStr, e);
         }
         return result;
@@ -293,6 +303,7 @@ public class InstallationService extends
      * @throws DeploymentException
      */
     protected void install(File tmpDir, Properties props, Descriptor root, boolean autoStart)
throws DeploymentException {
+        LOGGER.debug("Going to install component from {}", tmpDir.getPath());
         if (root.getComponent() != null) {
             String componentName = root.getComponent().getIdentification().getName();
             if (installers.containsKey(componentName)) {
@@ -336,6 +347,7 @@ public class InstallationService extends
                         throw new DeploymentException(e);
                     }
                 }
+                LOGGER.debug("Registering installer as loaded for component {}", componentName);
                 installers.put(componentName, installer);
             }
         }
@@ -524,10 +536,13 @@ public class InstallationService extends
     }
 
     protected void buildComponent(File componentDirectory) throws DeploymentException {
+        LOGGER.debug("Building component from directory {}" + componentDirectory.getPath());
         try {
             String componentName = componentDirectory.getName();
             ComponentEnvironment env = container.getEnvironmentContext().getComponentEnvironment(componentName);
             if (!env.getStateFile().exists()) {
+                LOGGER.debug("Removing directory {} as component has not been installed (there
is not state file)",
+                        componentDirectory.getPath());
                 // An installer has been created but the component has not been
                 // installed
                 // So remove it
@@ -536,6 +551,7 @@ public class InstallationService extends
                 InstallerMBeanImpl installer = createInstaller(componentName);
                 installer.activateComponent();
                 nonLoadedInstallers.put(componentName, installer);
+                LOGGER.debug("Registering installer as loaded for component {}", componentName);
             }
         } catch (Throwable e) {
             LOGGER.error("Failed to deploy component: {}", componentDirectory.getName(),
e);



Mime
View raw message