You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2010/05/06 11:21:24 UTC

svn commit: r941622 - /servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AdminCommandsImpl.java

Author: ffang
Date: Thu May  6 09:21:24 2010
New Revision: 941622

URL: http://svn.apache.org/viewvc?rev=941622&view=rev
Log:
[SMX4NMR-190]can't refresh JBI deployer bundle

Modified:
    servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AdminCommandsImpl.java

Modified: servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AdminCommandsImpl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AdminCommandsImpl.java?rev=941622&r1=941621&r2=941622&view=diff
==============================================================================
--- servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AdminCommandsImpl.java (original)
+++ servicemix/smx4/nmr/trunk/jbi/deployer/src/main/java/org/apache/servicemix/jbi/deployer/impl/AdminCommandsImpl.java Thu May  6 09:21:24 2010
@@ -24,6 +24,7 @@ import java.util.Properties;
 import java.util.Set;
 
 import javax.jbi.management.LifeCycleMBean;
+import javax.management.ObjectName;
 
 import org.apache.servicemix.jbi.deployer.AdminCommandsService;
 import org.apache.servicemix.jbi.deployer.Component;
@@ -445,14 +446,24 @@ public class AdminCommandsImpl implement
     }
 
     public void init() throws Exception {
-        deployer.getManagementStrategy().manageObject(this);
+    	try {
+    		deployer.getManagementStrategy().manageObject(this);
+    	} catch (Exception e) {
+    		//means somehow the previous AdminCommandsService not dereference successfully, 
+    		//this could be caused by a race between the AdminCommandsImpl destroy-method 
+    		//being called and Blueprint itself being shutdown.
+    		//so we try to dereference it again at this point
+        	ObjectName objectName = deployer.getManagementStrategy().getManagedObjectName(this, null, ObjectName.class);
+        	deployer.getManagementStrategy().unmanageNamedObject(objectName);
+        	deployer.getManagementStrategy().manageObject(this);
+    	}
     }
 
     public void destroy() throws Exception {
         try {
-            deployer.getManagementStrategy().unmanageObject(this);
+        	deployer.getManagementStrategy().unmanageObject(this);
         } catch (Exception e) {
-            // ignore ServiceUnavailableException thrown by Blueprint
+        	// ignore ServiceUnavailableException thrown by Blueprint
             // Service on dereference of ManagementStrategy proxy if its
             // already in the process of itself shutting down
         }