[jboss-cvs] JBossAS SVN: r73445 - in trunk: system-jmx/src/main/org/jboss/system and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri May 16 09:00:07 EDT 2008
Author: adrian at jboss.org
Date: 2008-05-16 09:00:06 -0400 (Fri, 16 May 2008)
New Revision: 73445
Added:
trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/AbstractServiceControllerLifecycleCallback.java
trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerCreateDestroyLifecycleCallback.java
trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerRegistrationLifecycleCallback.java
trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerStartStopLifecycleCallback.java
Modified:
trunk/server/src/etc/conf/default/bootstrap-beans.xml
trunk/server/src/etc/conf/default/bootstrap-repo-beans.xml
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/ServiceProxy.java
Log:
[JBAS-5355] - Tie MBean lifecycle to POJO lifecycle for @JMX and remove duplicate invocation of lifecycle methods
Modified: trunk/server/src/etc/conf/default/bootstrap-beans.xml
===================================================================
--- trunk/server/src/etc/conf/default/bootstrap-beans.xml 2008-05-16 11:50:05 UTC (rev 73444)
+++ trunk/server/src/etc/conf/default/bootstrap-beans.xml 2008-05-16 13:00:06 UTC (rev 73445)
@@ -128,13 +128,29 @@
<!-- Add the JMX -->
<lifecycle-configure xmlns="urn:jboss:aop-beans:1.0"
- name="JMXAdvice"
- class="org.jboss.system.microcontainer.jmx.ServiceControllerLifecycleCallback"
+ name="JMXRegistrationAdvice"
+ class="org.jboss.system.microcontainer.jmx.ServiceControllerRegistrationLifecycleCallback"
classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX"
manager-bean="AspectManager"
manager-property="aspectManager">
<property name="serviceController"><inject bean="JMXKernel" property="serviceController"/></property>
</lifecycle-configure>
+ <lifecycle-create xmlns="urn:jboss:aop-beans:1.0"
+ name="JMXCreateDestroyAdvice"
+ class="org.jboss.system.microcontainer.jmx.ServiceControllerCreateDestroyLifecycleCallback"
+ classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX"
+ manager-bean="AspectManager"
+ manager-property="aspectManager">
+ <property name="serviceController"><inject bean="JMXKernel" property="serviceController"/></property>
+ </lifecycle-create>
+ <lifecycle-install xmlns="urn:jboss:aop-beans:1.0"
+ name="JMXStartStopAdvice"
+ class="org.jboss.system.microcontainer.jmx.ServiceControllerStartStopLifecycleCallback"
+ classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX"
+ manager-bean="AspectManager"
+ manager-property="aspectManager">
+ <property name="serviceController"><inject bean="JMXKernel" property="serviceController"/></property>
+ </lifecycle-install>
<!-- The MainDeployer -->
<bean name="MainDeployer" class="org.jboss.deployers.plugins.main.MainDeployerImpl">
Modified: trunk/server/src/etc/conf/default/bootstrap-repo-beans.xml
===================================================================
--- trunk/server/src/etc/conf/default/bootstrap-repo-beans.xml 2008-05-16 11:50:05 UTC (rev 73444)
+++ trunk/server/src/etc/conf/default/bootstrap-repo-beans.xml 2008-05-16 13:00:06 UTC (rev 73445)
@@ -140,13 +140,29 @@
<!-- Add the JMX -->
<lifecycle-configure xmlns="urn:jboss:aop-beans:1.0"
- name="JMXAdvice"
- class="org.jboss.system.microcontainer.jmx.ServiceControllerLifecycleCallback"
+ name="JMXRegistrationAdvice"
+ class="org.jboss.system.microcontainer.jmx.ServiceControllerRegistrationLifecycleCallback"
classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX"
manager-bean="AspectManager"
manager-property="aspectManager">
<property name="serviceController"><inject bean="JMXKernel" property="serviceController"/></property>
</lifecycle-configure>
+ <lifecycle-create xmlns="urn:jboss:aop-beans:1.0"
+ name="JMXCreateDestroyAdvice"
+ class="org.jboss.system.microcontainer.jmx.ServiceControllerCreateDestroyLifecycleCallback"
+ classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX"
+ manager-bean="AspectManager"
+ manager-property="aspectManager">
+ <property name="serviceController"><inject bean="JMXKernel" property="serviceController"/></property>
+ </lifecycle-create>
+ <lifecycle-install xmlns="urn:jboss:aop-beans:1.0"
+ name="JMXStartStopAdvice"
+ class="org.jboss.system.microcontainer.jmx.ServiceControllerStartStopLifecycleCallback"
+ classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX"
+ manager-bean="AspectManager"
+ manager-property="aspectManager">
+ <property name="serviceController"><inject bean="JMXKernel" property="serviceController"/></property>
+ </lifecycle-install>
<!-- The MainDeployer -->
<bean name="MainDeployer" class="org.jboss.deployers.plugins.main.MainDeployerImpl">
Modified: trunk/system-jmx/src/main/org/jboss/system/ServiceController.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/ServiceController.java 2008-05-16 11:50:05 UTC (rev 73444)
+++ trunk/system-jmx/src/main/org/jboss/system/ServiceController.java 2008-05-16 13:00:06 UTC (rev 73445)
@@ -324,6 +324,11 @@
public void register(ObjectName serviceName, Collection<ObjectName> depends) throws Exception
{
+ register(serviceName, depends, true);
+ }
+
+ public void register(ObjectName serviceName, Collection<ObjectName> depends, boolean includeLifecycle) throws Exception
+ {
if (serviceName == null)
{
log.warn("Ignoring request to register null service: ", new Exception("STACKTRACE"));
@@ -334,7 +339,7 @@
// This is an already registered mbean
KernelController controller = kernel.getController();
- ServiceControllerContext context = new ServiceControllerContext(this, serviceName);
+ ServiceControllerContext context = new ServiceControllerContext(this, serviceName, includeLifecycle);
if (depends != null)
addDependencies(context, depends);
Modified: trunk/system-jmx/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java 2008-05-16 11:50:05 UTC (rev 73444)
+++ trunk/system-jmx/src/main/org/jboss/system/microcontainer/ServiceControllerContext.java 2008-05-16 13:00:06 UTC (rev 73445)
@@ -61,6 +61,9 @@
/** The service context */
private ServiceContext serviceContext = new ServiceContext();
+
+ // Whether to include the lifecycle
+ private boolean includeLifecycle = true;
/**
* Create a new ServiceControllerContext.
@@ -70,11 +73,24 @@
*/
public ServiceControllerContext(ServiceController serviceController, ObjectName name)
{
+ this(serviceController, name, true);
+ }
+
+ /**
+ * 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)
+ {
super(name.getCanonicalName(), ServiceControllerContextActions.getLifecycleOnly());
this.objectName = name;
serviceContext.objectName = objectName;
this.serviceController = serviceController;
setMode(ControllerMode.MANUAL);
+ this.includeLifecycle = includeLifecycle;
}
/**
@@ -221,7 +237,7 @@
MBeanServer server = serviceController.getMBeanServer();
if (server != null)
- serviceContext.proxy = ServiceProxy.getServiceProxy(objectName, server);
+ serviceContext.proxy = ServiceProxy.getServiceProxy(objectName, server, includeLifecycle);
return serviceContext.proxy;
}
Modified: trunk/system-jmx/src/main/org/jboss/system/microcontainer/ServiceProxy.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/microcontainer/ServiceProxy.java 2008-05-16 11:50:05 UTC (rev 73444)
+++ trunk/system-jmx/src/main/org/jboss/system/microcontainer/ServiceProxy.java 2008-05-16 13:00:06 UTC (rev 73445)
@@ -61,6 +61,9 @@
*/
private static HashMap<String, Integer> serviceOpMap = new HashMap<String, Integer>();
+ // A singleton proxy with no callouts
+ private static Service NO_LIFECYCLE_CALLOUT;
+
/**
* Initialize the service operation map.
*/
@@ -70,6 +73,8 @@
serviceOpMap.put("start", new Integer(1));
serviceOpMap.put("destroy", new Integer(2));
serviceOpMap.put("stop", new Integer(3));
+ Class<?>[] interfaces = { Service.class };
+ NO_LIFECYCLE_CALLOUT = (Service) Proxy.newProxyInstance(Service.class.getClassLoader(), interfaces, NoLifecycleCallout.INSTANCE);
}
private boolean[] hasOp = {false, false, false, false};
@@ -89,12 +94,29 @@
*/
public static Service getServiceProxy(ObjectName objectName, MBeanServer server) throws Exception
{
+ return getServiceProxy(objectName, server, true);
+ }
+
+ /**
+ * Get the Service interface through which the mbean given by objectName will be managed.
+ *
+ * @param objectName the object name
+ * @param server the mbean server
+ * @param includeLifecycle include lifecycle
+ * @return The Service value
+ * @throws Exception for any error
+ */
+ public static Service getServiceProxy(ObjectName objectName, MBeanServer server, boolean includeLifecycle) throws Exception
+ {
Service service = null;
MBeanInfo info = server.getMBeanInfo(objectName);
MBeanOperationInfo[] opInfo = info.getOperations();
- Class[] interfaces = { Service.class };
+ Class<?>[] interfaces = { Service.class };
InvocationHandler handler = new ServiceProxy(objectName, server, opInfo);
- service = (Service) Proxy.newProxyInstance(Service.class.getClassLoader(), interfaces, handler);
+ if (includeLifecycle == false)
+ service = NO_LIFECYCLE_CALLOUT;
+ else
+ service = (Service) Proxy.newProxyInstance(Service.class.getClassLoader(), interfaces, handler);
return service;
}
@@ -191,4 +213,14 @@
return null;
}
+
+ private static class NoLifecycleCallout implements InvocationHandler
+ {
+ private static NoLifecycleCallout INSTANCE = new NoLifecycleCallout();
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ return null;
+ }
+ }
}
Added: trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/AbstractServiceControllerLifecycleCallback.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/AbstractServiceControllerLifecycleCallback.java (rev 0)
+++ trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/AbstractServiceControllerLifecycleCallback.java 2008-05-16 13:00:06 UTC (rev 73445)
@@ -0,0 +1,121 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.system.microcontainer.jmx;
+
+import javax.management.ObjectName;
+
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.mx.server.ServerConstants;
+import org.jboss.mx.util.ObjectNameFactory;
+import org.jboss.system.ServiceController;
+
+/**
+ * ServiceControllerLifecycleCallback.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractServiceControllerLifecycleCallback
+{
+ /** The service controller */
+ private ServiceController serviceController;
+
+ /** The MBean Registry Object Name */
+ protected static ObjectName MBEAN_REGISTRY = ObjectNameFactory.create(ServerConstants.MBEAN_REGISTRY);
+
+ /**
+ * Get the serviceController.
+ *
+ * @return the serviceController.
+ */
+ public ServiceController getServiceController()
+ {
+ return serviceController;
+ }
+
+ /**
+ * Set the serviceController.
+ *
+ * @param serviceController the serviceController.
+ */
+ public void setServiceController(ServiceController serviceController)
+ {
+ this.serviceController = serviceController;
+ }
+
+ public void create() throws Exception
+ {
+ if (serviceController == null)
+ throw new IllegalStateException("No service controller configured");
+ }
+
+ public abstract void install(ControllerContext context) throws Exception;
+ {
+ }
+
+ public abstract void uninstall(ControllerContext context) throws Exception;
+
+ protected JMX readJmxAnnotation(ControllerContext context) throws Exception
+ {
+ MetaData metaData = context.getScopeInfo().getMetaData();
+ if (metaData != null)
+ return metaData.getAnnotation(JMX.class);
+ return null;
+ }
+
+ protected ObjectName createObjectName(ControllerContext context, JMX jmx) throws Exception
+ {
+ ObjectName objectName = null;
+ if (jmx != null)
+ {
+ String jmxName = jmx.name();
+ if (jmxName != null && jmxName.length() > 0)
+ objectName = new ObjectName(jmxName);
+ }
+
+ if (objectName == null)
+ {
+ // try to build one from the bean name
+ String name = (String) context.getName();
+
+ if (name.contains(":"))
+ {
+ objectName = new ObjectName(name);
+ }
+ else
+ {
+ objectName = new ObjectName("jboss.pojo:name='" + name + "'");
+ }
+ }
+
+ return objectName;
+ }
+
+ protected ObjectName determineObjectName(ControllerContext context) throws Exception
+ {
+ JMX jmx = readJmxAnnotation(context);
+ return createObjectName(context, jmx);
+ }
+}
\ No newline at end of file
Added: trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerCreateDestroyLifecycleCallback.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerCreateDestroyLifecycleCallback.java (rev 0)
+++ trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerCreateDestroyLifecycleCallback.java 2008-05-16 13:00:06 UTC (rev 73445)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.system.microcontainer.jmx;
+
+import javax.management.ObjectName;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.logging.Logger;
+
+/**
+ * ServiceControllerLifecycleCallback.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceControllerCreateDestroyLifecycleCallback extends AbstractServiceControllerLifecycleCallback
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(ServiceControllerCreateDestroyLifecycleCallback.class);
+
+ public void install(ControllerContext context) throws Exception
+ {
+ ObjectName objectName = determineObjectName(context);
+ getServiceController().create(objectName);
+ }
+
+ public void uninstall(ControllerContext context) throws Exception
+ {
+ ObjectName objectName = determineObjectName(context);
+ try
+ {
+ getServiceController().destroy(objectName);
+ }
+ catch(Exception e)
+ {
+ log.debug("Error destroying mbean", e);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerRegistrationLifecycleCallback.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerRegistrationLifecycleCallback.java (rev 0)
+++ trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerRegistrationLifecycleCallback.java 2008-05-16 13:00:06 UTC (rev 73445)
@@ -0,0 +1,142 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.system.microcontainer.jmx;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.classloading.spi.RealClassLoader;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+import org.jboss.logging.Logger;
+import org.jboss.mx.server.ServerConstants;
+
+/**
+ * ServiceControllerLifecycleCallback.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceControllerRegistrationLifecycleCallback extends AbstractServiceControllerLifecycleCallback
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(ServiceControllerRegistrationLifecycleCallback.class);
+
+ public void install(ControllerContext context) throws Exception
+ {
+ JMX jmx = readJmxAnnotation(context);
+ ObjectName objectName = createObjectName(context, jmx);
+
+ Class<?> intfClass = null;
+ boolean registerDirectly = false;
+ if (jmx != null)
+ {
+ intfClass = jmx.exposedInterface();
+ registerDirectly = jmx.registerDirectly();
+ }
+ Object mbean = (registerDirectly ? context.getTarget()
+ : new StandardMBean(context.getTarget(), intfClass));
+ MBeanServer server = getServiceController().getMBeanServer();
+ ClassLoader cl = null;
+ if (context instanceof InvokeDispatchContext)
+ {
+ try
+ {
+ cl = ((InvokeDispatchContext) context).getClassLoader();
+ }
+ catch (Throwable t)
+ {
+ log.debug("Unable to get classloader from " + context + " " + t);
+ }
+ if (cl == null)
+ cl = Thread.currentThread().getContextClassLoader();
+ }
+
+ ObjectName classLoaderName = null;
+ while (cl != null)
+ {
+ if (cl instanceof RealClassLoader)
+ {
+ classLoaderName = ((RealClassLoader) cl).getObjectName();
+ break;
+ }
+ cl = cl.getParent();
+ }
+
+ if (classLoaderName != null)
+ {
+ final Object[] args = {mbean, objectName, setUpClassLoaderProperty(cl)};
+ final String[] sig = {Object.class.getName(),
+ ObjectName.class.getName(), Map.class.getName()};
+ server.invoke(MBEAN_REGISTRY, "registerMBean", args, sig);
+ }
+ else
+ server.registerMBean(mbean, objectName);
+ try
+ {
+ // Don't include the lifecycle callouts unless we know the MBean implementation
+ // wants them and supports "double invocation"
+ getServiceController().register(objectName, null, false);
+ }
+ catch (Exception e)
+ {
+ try
+ {
+ server.unregisterMBean(objectName);
+ }
+ catch (Exception t)
+ {
+ log.debug("Error unregistering mbean", t);
+ }
+ throw e;
+ }
+ log.debug("Registered MBean " + objectName);
+ }
+
+ public void uninstall(ControllerContext context) throws Exception
+ {
+ ObjectName objectName = determineObjectName(context);
+ try
+ {
+ getServiceController().remove(objectName);
+ }
+ catch(Exception e)
+ {
+ log.debug("Error unregistering mbean", e);
+ }
+ log.debug("Unregistered MBean " + objectName);
+ }
+
+ @SuppressWarnings("unchecked")
+ protected HashMap setUpClassLoaderProperty(ClassLoader cl)
+ {
+ HashMap valueMap = new HashMap();
+ valueMap.put(ServerConstants.CLASSLOADER, cl);
+ return valueMap;
+ }
+}
\ No newline at end of file
Added: trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerStartStopLifecycleCallback.java
===================================================================
--- trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerStartStopLifecycleCallback.java (rev 0)
+++ trunk/system-jmx/src/main/org/jboss/system/microcontainer/jmx/ServiceControllerStartStopLifecycleCallback.java 2008-05-16 13:00:06 UTC (rev 73445)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.system.microcontainer.jmx;
+
+import javax.management.ObjectName;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.logging.Logger;
+
+/**
+ * ServiceControllerLifecycleCallback.
+ *
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ServiceControllerStartStopLifecycleCallback extends AbstractServiceControllerLifecycleCallback
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(ServiceControllerStartStopLifecycleCallback.class);
+
+ public void install(ControllerContext context) throws Exception
+ {
+ ObjectName objectName = determineObjectName(context);
+ getServiceController().start(objectName);
+ }
+
+ public void uninstall(ControllerContext context) throws Exception
+ {
+ ObjectName objectName = determineObjectName(context);
+ try
+ {
+ getServiceController().stop(objectName);
+ }
+ catch(Exception e)
+ {
+ log.debug("Error stopping mbean", e);
+ }
+ }
+}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list