[jboss-cvs] JBossAS SVN: r60220 - in trunk: server/src/etc/conf/default and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Feb 2 16:56:27 EST 2007


Author: kabir.khan at jboss.com
Date: 2007-02-02 16:56:27 -0500 (Fri, 02 Feb 2007)
New Revision: 60220

Added:
   trunk/aspects/src/main/org/jboss/aop/deployers/AspectManagerJMXRegistrar.java
Modified:
   trunk/aspects/src/main/org/jboss/aop/deployers/AbstractAspectManager.java
   trunk/server/src/etc/conf/default/bootstrap-beans.xml
Log:
Add bean to register the AspectManager in JMX

Modified: trunk/aspects/src/main/org/jboss/aop/deployers/AbstractAspectManager.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aop/deployers/AbstractAspectManager.java	2007-02-02 21:50:22 UTC (rev 60219)
+++ trunk/aspects/src/main/org/jboss/aop/deployers/AbstractAspectManager.java	2007-02-02 21:56:27 UTC (rev 60220)
@@ -51,52 +51,13 @@
 {
    final static String BASE_ASPECTS_XML = "base-aspects.xml";
    AspectManagerService delegate = null;
-//   MBeanServer server;
    String bootstrapXml;
    
    public AbstractAspectManager(String bootstrapXml)
    {
       this.bootstrapXml = bootstrapXml;
-      try
-      {
-         if (bootstrapXml != null)
-         {
-            InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
-            try
-            {
-               Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
-               AspectXmlLoader loader = new AspectXmlLoader();
-               loader.setManager(getAspectManager());
-               loader.deployXML(doc, null);
-            }
-            finally
-            {
-               if (in != null)
-               {
-                  in.close();
-               }
-            }
-         }
-      }
-      catch (Exception e)
-      {
-         // AutoGenerated
-         throw new RuntimeException("Problem starting AspectManager", e);
-      }
    }
 
-   /*
-   public void setMbeanServer(MBeanServer server)
-   {
-      this.server = server;
-   }
-
-   public MBeanServer getMbeanServer()
-   {
-      return server;
-   }
-   */
-   
    public AspectManager getAspectManager()
    {
       return AspectManager.getTopLevelAspectManager();
@@ -146,6 +107,32 @@
     */
    public void create() throws Exception
    {
+      try
+      {
+         if (bootstrapXml != null && bootstrapXml.trim().length() == 0)
+         {
+            InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
+            try
+            {
+               Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
+               AspectXmlLoader loader = new AspectXmlLoader();
+               loader.setManager(getAspectManager());
+               loader.deployXML(doc, null);
+            }
+            finally
+            {
+               if (in != null)
+               {
+                  in.close();
+               }
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         // AutoGenerated
+         throw new RuntimeException("Problem starting AspectManager", e);
+      }
       delegate.create();
    }
 
@@ -169,35 +156,31 @@
     */
    public void destroy()
    {
-//      if (this.server == null)
-//      {
-//         try
-//         {
-//            if (bootstrapXml != null)
-//            {
-//               InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
-//               try
-//               {
-//                  Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
-//                  AspectXmlLoader loader = new AspectXmlLoader();
-//                  loader.setManager(getAspectManager());
-//                  loader.deployXML(doc, null);
-//               }
-//               finally
-//               {
-//                  if (in != null)
-//                  {
-//                     in.close();
-//                  }
-//               }
-//            }
-//            server.unregisterMBean(new ObjectName("jboss.aop:service=AspectManager"));
-//         }
-//         catch (Exception e)
-//         {
-//            throw new RuntimeException("Problem unregistering jboss.aop:service=AspectManager with JMXServer", e);
-//         }
-//      }
+      try
+      {
+         if (bootstrapXml != null)
+         {
+            InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
+            try
+            {
+               Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
+               AspectXmlLoader loader = new AspectXmlLoader();
+               loader.setManager(getAspectManager());
+               loader.deployXML(doc, null);
+            }
+            finally
+            {
+               if (in != null)
+               {
+                  in.close();
+               }
+            }
+         }
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Problem destroying AspectManager", e);
+      }
       delegate.destroy();
    }
 

Added: trunk/aspects/src/main/org/jboss/aop/deployers/AspectManagerJMXRegistrar.java
===================================================================
--- trunk/aspects/src/main/org/jboss/aop/deployers/AspectManagerJMXRegistrar.java	                        (rev 0)
+++ trunk/aspects/src/main/org/jboss/aop/deployers/AspectManagerJMXRegistrar.java	2007-02-02 21:56:27 UTC (rev 60220)
@@ -0,0 +1,80 @@
+/*
+* JBoss, Home of Professional Open Source.
+* Copyright 2006, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.aop.deployers;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.jboss.logging.Logger;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AspectManagerJMXRegistrar
+{
+   final static Logger log = Logger.getLogger(AspectManagerJMXRegistrar.class.getName());
+   final static String ASPECTMANAGER_OBJECTNAME = "jboss.aop:service=AspectManager";
+   
+   MBeanServer server;
+   AbstractAspectManager aspectManager;
+   
+   public void setMbeanServer(MBeanServer server)
+   {
+      this.server = server;
+   }
+
+   public void setAspectManager(AbstractAspectManager aspectManager)
+   {
+      this.aspectManager = aspectManager;
+   }
+   
+   public void start() throws Exception
+   {
+      try
+      {
+         log.debug("Registering AspectManagerService in JMX under: " + ASPECTMANAGER_OBJECTNAME);
+         server.registerMBean(aspectManager.delegate, new ObjectName(ASPECTMANAGER_OBJECTNAME));
+      }
+      catch (Exception e)
+      {
+         // AutoGenerated
+         throw new RuntimeException("Error starting AspectManagerJMXWrapper", e);
+      }
+   }
+
+
+   public void stop()
+   {
+      try
+      {
+         log.debug("Unregistering AspectManagerService in JMX under: " + ASPECTMANAGER_OBJECTNAME);
+         server.unregisterMBean(new ObjectName(ASPECTMANAGER_OBJECTNAME));
+      }
+      catch (Exception e)
+      {
+         // AutoGenerated
+         throw new RuntimeException("Error stopping AspectManagerJMXWrapper", e);
+      }
+   }
+}

Modified: trunk/server/src/etc/conf/default/bootstrap-beans.xml
===================================================================
--- trunk/server/src/etc/conf/default/bootstrap-beans.xml	2007-02-02 21:50:22 UTC (rev 60219)
+++ trunk/server/src/etc/conf/default/bootstrap-beans.xml	2007-02-02 21:56:27 UTC (rev 60220)
@@ -174,6 +174,12 @@
       <depends>AspectManager</depends>
    </bean>
 
+	<!-- MBean for making sure that the underlying AspectManagerService gets registered in JMX -->
+	<bean name="AspectManagerJMXRegistrar" class="org.jboss.aop.deployers.AspectManagerJMXRegistrar">
+	   <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
+	   <property name="aspectManager"><inject bean="AspectManager"/></property>
+	</bean>
+
    <!-- A filter for excluding files from the scanner -->
    <bean name="DeploymentFilter" class="org.jboss.virtual.plugins.vfs.helpers.ExtensibleFilter">
       <!-- Files starting with theses strings are ignored -->




More information about the jboss-cvs-commits mailing list