[jboss-cvs] JBossAS SVN: r78853 - in projects/aop/trunk: asintegration-core and 11 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 25 09:39:15 EDT 2008


Author: kabir.khan at jboss.com
Date: 2008-09-25 09:39:14 -0400 (Thu, 25 Sep 2008)
New Revision: 78853

Added:
   projects/aop/trunk/asintegration-core/
   projects/aop/trunk/asintegration-jmx/
   projects/aop/trunk/asintegration-mc/
Modified:
   projects/aop/trunk/asintegration-core/.classpath
   projects/aop/trunk/asintegration-core/pom.xml
   projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java
   projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/deployers/AbstractAspectManager.java
   projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/deployers/JBossAspectLibrary.java
   projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/deployment/AbstractAspectManagerService.java
   projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/deployment/AbstractAspectManagerServiceMBean.java
   projects/aop/trunk/asintegration-jmx/.classpath
   projects/aop/trunk/asintegration-jmx/pom.xml
   projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java
   projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/deployers/AbstractAspectManager.java
   projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/deployers/JBossAspectLibrary.java
   projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/deployment/AbstractAspectManagerService.java
   projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/deployment/AbstractAspectManagerServiceMBean.java
   projects/aop/trunk/asintegration-mc/.classpath
   projects/aop/trunk/asintegration-mc/pom.xml
   projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java
   projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/deployers/AbstractAspectManager.java
   projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/deployers/JBossAspectLibrary.java
   projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/deployment/AbstractAspectManagerService.java
   projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/deployment/AbstractAspectManagerServiceMBean.java
Log:
[JBAOP-652] Add new modules for asintegration. So far they are just copies of the existing asintegration module. I'll be deleting and moving round loads of stuff once this is in svn

Copied: projects/aop/trunk/asintegration-core (from rev 78832, projects/aop/trunk/asintegration)

Modified: projects/aop/trunk/asintegration-core/.classpath
===================================================================
--- projects/aop/trunk/asintegration/.classpath	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-core/.classpath	2008-09-25 13:39:14 UTC (rev 78853)
@@ -1,26 +1,27 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src/main"/>
-	<classpathentry kind="src" path="src/tests"/>
-	<classpathentry kind="lib" path="src/resources/tests"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/aop"/>
-	<classpathentry kind="lib" path="/thirdparty/javassist/lib/javassist.jar" sourcepath="/javassist"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/common-core/lib/jboss-common-core.jar" sourcepath="/thirdparty/jboss/common-core/lib/jboss-common-core-sources.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/integration/lib/jboss-classloading-spi.jar" sourcepath="/thirdparty/jboss/integration/lib/jboss-classloading-spi-sources.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs.jar" sourcepath="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs-sources.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-mdr/lib/jboss-mdr.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-vfs-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-core-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-structure-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-client-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-managed/lib/jboss-managed.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-cl/lib/jboss-classloader.jar"/>
-	<classpathentry kind="output" path="output/eclipse-classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main"/>
+	<classpathentry kind="src" path="src/tests"/>
+	<classpathentry kind="lib" path="src/resources/tests"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/aop"/>
+	<classpathentry kind="lib" path="/thirdparty/javassist/lib/javassist.jar" sourcepath="/javassist"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-core/lib/jboss-common-core.jar" sourcepath="/thirdparty/jboss/common-core/lib/jboss-common-core-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/integration/lib/jboss-classloading-spi.jar" sourcepath="/thirdparty/jboss/integration/lib/jboss-classloading-spi-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs.jar" sourcepath="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-mdr/lib/jboss-mdr.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-vfs-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-core-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-structure-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-client-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-managed/lib/jboss-managed.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-cl/lib/jboss-classloader.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/pluggable-instrumentor"/>
+	<classpathentry kind="output" path="output/eclipse-classes"/>
+</classpath>

Modified: projects/aop/trunk/asintegration-core/pom.xml
===================================================================
--- projects/aop/trunk/asintegration/pom.xml	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-core/pom.xml	2008-09-25 13:39:14 UTC (rev 78853)
@@ -7,10 +7,10 @@
     <version>2.0.0-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
-  <artifactId>jboss-aop-deployer</artifactId>
+  <artifactId>jboss-asintegration-core</artifactId>
   <packaging>jar</packaging>
-  <name>JBoss AOP AS Integration</name>
-  <description>JBoss AOP AS Integration</description>
+  <name>JBoss AOP AS Integration Core</name>
+  <description>JBoss AOP AS Integrationi Core</description>
   
   <build>
     <sourceDirectory>src/main/</sourceDirectory>

Modified: projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -25,18 +25,19 @@
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 import javassist.ClassPool;
 import javassist.scopedpool.ScopedClassPoolFactory;
 
 import javax.management.ObjectName;
+import javax.xml.parsers.ParserConfigurationException;
 
 import org.jboss.aop.AspectManager;
 import org.jboss.aop.AspectXmlLoader;
@@ -62,6 +63,7 @@
 import org.jboss.mx.util.ObjectNameFactory;
 import org.jboss.system.server.ServerConfig;
 import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
 
 /**
  * 
@@ -87,9 +89,13 @@
 
    // Attributes ---------------------------------------------------
 
-   boolean created = false;
+//   boolean created = false;
    protected File tmpClassesDir;
+   
+   /** True if the deprecated translator is enabled */
    protected boolean enableTransformer = false;
+   
+   /** True if the noveau translator is enabled */
    protected boolean enableLoadtimeWeaving = false;
    protected boolean suppressTransformationErrors = true;
    protected boolean suppressReferenceErrors = true;
@@ -105,26 +111,34 @@
    /**
     * The name of the file used to deploy the core aspects
     */
-   private String baseXml = "base-aop.xml";
+   private String baseXml;
    
-   //When running with JBoss 5 registration with MBeanServer happens after the service has been started
+   /** Whether we found and deployed baseXml */
+   private boolean deployedBaseXml;
+
+   /** Whether we should deploy baseXml or not */ 
+   private boolean useBaseXml;
+   
+   /** When running with JBoss 5 registration with MBeanServer happens after the service has been started */
    boolean registerHappensAfterStart;
-   boolean hasBeenStarted;
    
    /** The encapsulation of the integration */
    private JBossIntegration integration;
    
-   private AtomicBoolean started = new AtomicBoolean();
+   /** Whether this service was started */
+   private boolean started;
    
+   
+   /** The AspectManager managed by this service */
    private AspectManager manager;
    
    
+   
    // Static -------------------------------------------------------
 
    // Constructors -------------------------------------------------
    public AspectManagerServiceDelegate()
    {
-      
    }
 
    public void setBootstrapXml(String bootstrapXml)
@@ -209,10 +223,11 @@
            throws Exception
    {
       initIntegration();
-      if (hasBeenStarted)
+      if (started)
       {
          return;
       }
+      PortableAnnotationElement.setClosingDownManager(false);
       
       
       // Set a default tmp classes dir to the jboss tmp dir/aopclasses
@@ -242,114 +257,158 @@
       {
          attachTranslator();
       }
-      created = true;
       AspectManager.setClassLoaderScopingPolicy(integration.createAOPClassLoaderScopingPolicy());
 
-      bootstrapXml();
-      baseXml();
+      deployBootstrapXml();
+      deployBaseXml();
    }
    
    public void start() throws Exception
    {
-      started.set(true);
+      started = true;
    }
 
    public void stop()
    {
-      started.set(false);
+      started = false;
    }
    
    public void destroy()
    {
-      //TODO remove baseAop stuff
       try
       {
-         if (bootstrapXml != null)
+         PortableAnnotationElement.setClosingDownManager(true);
+         undeployBaseXml();
+      }
+      catch(Exception e)
+      {
+         log.error("Problem destroying AspectManager", e);
+      }
+      try
+      {
+         undeployBootstrapXml();
+      }
+      catch (Exception e)
+      {
+         log.error("Problem destroying AspectManager", e);
+      }
+   }
+   
+   public void deployBaseXml()
+   {
+      if (!deployedBaseXml && useBaseXml)
+      {
+         URL base = baseXmlUrl();
+         try
          {
-            InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
-            try
+            if (base != null)
             {
-               Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
-               AspectXmlLoader loader = new AspectXmlLoader();
-               loader.setManager(manager);
-               PortableAnnotationElement.setClosingDownManager(true);
-               loader.undeployXML(doc, null);
+               log.debug("Deploying base aspects " + base);
+               AspectXmlLoader.deployXML(base);
+               deployedBaseXml = true;
             }
-            finally
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Error loading " + baseXml + " file" + e);
+         }
+      }
+   }
+   
+   public void undeployBaseXml()
+   {
+      if (deployedBaseXml)
+      {
+         URL base = baseXmlUrl();
+         try
+         {
+            if (base != null)
             {
-               if (in != null)
-               {
-                  in.close();
-               }
+               log.debug("Undeploying base aspects " + base);
+               AspectXmlLoader.undeployXML(base);
             }
          }
+         catch (Exception e)
+         {
+            log.warn("Error loading " + baseXml + " file" + e);
+         }
+         deployedBaseXml = false;
       }
-      catch (Exception e)
+   }
+   
+   private URL baseXmlUrl()
+   {
+      if (baseXml == null || baseXml.trim().length() == 0)
       {
-         throw new RuntimeException("Problem destroying AspectManager", e);
+         return null;
       }
+
+      ClassLoader cl = Thread.currentThread().getContextClassLoader();
+      URL base = cl.getResource(baseXml);
+      if (base == null)
+      {
+         log.debug("Could not find " + baseXml + " file in the resources of " + cl);
+      }
+      return base;
    }
    
-   protected void baseXml()
+   private void deployBootstrapXml()
    {
-      if (baseXml == null)
+      try
       {
-         return;
+         Document doc = bootstrapXmlDocument();
+         if (doc != null)
+         {
+            AspectXmlLoader loader = new AspectXmlLoader();
+            loader.setManager(manager);
+            loader.deployXML(doc, null);
+         }
       }
-      baseXml(baseXml);
+      catch(Exception e)
+      {
+         throw new RuntimeException("Error deploying bootstrap xml", e);
+      }
    }
-
-   public void baseXml(String xml)
+   
+   private void undeployBootstrapXml()
    {
-      ClassLoader cl = Thread.currentThread().getContextClassLoader();
-      URL base = cl.getResource(xml);
       try
       {
-         if (base != null)
+         Document doc = bootstrapXmlDocument();
+         if (doc != null)
          {
-            AspectXmlLoader.deployXML(base);
+            AspectXmlLoader loader = new AspectXmlLoader();
+            loader.setManager(manager);
+            loader.undeployXML(doc, null);
          }
-         else
-         {
-            log.warn("Could not find " + xml + " file in the resources of " + cl);
-         }
       }
-      catch (Exception e)
+      catch(Exception e)
       {
-         System.out.println("Error loading " + xml + " file" + e);
+         log.warn("Error undeploying bootstrap xml", e);
       }
    }
+
    
-   public void bootstrapXml()
+   private Document bootstrapXmlDocument() throws IOException, SAXException, ParserConfigurationException
    {
-      try
+      if (bootstrapXml != null && bootstrapXml.trim().length() > 0)
       {
-         if (bootstrapXml != null && bootstrapXml.trim().length() > 0)
+         InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
+         try
          {
-            InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
-            try
+            Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
+            return doc;
+         }
+         finally
+         {
+            if (in != null)
             {
-               Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
-               AspectXmlLoader loader = new AspectXmlLoader();
-               loader.setManager(manager);
-               loader.deployXML(doc, null);
+               in.close();
             }
-            finally
-            {
-               if (in != null)
-               {
-                  in.close();
-               }
-            }
          }
       }
-      catch (Exception e)
-      {
-         // AutoGenerated
-         throw new RuntimeException("Problem starting AspectManager", e);
-      }
+      return null;
    }
-   
    protected void attachDeprecatedTranslator()
    {
       log.warn("EnableTransformer has been deprecated, please use EnableLoadtimeWeaving.  See docs for more details");
@@ -524,6 +583,35 @@
       AspectManager.optimize = verbose;
    }
 
+   /**
+    * Gets whether the base aspects are being deployed
+    */
+   public boolean getUseBaseXml()
+   {
+      return useBaseXml;
+   }
+
+   /**
+    * Set whether the base aspects should be deployed. If called against
+    * a running server, will deploy/undeploy the base aspects depending on the 
+    * value of the parameter 
+    */
+   public synchronized void setUseBaseXml(boolean useBaseXml)
+   {
+      if (started && useBaseXml != this.useBaseXml)
+      {
+         this.useBaseXml = useBaseXml;
+         if (useBaseXml)
+         {
+            deployBaseXml();
+         }
+         else
+         {
+            undeployBaseXml();
+         }
+      }
+   }
+
    public boolean getSuppressTransformationErrors()
    {
       return suppressTransformationErrors;
@@ -630,13 +718,13 @@
    {
       // Testsuite uses enableTransformer, we may be testing new loadtime features though.
 
-      if (enableLoadtimeWeaving)
+      if (this.enableTransformer == enableTransformer) return;
+      if (enableLoadtimeWeaving && enableTransformer)
       {
          log.warn("enabledLoadtimeWeaving alread set");
          return;
       }
-      if (this.enableTransformer == enableTransformer) return;
-      if (started.get() == true)
+      if (started)
       {
          if (enableTransformer)
          {
@@ -658,8 +746,12 @@
    public void setEnableLoadtimeWeaving(boolean enableTransformer)
    {
       if (this.enableLoadtimeWeaving == enableTransformer) return;
-      if (started.get() == true)
+      if (enableLoadtimeWeaving && enableTransformer)
       {
+         log.warn("enableTransformer already set");
+      }
+      if (started)
+      {
          if (enableTransformer)
          {
             attachTranslator();

Modified: projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/deployers/AbstractAspectManager.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AbstractAspectManager.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/deployers/AbstractAspectManager.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -410,10 +410,32 @@
 
    public void deployBaseAspects()
    {
-      delegate.baseXml(BASE_ASPECTS_XML);
+      delegate.deployBaseXml();
    }
 
+   public void undeployBaseAspects()
+   {
+      delegate.undeployBaseXml();
+   }
+
+
    /**
+    * @see org.jboss.aop.asintegration.core.AspectManagerServiceDelegate#getUseBaseXml()
+    */
+   public boolean getUseBaseXml()
+   {
+      return delegate.getUseBaseXml();
+   }
+
+   /**
+    * @see org.jboss.aop.asintegration.core.AspectManagerServiceDelegate#setUseBaseXml()
+    */
+   public synchronized void setUseBaseXml(boolean useBaseXml)
+   {
+      delegate.setUseBaseXml(useBaseXml);
+   }
+
+   /**
     * @return
     * @see java.lang.Object#toString()
     */

Modified: projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/deployers/JBossAspectLibrary.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/JBossAspectLibrary.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/deployers/JBossAspectLibrary.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -45,12 +45,9 @@
       this.aspectManager = aspectManagerBean;
    }
    
-   /**
-    * @throws Exception
-    * @see org.jboss.system.ServiceMBeanSupport#start()
-    */
    public void start() throws Exception
    {
+      System.out.println("\n\n!!! JBossAspectLibrary should be removed from AOP!!!\n\n");
       log.debug("Starting JBoss AspectLibrary");
       aspectManager.deployBaseAspects();
    }
@@ -58,6 +55,7 @@
    public void stop()
    {
       log.debug("Stopping JBoss AspectLibrary");
+      aspectManager.undeployBaseAspects();
    }
 
 }

Modified: projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/deployment/AbstractAspectManagerService.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AbstractAspectManagerService.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/deployment/AbstractAspectManagerService.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -56,6 +56,9 @@
    // Static -------------------------------------------------------
 
    // Constructors -------------------------------------------------
+   /**
+    * This constructor shouuld only get called when used in JBoss 4.x.x, not in JBoss 5.
+    */
    public AbstractAspectManagerService()
    {
       //Initialise the manager and delegate
@@ -66,13 +69,19 @@
       //This constructor shouuld only get called when used in JBoss 4.x.x, not in JBoss 5.
       //In JBoss 4 we need to maintain this field
       delegate.setAspectManagerMaintainAdvisorInterceptors(true);
+      
+      //Default 
+      delegate.setUseBaseXml(true);
    }
 
+   /**
+    * This constructor should only get called when used in JBoss 5 by JBossAspectLibrary.
+    */
    public AbstractAspectManagerService(AspectManagerServiceDelegate delegate)
    {
       this.delegate = delegate;
-//      this.registerHappensAfterStart = registerHappensAfterStart;
    }
+
    
    protected AspectManagerServiceDelegate createDelegate()
    {
@@ -321,4 +330,15 @@
    {
       delegate.setInstrumentor(instrumentor);
    }
+   
+   public boolean getUseBaseXml()
+   {
+      return delegate.getUseBaseXml();
+   }
+
+   public synchronized void setUseBaseXml(boolean useBaseXml)
+   {
+      delegate.setUseBaseXml(useBaseXml);
+   }
+
 }

Modified: projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/deployment/AbstractAspectManagerServiceMBean.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AbstractAspectManagerServiceMBean.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-core/src/main/org/jboss/aop/deployment/AbstractAspectManagerServiceMBean.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -126,6 +126,14 @@
    String getInstrumentor();
    
    void setInstrumentor(String instrumentor);
+
+   /**
+    * Whether or not tu use base-aop.xml
+    */
+   boolean getUseBaseXml();
    
-   
+   /**
+    * Whether or not tu use base-aop.xml
+    */
+   void setUseBaseXml(boolean useBaseXml);
 }

Copied: projects/aop/trunk/asintegration-jmx (from rev 78832, projects/aop/trunk/asintegration)

Modified: projects/aop/trunk/asintegration-jmx/.classpath
===================================================================
--- projects/aop/trunk/asintegration/.classpath	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-jmx/.classpath	2008-09-25 13:39:14 UTC (rev 78853)
@@ -1,26 +1,27 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src/main"/>
-	<classpathentry kind="src" path="src/tests"/>
-	<classpathentry kind="lib" path="src/resources/tests"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/aop"/>
-	<classpathentry kind="lib" path="/thirdparty/javassist/lib/javassist.jar" sourcepath="/javassist"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/common-core/lib/jboss-common-core.jar" sourcepath="/thirdparty/jboss/common-core/lib/jboss-common-core-sources.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/integration/lib/jboss-classloading-spi.jar" sourcepath="/thirdparty/jboss/integration/lib/jboss-classloading-spi-sources.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs.jar" sourcepath="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs-sources.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-mdr/lib/jboss-mdr.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-vfs-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-core-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-structure-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-client-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-managed/lib/jboss-managed.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-cl/lib/jboss-classloader.jar"/>
-	<classpathentry kind="output" path="output/eclipse-classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main"/>
+	<classpathentry kind="src" path="src/tests"/>
+	<classpathentry kind="lib" path="src/resources/tests"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/aop"/>
+	<classpathentry kind="lib" path="/thirdparty/javassist/lib/javassist.jar" sourcepath="/javassist"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-core/lib/jboss-common-core.jar" sourcepath="/thirdparty/jboss/common-core/lib/jboss-common-core-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/integration/lib/jboss-classloading-spi.jar" sourcepath="/thirdparty/jboss/integration/lib/jboss-classloading-spi-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs.jar" sourcepath="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-mdr/lib/jboss-mdr.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-vfs-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-core-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-structure-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-client-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-managed/lib/jboss-managed.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-cl/lib/jboss-classloader.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/pluggable-instrumentor"/>
+	<classpathentry kind="output" path="output/eclipse-classes"/>
+</classpath>

Modified: projects/aop/trunk/asintegration-jmx/pom.xml
===================================================================
--- projects/aop/trunk/asintegration/pom.xml	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-jmx/pom.xml	2008-09-25 13:39:14 UTC (rev 78853)
@@ -7,10 +7,10 @@
     <version>2.0.0-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
-  <artifactId>jboss-aop-deployer</artifactId>
+  <artifactId>jboss-asintegration-jmx</artifactId>
   <packaging>jar</packaging>
-  <name>JBoss AOP AS Integration</name>
-  <description>JBoss AOP AS Integration</description>
+  <name>JBoss AOP AS Integration JMX</name>
+  <description>JBoss AOP AS Integration JMX</description>
   
   <build>
     <sourceDirectory>src/main/</sourceDirectory>

Modified: projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -25,18 +25,19 @@
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 import javassist.ClassPool;
 import javassist.scopedpool.ScopedClassPoolFactory;
 
 import javax.management.ObjectName;
+import javax.xml.parsers.ParserConfigurationException;
 
 import org.jboss.aop.AspectManager;
 import org.jboss.aop.AspectXmlLoader;
@@ -62,6 +63,7 @@
 import org.jboss.mx.util.ObjectNameFactory;
 import org.jboss.system.server.ServerConfig;
 import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
 
 /**
  * 
@@ -87,9 +89,13 @@
 
    // Attributes ---------------------------------------------------
 
-   boolean created = false;
+//   boolean created = false;
    protected File tmpClassesDir;
+   
+   /** True if the deprecated translator is enabled */
    protected boolean enableTransformer = false;
+   
+   /** True if the noveau translator is enabled */
    protected boolean enableLoadtimeWeaving = false;
    protected boolean suppressTransformationErrors = true;
    protected boolean suppressReferenceErrors = true;
@@ -105,26 +111,34 @@
    /**
     * The name of the file used to deploy the core aspects
     */
-   private String baseXml = "base-aop.xml";
+   private String baseXml;
    
-   //When running with JBoss 5 registration with MBeanServer happens after the service has been started
+   /** Whether we found and deployed baseXml */
+   private boolean deployedBaseXml;
+
+   /** Whether we should deploy baseXml or not */ 
+   private boolean useBaseXml;
+   
+   /** When running with JBoss 5 registration with MBeanServer happens after the service has been started */
    boolean registerHappensAfterStart;
-   boolean hasBeenStarted;
    
    /** The encapsulation of the integration */
    private JBossIntegration integration;
    
-   private AtomicBoolean started = new AtomicBoolean();
+   /** Whether this service was started */
+   private boolean started;
    
+   
+   /** The AspectManager managed by this service */
    private AspectManager manager;
    
    
+   
    // Static -------------------------------------------------------
 
    // Constructors -------------------------------------------------
    public AspectManagerServiceDelegate()
    {
-      
    }
 
    public void setBootstrapXml(String bootstrapXml)
@@ -209,10 +223,11 @@
            throws Exception
    {
       initIntegration();
-      if (hasBeenStarted)
+      if (started)
       {
          return;
       }
+      PortableAnnotationElement.setClosingDownManager(false);
       
       
       // Set a default tmp classes dir to the jboss tmp dir/aopclasses
@@ -242,114 +257,158 @@
       {
          attachTranslator();
       }
-      created = true;
       AspectManager.setClassLoaderScopingPolicy(integration.createAOPClassLoaderScopingPolicy());
 
-      bootstrapXml();
-      baseXml();
+      deployBootstrapXml();
+      deployBaseXml();
    }
    
    public void start() throws Exception
    {
-      started.set(true);
+      started = true;
    }
 
    public void stop()
    {
-      started.set(false);
+      started = false;
    }
    
    public void destroy()
    {
-      //TODO remove baseAop stuff
       try
       {
-         if (bootstrapXml != null)
+         PortableAnnotationElement.setClosingDownManager(true);
+         undeployBaseXml();
+      }
+      catch(Exception e)
+      {
+         log.error("Problem destroying AspectManager", e);
+      }
+      try
+      {
+         undeployBootstrapXml();
+      }
+      catch (Exception e)
+      {
+         log.error("Problem destroying AspectManager", e);
+      }
+   }
+   
+   public void deployBaseXml()
+   {
+      if (!deployedBaseXml && useBaseXml)
+      {
+         URL base = baseXmlUrl();
+         try
          {
-            InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
-            try
+            if (base != null)
             {
-               Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
-               AspectXmlLoader loader = new AspectXmlLoader();
-               loader.setManager(manager);
-               PortableAnnotationElement.setClosingDownManager(true);
-               loader.undeployXML(doc, null);
+               log.debug("Deploying base aspects " + base);
+               AspectXmlLoader.deployXML(base);
+               deployedBaseXml = true;
             }
-            finally
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Error loading " + baseXml + " file" + e);
+         }
+      }
+   }
+   
+   public void undeployBaseXml()
+   {
+      if (deployedBaseXml)
+      {
+         URL base = baseXmlUrl();
+         try
+         {
+            if (base != null)
             {
-               if (in != null)
-               {
-                  in.close();
-               }
+               log.debug("Undeploying base aspects " + base);
+               AspectXmlLoader.undeployXML(base);
             }
          }
+         catch (Exception e)
+         {
+            log.warn("Error loading " + baseXml + " file" + e);
+         }
+         deployedBaseXml = false;
       }
-      catch (Exception e)
+   }
+   
+   private URL baseXmlUrl()
+   {
+      if (baseXml == null || baseXml.trim().length() == 0)
       {
-         throw new RuntimeException("Problem destroying AspectManager", e);
+         return null;
       }
+
+      ClassLoader cl = Thread.currentThread().getContextClassLoader();
+      URL base = cl.getResource(baseXml);
+      if (base == null)
+      {
+         log.debug("Could not find " + baseXml + " file in the resources of " + cl);
+      }
+      return base;
    }
    
-   protected void baseXml()
+   private void deployBootstrapXml()
    {
-      if (baseXml == null)
+      try
       {
-         return;
+         Document doc = bootstrapXmlDocument();
+         if (doc != null)
+         {
+            AspectXmlLoader loader = new AspectXmlLoader();
+            loader.setManager(manager);
+            loader.deployXML(doc, null);
+         }
       }
-      baseXml(baseXml);
+      catch(Exception e)
+      {
+         throw new RuntimeException("Error deploying bootstrap xml", e);
+      }
    }
-
-   public void baseXml(String xml)
+   
+   private void undeployBootstrapXml()
    {
-      ClassLoader cl = Thread.currentThread().getContextClassLoader();
-      URL base = cl.getResource(xml);
       try
       {
-         if (base != null)
+         Document doc = bootstrapXmlDocument();
+         if (doc != null)
          {
-            AspectXmlLoader.deployXML(base);
+            AspectXmlLoader loader = new AspectXmlLoader();
+            loader.setManager(manager);
+            loader.undeployXML(doc, null);
          }
-         else
-         {
-            log.warn("Could not find " + xml + " file in the resources of " + cl);
-         }
       }
-      catch (Exception e)
+      catch(Exception e)
       {
-         System.out.println("Error loading " + xml + " file" + e);
+         log.warn("Error undeploying bootstrap xml", e);
       }
    }
+
    
-   public void bootstrapXml()
+   private Document bootstrapXmlDocument() throws IOException, SAXException, ParserConfigurationException
    {
-      try
+      if (bootstrapXml != null && bootstrapXml.trim().length() > 0)
       {
-         if (bootstrapXml != null && bootstrapXml.trim().length() > 0)
+         InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
+         try
          {
-            InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
-            try
+            Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
+            return doc;
+         }
+         finally
+         {
+            if (in != null)
             {
-               Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
-               AspectXmlLoader loader = new AspectXmlLoader();
-               loader.setManager(manager);
-               loader.deployXML(doc, null);
+               in.close();
             }
-            finally
-            {
-               if (in != null)
-               {
-                  in.close();
-               }
-            }
          }
       }
-      catch (Exception e)
-      {
-         // AutoGenerated
-         throw new RuntimeException("Problem starting AspectManager", e);
-      }
+      return null;
    }
-   
    protected void attachDeprecatedTranslator()
    {
       log.warn("EnableTransformer has been deprecated, please use EnableLoadtimeWeaving.  See docs for more details");
@@ -524,6 +583,35 @@
       AspectManager.optimize = verbose;
    }
 
+   /**
+    * Gets whether the base aspects are being deployed
+    */
+   public boolean getUseBaseXml()
+   {
+      return useBaseXml;
+   }
+
+   /**
+    * Set whether the base aspects should be deployed. If called against
+    * a running server, will deploy/undeploy the base aspects depending on the 
+    * value of the parameter 
+    */
+   public synchronized void setUseBaseXml(boolean useBaseXml)
+   {
+      if (started && useBaseXml != this.useBaseXml)
+      {
+         this.useBaseXml = useBaseXml;
+         if (useBaseXml)
+         {
+            deployBaseXml();
+         }
+         else
+         {
+            undeployBaseXml();
+         }
+      }
+   }
+
    public boolean getSuppressTransformationErrors()
    {
       return suppressTransformationErrors;
@@ -630,13 +718,13 @@
    {
       // Testsuite uses enableTransformer, we may be testing new loadtime features though.
 
-      if (enableLoadtimeWeaving)
+      if (this.enableTransformer == enableTransformer) return;
+      if (enableLoadtimeWeaving && enableTransformer)
       {
          log.warn("enabledLoadtimeWeaving alread set");
          return;
       }
-      if (this.enableTransformer == enableTransformer) return;
-      if (started.get() == true)
+      if (started)
       {
          if (enableTransformer)
          {
@@ -658,8 +746,12 @@
    public void setEnableLoadtimeWeaving(boolean enableTransformer)
    {
       if (this.enableLoadtimeWeaving == enableTransformer) return;
-      if (started.get() == true)
+      if (enableLoadtimeWeaving && enableTransformer)
       {
+         log.warn("enableTransformer already set");
+      }
+      if (started)
+      {
          if (enableTransformer)
          {
             attachTranslator();

Modified: projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/deployers/AbstractAspectManager.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AbstractAspectManager.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/deployers/AbstractAspectManager.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -410,10 +410,32 @@
 
    public void deployBaseAspects()
    {
-      delegate.baseXml(BASE_ASPECTS_XML);
+      delegate.deployBaseXml();
    }
 
+   public void undeployBaseAspects()
+   {
+      delegate.undeployBaseXml();
+   }
+
+
    /**
+    * @see org.jboss.aop.asintegration.core.AspectManagerServiceDelegate#getUseBaseXml()
+    */
+   public boolean getUseBaseXml()
+   {
+      return delegate.getUseBaseXml();
+   }
+
+   /**
+    * @see org.jboss.aop.asintegration.core.AspectManagerServiceDelegate#setUseBaseXml()
+    */
+   public synchronized void setUseBaseXml(boolean useBaseXml)
+   {
+      delegate.setUseBaseXml(useBaseXml);
+   }
+
+   /**
     * @return
     * @see java.lang.Object#toString()
     */

Modified: projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/deployers/JBossAspectLibrary.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/JBossAspectLibrary.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/deployers/JBossAspectLibrary.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -45,12 +45,9 @@
       this.aspectManager = aspectManagerBean;
    }
    
-   /**
-    * @throws Exception
-    * @see org.jboss.system.ServiceMBeanSupport#start()
-    */
    public void start() throws Exception
    {
+      System.out.println("\n\n!!! JBossAspectLibrary should be removed from AOP!!!\n\n");
       log.debug("Starting JBoss AspectLibrary");
       aspectManager.deployBaseAspects();
    }
@@ -58,6 +55,7 @@
    public void stop()
    {
       log.debug("Stopping JBoss AspectLibrary");
+      aspectManager.undeployBaseAspects();
    }
 
 }

Modified: projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/deployment/AbstractAspectManagerService.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AbstractAspectManagerService.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/deployment/AbstractAspectManagerService.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -56,6 +56,9 @@
    // Static -------------------------------------------------------
 
    // Constructors -------------------------------------------------
+   /**
+    * This constructor shouuld only get called when used in JBoss 4.x.x, not in JBoss 5.
+    */
    public AbstractAspectManagerService()
    {
       //Initialise the manager and delegate
@@ -66,13 +69,19 @@
       //This constructor shouuld only get called when used in JBoss 4.x.x, not in JBoss 5.
       //In JBoss 4 we need to maintain this field
       delegate.setAspectManagerMaintainAdvisorInterceptors(true);
+      
+      //Default 
+      delegate.setUseBaseXml(true);
    }
 
+   /**
+    * This constructor should only get called when used in JBoss 5 by JBossAspectLibrary.
+    */
    public AbstractAspectManagerService(AspectManagerServiceDelegate delegate)
    {
       this.delegate = delegate;
-//      this.registerHappensAfterStart = registerHappensAfterStart;
    }
+
    
    protected AspectManagerServiceDelegate createDelegate()
    {
@@ -321,4 +330,15 @@
    {
       delegate.setInstrumentor(instrumentor);
    }
+   
+   public boolean getUseBaseXml()
+   {
+      return delegate.getUseBaseXml();
+   }
+
+   public synchronized void setUseBaseXml(boolean useBaseXml)
+   {
+      delegate.setUseBaseXml(useBaseXml);
+   }
+
 }

Modified: projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/deployment/AbstractAspectManagerServiceMBean.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AbstractAspectManagerServiceMBean.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-jmx/src/main/org/jboss/aop/deployment/AbstractAspectManagerServiceMBean.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -126,6 +126,14 @@
    String getInstrumentor();
    
    void setInstrumentor(String instrumentor);
+
+   /**
+    * Whether or not tu use base-aop.xml
+    */
+   boolean getUseBaseXml();
    
-   
+   /**
+    * Whether or not tu use base-aop.xml
+    */
+   void setUseBaseXml(boolean useBaseXml);
 }

Copied: projects/aop/trunk/asintegration-mc (from rev 78832, projects/aop/trunk/asintegration)

Modified: projects/aop/trunk/asintegration-mc/.classpath
===================================================================
--- projects/aop/trunk/asintegration/.classpath	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-mc/.classpath	2008-09-25 13:39:14 UTC (rev 78853)
@@ -1,26 +1,27 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
-	<classpathentry kind="src" path="src/main"/>
-	<classpathentry kind="src" path="src/tests"/>
-	<classpathentry kind="lib" path="src/resources/tests"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-	<classpathentry combineaccessrules="false" kind="src" path="/aop"/>
-	<classpathentry kind="lib" path="/thirdparty/javassist/lib/javassist.jar" sourcepath="/javassist"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/common-core/lib/jboss-common-core.jar" sourcepath="/thirdparty/jboss/common-core/lib/jboss-common-core-sources.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/integration/lib/jboss-classloading-spi.jar" sourcepath="/thirdparty/jboss/integration/lib/jboss-classloading-spi-sources.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs.jar" sourcepath="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs-sources.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-mdr/lib/jboss-mdr.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-vfs-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-core-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-structure-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-client-spi.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-managed/lib/jboss-managed.jar"/>
-	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-cl/lib/jboss-classloader.jar"/>
-	<classpathentry kind="output" path="output/eclipse-classes"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main"/>
+	<classpathentry kind="src" path="src/tests"/>
+	<classpathentry kind="lib" path="src/resources/tests"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/aop"/>
+	<classpathentry kind="lib" path="/thirdparty/javassist/lib/javassist.jar" sourcepath="/javassist"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-core/lib/jboss-common-core.jar" sourcepath="/thirdparty/jboss/common-core/lib/jboss-common-core-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/junit/lib/junit.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/common-logging-spi/lib/jboss-logging-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-jmx.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jbossas/core-libs/lib/jboss-system.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/integration/lib/jboss-classloading-spi.jar" sourcepath="/thirdparty/jboss/integration/lib/jboss-classloading-spi-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs.jar" sourcepath="/thirdparty/jboss/jboss-vfs/lib/jboss-vfs-sources.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-mdr/lib/jboss-mdr.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-vfs-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-core-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-structure-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-deployers/lib/jboss-deployers-client-spi.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-managed/lib/jboss-managed.jar"/>
+	<classpathentry kind="lib" path="/thirdparty/jboss/jboss-cl/lib/jboss-classloader.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/pluggable-instrumentor"/>
+	<classpathentry kind="output" path="output/eclipse-classes"/>
+</classpath>

Modified: projects/aop/trunk/asintegration-mc/pom.xml
===================================================================
--- projects/aop/trunk/asintegration/pom.xml	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-mc/pom.xml	2008-09-25 13:39:14 UTC (rev 78853)
@@ -7,10 +7,10 @@
     <version>2.0.0-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
-  <artifactId>jboss-aop-deployer</artifactId>
+  <artifactId>jboss-asintegration-mc</artifactId>
   <packaging>jar</packaging>
-  <name>JBoss AOP AS Integration</name>
-  <description>JBoss AOP AS Integration</description>
+  <name>JBoss AOP AS Integration MC</name>
+  <description>JBoss AOP AS Integration MC</description>
   
   <build>
     <sourceDirectory>src/main/</sourceDirectory>

Modified: projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/asintegration/core/AspectManagerServiceDelegate.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -25,18 +25,19 @@
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
-import java.util.concurrent.atomic.AtomicBoolean;
 
 import javassist.ClassPool;
 import javassist.scopedpool.ScopedClassPoolFactory;
 
 import javax.management.ObjectName;
+import javax.xml.parsers.ParserConfigurationException;
 
 import org.jboss.aop.AspectManager;
 import org.jboss.aop.AspectXmlLoader;
@@ -62,6 +63,7 @@
 import org.jboss.mx.util.ObjectNameFactory;
 import org.jboss.system.server.ServerConfig;
 import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
 
 /**
  * 
@@ -87,9 +89,13 @@
 
    // Attributes ---------------------------------------------------
 
-   boolean created = false;
+//   boolean created = false;
    protected File tmpClassesDir;
+   
+   /** True if the deprecated translator is enabled */
    protected boolean enableTransformer = false;
+   
+   /** True if the noveau translator is enabled */
    protected boolean enableLoadtimeWeaving = false;
    protected boolean suppressTransformationErrors = true;
    protected boolean suppressReferenceErrors = true;
@@ -105,26 +111,34 @@
    /**
     * The name of the file used to deploy the core aspects
     */
-   private String baseXml = "base-aop.xml";
+   private String baseXml;
    
-   //When running with JBoss 5 registration with MBeanServer happens after the service has been started
+   /** Whether we found and deployed baseXml */
+   private boolean deployedBaseXml;
+
+   /** Whether we should deploy baseXml or not */ 
+   private boolean useBaseXml;
+   
+   /** When running with JBoss 5 registration with MBeanServer happens after the service has been started */
    boolean registerHappensAfterStart;
-   boolean hasBeenStarted;
    
    /** The encapsulation of the integration */
    private JBossIntegration integration;
    
-   private AtomicBoolean started = new AtomicBoolean();
+   /** Whether this service was started */
+   private boolean started;
    
+   
+   /** The AspectManager managed by this service */
    private AspectManager manager;
    
    
+   
    // Static -------------------------------------------------------
 
    // Constructors -------------------------------------------------
    public AspectManagerServiceDelegate()
    {
-      
    }
 
    public void setBootstrapXml(String bootstrapXml)
@@ -209,10 +223,11 @@
            throws Exception
    {
       initIntegration();
-      if (hasBeenStarted)
+      if (started)
       {
          return;
       }
+      PortableAnnotationElement.setClosingDownManager(false);
       
       
       // Set a default tmp classes dir to the jboss tmp dir/aopclasses
@@ -242,114 +257,158 @@
       {
          attachTranslator();
       }
-      created = true;
       AspectManager.setClassLoaderScopingPolicy(integration.createAOPClassLoaderScopingPolicy());
 
-      bootstrapXml();
-      baseXml();
+      deployBootstrapXml();
+      deployBaseXml();
    }
    
    public void start() throws Exception
    {
-      started.set(true);
+      started = true;
    }
 
    public void stop()
    {
-      started.set(false);
+      started = false;
    }
    
    public void destroy()
    {
-      //TODO remove baseAop stuff
       try
       {
-         if (bootstrapXml != null)
+         PortableAnnotationElement.setClosingDownManager(true);
+         undeployBaseXml();
+      }
+      catch(Exception e)
+      {
+         log.error("Problem destroying AspectManager", e);
+      }
+      try
+      {
+         undeployBootstrapXml();
+      }
+      catch (Exception e)
+      {
+         log.error("Problem destroying AspectManager", e);
+      }
+   }
+   
+   public void deployBaseXml()
+   {
+      if (!deployedBaseXml && useBaseXml)
+      {
+         URL base = baseXmlUrl();
+         try
          {
-            InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
-            try
+            if (base != null)
             {
-               Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
-               AspectXmlLoader loader = new AspectXmlLoader();
-               loader.setManager(manager);
-               PortableAnnotationElement.setClosingDownManager(true);
-               loader.undeployXML(doc, null);
+               log.debug("Deploying base aspects " + base);
+               AspectXmlLoader.deployXML(base);
+               deployedBaseXml = true;
             }
-            finally
+         }
+         catch (Exception e)
+         {
+            throw new RuntimeException("Error loading " + baseXml + " file" + e);
+         }
+      }
+   }
+   
+   public void undeployBaseXml()
+   {
+      if (deployedBaseXml)
+      {
+         URL base = baseXmlUrl();
+         try
+         {
+            if (base != null)
             {
-               if (in != null)
-               {
-                  in.close();
-               }
+               log.debug("Undeploying base aspects " + base);
+               AspectXmlLoader.undeployXML(base);
             }
          }
+         catch (Exception e)
+         {
+            log.warn("Error loading " + baseXml + " file" + e);
+         }
+         deployedBaseXml = false;
       }
-      catch (Exception e)
+   }
+   
+   private URL baseXmlUrl()
+   {
+      if (baseXml == null || baseXml.trim().length() == 0)
       {
-         throw new RuntimeException("Problem destroying AspectManager", e);
+         return null;
       }
+
+      ClassLoader cl = Thread.currentThread().getContextClassLoader();
+      URL base = cl.getResource(baseXml);
+      if (base == null)
+      {
+         log.debug("Could not find " + baseXml + " file in the resources of " + cl);
+      }
+      return base;
    }
    
-   protected void baseXml()
+   private void deployBootstrapXml()
    {
-      if (baseXml == null)
+      try
       {
-         return;
+         Document doc = bootstrapXmlDocument();
+         if (doc != null)
+         {
+            AspectXmlLoader loader = new AspectXmlLoader();
+            loader.setManager(manager);
+            loader.deployXML(doc, null);
+         }
       }
-      baseXml(baseXml);
+      catch(Exception e)
+      {
+         throw new RuntimeException("Error deploying bootstrap xml", e);
+      }
    }
-
-   public void baseXml(String xml)
+   
+   private void undeployBootstrapXml()
    {
-      ClassLoader cl = Thread.currentThread().getContextClassLoader();
-      URL base = cl.getResource(xml);
       try
       {
-         if (base != null)
+         Document doc = bootstrapXmlDocument();
+         if (doc != null)
          {
-            AspectXmlLoader.deployXML(base);
+            AspectXmlLoader loader = new AspectXmlLoader();
+            loader.setManager(manager);
+            loader.undeployXML(doc, null);
          }
-         else
-         {
-            log.warn("Could not find " + xml + " file in the resources of " + cl);
-         }
       }
-      catch (Exception e)
+      catch(Exception e)
       {
-         System.out.println("Error loading " + xml + " file" + e);
+         log.warn("Error undeploying bootstrap xml", e);
       }
    }
+
    
-   public void bootstrapXml()
+   private Document bootstrapXmlDocument() throws IOException, SAXException, ParserConfigurationException
    {
-      try
+      if (bootstrapXml != null && bootstrapXml.trim().length() > 0)
       {
-         if (bootstrapXml != null && bootstrapXml.trim().length() > 0)
+         InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
+         try
          {
-            InputStream in = new BufferedInputStream(new ByteArrayInputStream(bootstrapXml.getBytes()));
-            try
+            Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
+            return doc;
+         }
+         finally
+         {
+            if (in != null)
             {
-               Document doc = AspectXmlLoader.loadDocument(new BufferedInputStream(in));
-               AspectXmlLoader loader = new AspectXmlLoader();
-               loader.setManager(manager);
-               loader.deployXML(doc, null);
+               in.close();
             }
-            finally
-            {
-               if (in != null)
-               {
-                  in.close();
-               }
-            }
          }
       }
-      catch (Exception e)
-      {
-         // AutoGenerated
-         throw new RuntimeException("Problem starting AspectManager", e);
-      }
+      return null;
    }
-   
    protected void attachDeprecatedTranslator()
    {
       log.warn("EnableTransformer has been deprecated, please use EnableLoadtimeWeaving.  See docs for more details");
@@ -524,6 +583,35 @@
       AspectManager.optimize = verbose;
    }
 
+   /**
+    * Gets whether the base aspects are being deployed
+    */
+   public boolean getUseBaseXml()
+   {
+      return useBaseXml;
+   }
+
+   /**
+    * Set whether the base aspects should be deployed. If called against
+    * a running server, will deploy/undeploy the base aspects depending on the 
+    * value of the parameter 
+    */
+   public synchronized void setUseBaseXml(boolean useBaseXml)
+   {
+      if (started && useBaseXml != this.useBaseXml)
+      {
+         this.useBaseXml = useBaseXml;
+         if (useBaseXml)
+         {
+            deployBaseXml();
+         }
+         else
+         {
+            undeployBaseXml();
+         }
+      }
+   }
+
    public boolean getSuppressTransformationErrors()
    {
       return suppressTransformationErrors;
@@ -630,13 +718,13 @@
    {
       // Testsuite uses enableTransformer, we may be testing new loadtime features though.
 
-      if (enableLoadtimeWeaving)
+      if (this.enableTransformer == enableTransformer) return;
+      if (enableLoadtimeWeaving && enableTransformer)
       {
          log.warn("enabledLoadtimeWeaving alread set");
          return;
       }
-      if (this.enableTransformer == enableTransformer) return;
-      if (started.get() == true)
+      if (started)
       {
          if (enableTransformer)
          {
@@ -658,8 +746,12 @@
    public void setEnableLoadtimeWeaving(boolean enableTransformer)
    {
       if (this.enableLoadtimeWeaving == enableTransformer) return;
-      if (started.get() == true)
+      if (enableLoadtimeWeaving && enableTransformer)
       {
+         log.warn("enableTransformer already set");
+      }
+      if (started)
+      {
          if (enableTransformer)
          {
             attachTranslator();

Modified: projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/deployers/AbstractAspectManager.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/AbstractAspectManager.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/deployers/AbstractAspectManager.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -410,10 +410,32 @@
 
    public void deployBaseAspects()
    {
-      delegate.baseXml(BASE_ASPECTS_XML);
+      delegate.deployBaseXml();
    }
 
+   public void undeployBaseAspects()
+   {
+      delegate.undeployBaseXml();
+   }
+
+
    /**
+    * @see org.jboss.aop.asintegration.core.AspectManagerServiceDelegate#getUseBaseXml()
+    */
+   public boolean getUseBaseXml()
+   {
+      return delegate.getUseBaseXml();
+   }
+
+   /**
+    * @see org.jboss.aop.asintegration.core.AspectManagerServiceDelegate#setUseBaseXml()
+    */
+   public synchronized void setUseBaseXml(boolean useBaseXml)
+   {
+      delegate.setUseBaseXml(useBaseXml);
+   }
+
+   /**
     * @return
     * @see java.lang.Object#toString()
     */

Modified: projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/deployers/JBossAspectLibrary.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployers/JBossAspectLibrary.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/deployers/JBossAspectLibrary.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -45,12 +45,9 @@
       this.aspectManager = aspectManagerBean;
    }
    
-   /**
-    * @throws Exception
-    * @see org.jboss.system.ServiceMBeanSupport#start()
-    */
    public void start() throws Exception
    {
+      System.out.println("\n\n!!! JBossAspectLibrary should be removed from AOP!!!\n\n");
       log.debug("Starting JBoss AspectLibrary");
       aspectManager.deployBaseAspects();
    }
@@ -58,6 +55,7 @@
    public void stop()
    {
       log.debug("Stopping JBoss AspectLibrary");
+      aspectManager.undeployBaseAspects();
    }
 
 }

Modified: projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/deployment/AbstractAspectManagerService.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AbstractAspectManagerService.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/deployment/AbstractAspectManagerService.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -56,6 +56,9 @@
    // Static -------------------------------------------------------
 
    // Constructors -------------------------------------------------
+   /**
+    * This constructor shouuld only get called when used in JBoss 4.x.x, not in JBoss 5.
+    */
    public AbstractAspectManagerService()
    {
       //Initialise the manager and delegate
@@ -66,13 +69,19 @@
       //This constructor shouuld only get called when used in JBoss 4.x.x, not in JBoss 5.
       //In JBoss 4 we need to maintain this field
       delegate.setAspectManagerMaintainAdvisorInterceptors(true);
+      
+      //Default 
+      delegate.setUseBaseXml(true);
    }
 
+   /**
+    * This constructor should only get called when used in JBoss 5 by JBossAspectLibrary.
+    */
    public AbstractAspectManagerService(AspectManagerServiceDelegate delegate)
    {
       this.delegate = delegate;
-//      this.registerHappensAfterStart = registerHappensAfterStart;
    }
+
    
    protected AspectManagerServiceDelegate createDelegate()
    {
@@ -321,4 +330,15 @@
    {
       delegate.setInstrumentor(instrumentor);
    }
+   
+   public boolean getUseBaseXml()
+   {
+      return delegate.getUseBaseXml();
+   }
+
+   public synchronized void setUseBaseXml(boolean useBaseXml)
+   {
+      delegate.setUseBaseXml(useBaseXml);
+   }
+
 }

Modified: projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/deployment/AbstractAspectManagerServiceMBean.java
===================================================================
--- projects/aop/trunk/asintegration/src/main/org/jboss/aop/deployment/AbstractAspectManagerServiceMBean.java	2008-09-24 16:03:05 UTC (rev 78832)
+++ projects/aop/trunk/asintegration-mc/src/main/org/jboss/aop/deployment/AbstractAspectManagerServiceMBean.java	2008-09-25 13:39:14 UTC (rev 78853)
@@ -126,6 +126,14 @@
    String getInstrumentor();
    
    void setInstrumentor(String instrumentor);
+
+   /**
+    * Whether or not tu use base-aop.xml
+    */
+   boolean getUseBaseXml();
    
-   
+   /**
+    * Whether or not tu use base-aop.xml
+    */
+   void setUseBaseXml(boolean useBaseXml);
 }




More information about the jboss-cvs-commits mailing list