[jboss-svn-commits] JBL Code SVN: r24205 - in labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer: deployment and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Dec 2 08:56:05 EST 2008


Author: beve
Date: 2008-12-02 08:56:05 -0500 (Tue, 02 Dec 2008)
New Revision: 24205

Added:
   labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployment/EsbDeploymentMBean.java
Modified:
   labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployers/EsbRuntimeDeployer.java
   labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployment/EsbDeployment.java
Log:
Added managment interface. The esb deployments will now show up in the jmx-console under jboss.esb.
Currently the only methods that are exposed are start and stop.


Modified: labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployers/EsbRuntimeDeployer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployers/EsbRuntimeDeployer.java	2008-12-02 13:53:48 UTC (rev 24204)
+++ labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployers/EsbRuntimeDeployer.java	2008-12-02 13:56:05 UTC (rev 24205)
@@ -46,6 +46,11 @@
     private Logger log = Logger.getLogger(EsbRuntimeDeployer.class);
 
     /**
+     * Prefix used for the BeanMetaData and for the managenment bean name.
+     */
+    private static final String BEAN_PREFIX = "jboss.esb";
+
+    /**
      * No args constructor.
      */
     public EsbRuntimeDeployer()
@@ -87,11 +92,14 @@
      */
     private BeanMetaData createBeanMetaData(final DeploymentUnit deploymentUnit, final EsbMetaData esbMetaData)
     {
-        BeanMetaDataBuilder bmdBuilder = BeanMetaDataBuilder.createBuilder("jboss.esb." + deploymentUnit.getName(), EsbDeployment.class.getName());
+        BeanMetaDataBuilder bmdBuilder = BeanMetaDataBuilder.createBuilder(BEAN_PREFIX + "." + deploymentUnit.getName(), EsbDeployment.class.getName());
         // Setup the first constructor argument.
         bmdBuilder.addConstructorParameter(String.class.getName(), esbMetaData.getAchiveName());
         // Setup the second constructor argument.
         bmdBuilder.addConstructorParameter(org.jboss.esb.deploy.config.DeploymentUnit.class.getName(), esbMetaData.getDeploymentUnit());
+        // Add management annotation.
+        final String mbeanName = BEAN_PREFIX + ":app=" + esbMetaData.getAchiveName();
+        bmdBuilder.addAnnotation("@org.jboss.aop.microcontainer.aspects.jmx.JMX(registerDirectly=true, exposedInterface=void.class, name=\"" + mbeanName + "\")");
 
         return bmdBuilder.getBeanMetaData();
     }

Modified: labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployment/EsbDeployment.java
===================================================================
--- labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployment/EsbDeployment.java	2008-12-02 13:53:48 UTC (rev 24204)
+++ labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployment/EsbDeployment.java	2008-12-02 13:56:05 UTC (rev 24205)
@@ -36,7 +36,7 @@
  * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
  * @since 5.0
  */
-public class EsbDeployment
+public class EsbDeployment implements EsbDeploymentMBean
 {
     /**
      * The name of the deployment achive.
@@ -87,6 +87,11 @@
      */
     public final void start() throws DeploymentException
     {
+        if (!isRuntimeDeployed())
+        {
+            create();
+        }
+
         runtime.deploy();
     }
 
@@ -97,10 +102,7 @@
      */
     public final void stop() throws DeploymentException
     {
-        if (runtime != null)
-        {
-            runtime.undeploy();
-        }
+        runtime.undeploy();
     }
 
     /**
@@ -123,4 +125,14 @@
         return deploymentName;
     }
 
+    /**
+     * Will check if the runtime is deployed.
+     *
+     * @return boolean  true if the runtime is deployed, otherwise false.
+     */
+    private boolean isRuntimeDeployed()
+    {
+        return runtime != null && runtime.getContext() != null;
+    }
+
 }

Added: labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployment/EsbDeploymentMBean.java
===================================================================
--- labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployment/EsbDeploymentMBean.java	                        (rev 0)
+++ labs/jbossesb/workspace/skeagh/container/microcontainer/src/main/java/org/jboss/esb/microcontainer/deployment/EsbDeploymentMBean.java	2008-12-02 13:56:05 UTC (rev 24205)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2008, Red Hat Middleware
+ * LLC, and individual contributors 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.esb.microcontainer.deployment;
+
+import org.jboss.esb.api.exception.DeploymentException;
+
+/**
+ * Simple marker interface to be used for jmx exposure.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ * @since 5.0
+ *
+ */
+public interface EsbDeploymentMBean
+{
+    /**
+     * Start a deployment.
+     *
+     * @throws DeploymentException If an exception occurs while starting.
+     */
+    void start() throws DeploymentException;
+
+    /**
+     * Stop a deployment.
+     *
+     * @throws DeploymentException If an exeption occurs while stoping.
+     */
+    void stop() throws DeploymentException;
+}




More information about the jboss-svn-commits mailing list