[jboss-cvs] JBossAS SVN: r76829 - in trunk/system-jmx/src/main/org/jboss/system: microcontainer and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 8 09:09:54 EDT 2008


Author: alesj
Date: 2008-08-08 09:09:54 -0400 (Fri, 08 Aug 2008)
New Revision: 76829

Modified:
   trunk/system-jmx/src/main/org/jboss/system/ServiceController.java
   trunk/system-jmx/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java
   trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerRegistrationLifecycleCallback.java
Log:
[JBAS-5843]; fix ServiceControllerContext.target via @JMX.

Modified: trunk/system-jmx/src/main/org/jboss/system/ServiceController.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/ServiceController.java	2008-08-08 12:38:17 UTC (rev 76828)
+++ trunk/system-jmx/src/main/org/jboss/system/ServiceController.java	2008-08-08 13:09:54 UTC (rev 76829)
@@ -28,7 +28,6 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.CopyOnWriteArrayList;
-
 import javax.management.MBeanRegistration;
 import javax.management.MBeanServer;
 import javax.management.Notification;
@@ -40,7 +39,7 @@
 import org.jboss.dependency.spi.ControllerState;
 import org.jboss.dependency.spi.DependencyInfo;
 import org.jboss.dependency.spi.DependencyItem;
-import org.jboss.deployment.DeploymentException;
+import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployment.DeploymentInfo;
 import org.jboss.deployment.DeploymentState;
 import org.jboss.kernel.Kernel;
@@ -104,8 +103,19 @@
    
    /** The contexts in installation order */
    protected CopyOnWriteArrayList<ServiceControllerContext> installedOrder = new CopyOnWriteArrayList<ServiceControllerContext>();
-   
+
    /**
+    * Get exception that will expose stacktrace.
+    *
+    * @return the stracktrace exposing exception
+    */
+   protected Throwable getStackTrace()
+   {
+      //noinspection ThrowableInstanceNeverThrown
+      return new Exception("STACKTRACE");
+   }
+
+   /**
     * Get the MBeanServer
     * 
     * @return the server
@@ -208,13 +218,12 @@
 
    public void validateDeploymentState(DeploymentInfo di, DeploymentState state)
    {
-      ArrayList<ObjectName> mbeans = new ArrayList<ObjectName>(di.mbeans);
+      List<ObjectName> mbeans = new ArrayList<ObjectName>(di.mbeans);
       if (di.deployedObject != null)
          mbeans.add(di.deployedObject);
       boolean mbeansStateIsValid = true;
-      for (int m = 0; m < mbeans.size(); ++m)
+      for (ObjectName serviceName : mbeans)
       {
-         ObjectName serviceName = mbeans.get(m);
          ServiceContext ctx = getServiceContext(serviceName);
          if (ctx != null && state == DeploymentState.STARTED)
             mbeansStateIsValid &= ctx.state == ServiceContext.RUNNING;
@@ -327,11 +336,33 @@
       register(serviceName, depends, true);
    }
 
+   /**
+    * Register the mbean against the microkernel with dependencies.
+    *
+    * @param serviceName the object name
+    * @param depends the dependencies
+    * @param includeLifecycle the includes lifecycle flag
+    * @throws Exception for any error
+    */
    public void register(ObjectName serviceName, Collection<ObjectName> depends, boolean includeLifecycle)  throws Exception
    {
+      register(serviceName, depends, includeLifecycle, null);
+   }
+
+   /**
+    * Register the mbean against the microkernel with dependencies.
+    *
+    * @param serviceName the object name
+    * @param depends the dependencies
+    * @param includeLifecycle the includes lifecycle flag
+    * @param target the target
+    * @throws Exception for any error
+    */
+   public void register(ObjectName serviceName, Collection<ObjectName> depends, boolean includeLifecycle, Object target)  throws Exception
+   {
       if (serviceName == null)
       {
-         log.warn("Ignoring request to register null service: ", new Exception("STACKTRACE"));
+         log.warn("Ignoring request to register null service: ", getStackTrace());
          return;
       }
       
@@ -339,7 +370,7 @@
 
       // This is an already registered mbean
       KernelController controller = kernel.getController();
-      ServiceControllerContext context = new ServiceControllerContext(this, serviceName, includeLifecycle);
+      ServiceControllerContext context = new ServiceControllerContext(this, serviceName, includeLifecycle, target);
       if (depends != null)
          addDependencies(context, depends);
 
@@ -367,7 +398,7 @@
    {
       if (serviceName == null)
       {
-         log.warn("Ignoring request to create null service: ", new Exception("STACKTRACE"));
+         log.warn("Ignoring request to create null service: ", getStackTrace());
          return;
       }
       
@@ -407,7 +438,7 @@
    {
       if (serviceName == null)
       {
-         log.warn("Ignoring request to start null service: ", new Exception("STACKTRACE"));
+         log.warn("Ignoring request to start null service: ", getStackTrace());
          return;
       }
 
@@ -445,7 +476,7 @@
    {
       if (serviceName == null)
       {
-         log.warn("Ignoring request to restart null service: ", new Exception("STACKTRACE"));
+         log.warn("Ignoring request to restart null service: ", getStackTrace());
          return;
       }
 
@@ -458,7 +489,7 @@
    {
       if (serviceName == null)
       {
-         log.warn("Ignoring request to stop null service: ", new Exception("STACKTRACE"));
+         log.warn("Ignoring request to stop null service: ", getStackTrace());
          return;
       }
 
@@ -495,7 +526,7 @@
    {
       if (serviceName == null)
       {
-         log.warn("Ignoring request to destroy null service: ", new Exception("STACKTRACE"));
+         log.warn("Ignoring request to destroy null service: ", getStackTrace());
          return;
       }
 
@@ -532,7 +563,7 @@
    {
       if (objectName == null)
       {
-         log.warn("Ignoring request to remove null service: ", new Exception("STACKTRACE"));
+         log.warn("Ignoring request to remove null service: ", getStackTrace());
          return;
       }
 
@@ -603,7 +634,7 @@
 
    public void postRegister(Boolean registrationDone)
    {
-      if (registrationDone.booleanValue() == false)
+      if (registrationDone == false)
          log.fatal("Registration of ServiceController failed");
       else
       {

Modified: trunk/system-jmx/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java	2008-08-08 12:38:17 UTC (rev 76828)
+++ trunk/system-jmx/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java	2008-08-08 13:09:54 UTC (rev 76829)
@@ -45,10 +45,10 @@
  * ServiceControllerContext.
  * 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
  * @version $Revision: 1.1 $
  */
-public class ServiceControllerContext extends AbstractControllerContext
-   implements InvokeDispatchContext
+public class ServiceControllerContext extends AbstractControllerContext implements InvokeDispatchContext
 {
    /** The ObjectName */
    private ObjectName objectName;
@@ -78,21 +78,36 @@
    
    /**
     * Create a new ServiceControllerContext.
-    * 
+    *
     * @param serviceController the service controller
     * @param name the name of the context
     * @param includeLifecycle whether to include the lifecycle callouts
     */
    public ServiceControllerContext(ServiceController serviceController, ObjectName name, boolean includeLifecycle)
    {
+      this(serviceController, name, includeLifecycle, null);
+   }
+
+   /**
+    * Create a new ServiceControllerContext.
+    *
+    * @param serviceController the service controller
+    * @param name the name of the context
+    * @param includeLifecycle whether to include the lifecycle callouts
+    * @param target the target
+    */
+   public ServiceControllerContext(ServiceController serviceController, ObjectName name, boolean includeLifecycle, Object target)
+   {
       super(name.getCanonicalName(), ServiceControllerContextActions.getLifecycleOnly());
       this.objectName = name;
       serviceContext.objectName = objectName;
       this.serviceController = serviceController;
       setMode(ControllerMode.MANUAL);
       this.includeLifecycle = includeLifecycle;
+      if (target != null)
+         setTarget(target);
    }
-   
+
    /**
     * Create a new ServiceControllerContext.
     * 

Modified: trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerRegistrationLifecycleCallback.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerRegistrationLifecycleCallback.java	2008-08-08 12:38:17 UTC (rev 76828)
+++ trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerRegistrationLifecycleCallback.java	2008-08-08 13:09:54 UTC (rev 76829)
@@ -23,7 +23,6 @@
 
 import java.util.HashMap;
 import java.util.Map;
-
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 import javax.management.StandardMBean;
@@ -102,7 +101,7 @@
       {
          // Don't include the lifecycle callouts unless we know the MBean implementation
          // wants them and supports "double invocation"
-         getServiceController().register(objectName, null, false);
+         getServiceController().register(objectName, null, false, context.getTarget());
       }
       catch (Exception e)
       {




More information about the jboss-cvs-commits mailing list