[jboss-cvs] JBossAS SVN: r61194 - in projects/microcontainer/trunk: aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jmx and 19 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 7 09:36:25 EST 2007


Author: kabir.khan at jboss.com
Date: 2007-03-07 09:36:24 -0500 (Wed, 07 Mar 2007)
New Revision: 61194

Added:
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jmx/JMXLifecycleCallback.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jndi/JndiLifecycleCallback.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AbstractBinding.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBeanMetaDataUtil.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/LifecycleBinding.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AnnotationDependencyBuilderListItem.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AspectDependencyBuilderListItem.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/LifecycleAspectDependencyBuilderListItem.java
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackTestCaseNotAutomatic.xml
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackTestCaseNotAutomatic.xml
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/NonDefaultMethodsLifecycleCallbackTestCaseNotAutomatic.xml
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/AspectManagerBean.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/LifecycleCallback.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/LifecycleCallbackWithBeanDependency.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/NonDefaultMethodsLifecycleCallback.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/SimpleLifecycleCallback.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackWithDependencyTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/NonDefaultMethodsLifecycleCallbackTestCase.java
   projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/spi/DependencyBuilderListItem.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractLifecycleCallbackMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/LifecycleCallbackMetaData.java
Removed:
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/LifecycleAspectTestCaseNotAutomatic.xml
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/LifecycleInterceptor.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/LifecycleAspectTestCase.java
Modified:
   projects/microcontainer/trunk/aop-mc-int/.classpath
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jmx/JMXIntroduction.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jndi/JndiIntroduction.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/Aspect.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBeanMetaDataFactory.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBinding.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/ConfigureLifecycleBeanMetaDataFactory.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/CreateLifecycleBeanMetaDataFactory.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/DescribeLifecycleBeanMetaDataFactory.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/InstallLifecycleBeanMetaDataFactory.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/InstantiateLifecycleBeanMetaDataFactory.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/LifecycleBeanMetaDataFactory.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/StartLifecycleBeanMetaDataFactory.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/xml/AOPBeansSchemaInitializer.java
   projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java
   projects/microcontainer/trunk/aop-mc-int/src/resources/schema/aop-beans_1_0.xsd
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JMXLifecycleTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JndiLifeCycleTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/LifecycleTestCaseNotAutomatic.xml
   projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/MultipleLifecycleTestCase.xml
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/AspectMCAllTestSuite.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/LifecycleTestCase.java
   projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/MultipleLifecycleTestCase.java
   projects/microcontainer/trunk/build/build-thirdparty.xml
   projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java
   projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/BasicClassAdapter.java
   projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/dependency/AbstractDependencyBuilder.java
   projects/microcontainer/trunk/kernel/
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractBeanMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/BeanMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java
Log:
[JBMICROCONT-154] Add improved lifecycle events. They are now callbacks instead of interceptors, and don't need introductions.

Modified: projects/microcontainer/trunk/aop-mc-int/.classpath
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/.classpath	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/.classpath	2007-03-07 14:36:24 UTC (rev 61194)
@@ -18,5 +18,6 @@
 	<classpathentry kind="lib" path="/thirdparty/jboss/jbossxb/lib/jboss-xml-binding.jar" sourcepath="/thirdparty/jboss/jbossxb/lib/jboss-xml-binding-sources.jar"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/test/lib/jboss-test.jar" sourcepath="/thirdparty/jboss/test/lib/jboss-test-src.zip"/>
 	<classpathentry kind="lib" path="/thirdparty/jboss/aop/lib/jboss-aop-jdk50.jar" sourcepath="/thirdparty/jboss/aop/lib/jboss-aop-src.zip"/>
+	<classpathentry kind="lib" path="/thirdparty/javassist/lib/javassist.jar"/>
 	<classpathentry kind="output" path="output/eclipse-classes"/>
 </classpath>

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jmx/JMXIntroduction.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jmx/JMXIntroduction.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jmx/JMXIntroduction.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -40,6 +40,7 @@
  * or even the basic xml parsing. 
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision$
+ * @deprecated Should use JMXLifecycleCallback instead
  */
 public class JMXIntroduction implements Interceptor
 {

Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jmx/JMXLifecycleCallback.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jmx/JMXLifecycleCallback.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jmx/JMXLifecycleCallback.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,119 @@
+/*
+* 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.microcontainer.aspects.jmx;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.logging.Logger;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JMXLifecycleCallback
+{
+   private static final Logger log = Logger.getLogger(JMXLifecycleCallback.class);
+   private MBeanServer server;
+   
+   public void setMbeanServer(MBeanServer server)
+   {
+      this.server = server;
+   }
+ 
+   public void install(KernelControllerContext context) throws Exception
+   {
+      validateServer();
+      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));
+      server.registerMBean(mbean, objectName);
+      log.info("Registered MBean " + objectName);
+   }
+   
+   public void uninstall(KernelControllerContext context) throws Exception
+   {
+      validateServer();
+      JMX jmx = readJmxAnnotation(context);
+      ObjectName objectName = createObjectName(context, jmx); 
+
+      log.info("Unregistering MBean " + objectName);
+      server.unregisterMBean(objectName);
+   }
+   
+   private void validateServer()
+   {
+      if (server == null)
+      {
+         throw new RuntimeException("No MBeanServer was injected");
+      }
+   }
+   
+   private JMX readJmxAnnotation(KernelControllerContext context) throws Exception
+   {
+      if (context.getMetaData() != null)
+      {
+         return context.getMetaData().getAnnotation(JMX.class);
+      }
+      return null;
+   }
+   
+   private ObjectName createObjectName(KernelControllerContext 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("test:name='" + name + "'");            
+         }
+      }
+      
+      return objectName;
+   }
+}

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jndi/JndiIntroduction.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jndi/JndiIntroduction.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jndi/JndiIntroduction.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -40,6 +40,7 @@
  * 
  * @author Scott.Stark at jboss.org
  * @version $Revision: 46386 $
+ * @deprecated Should use JndiLifecycleCallback instead
  */
 public class JndiIntroduction implements Interceptor
 {

Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jndi/JndiLifecycleCallback.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jndi/JndiLifecycleCallback.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/aspects/jndi/JndiLifecycleCallback.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,180 @@
+/*
+* 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.microcontainer.aspects.jndi;
+
+import java.util.Properties;
+
+import javax.management.ObjectName;
+import javax.management.StandardMBean;
+import javax.naming.InitialContext;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.aop.microcontainer.aspects.jmx.JMX;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.logging.Logger;
+import org.jboss.util.naming.Util;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class JndiLifecycleCallback
+{
+   private static final Logger log = Logger.getLogger(JndiLifecycleCallback.class);
+   private Properties env;
+
+   public String getName()
+   {
+      return getClass().getName();
+   }
+ 
+   /**
+    * Get the InitialContext properties to use for binding/unbinding
+    * @return the InitialContext ctor env
+    */
+   public Properties getEnv()
+   {
+      return env;
+   }
+
+   /**
+    * Set the InitialContext properties to use for binding/unbinding
+    * @param env - the InitialContext ctor env
+    */
+   public void setEnv(Properties env)
+   {
+      this.env = env;
+   }
+
+   /**
+    * Bind the target on setKernelControllerContext, unbind on any other method provided that
+    * the invocation has a JndiBinding annotation.
+    */
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      MethodInvocation mi = (MethodInvocation) invocation;
+      KernelControllerContext context = (KernelControllerContext) mi.getArguments()[0];
+
+      boolean trace = log.isTraceEnabled();
+      JndiBinding bindingInfo = (JndiBinding) invocation.resolveClassAnnotation(JndiBinding.class);
+      if( trace )
+         log.trace("Checking method: "+mi.getMethod()+", bindingInfo: "+bindingInfo);
+      // If this is the setKernelControllerContext callback, bind the target into jndi
+      if ("setKernelControllerContext".equals(mi.getMethod().getName()) && bindingInfo != null)
+      {
+         InitialContext ctx = new InitialContext(env);
+         Object target = context.getTarget();
+         Util.bind(ctx, bindingInfo.name(), target);
+         if( trace )
+            log.trace("Bound to: "+bindingInfo.name());
+         String[] aliases = bindingInfo.aliases();
+         if( aliases != null )
+         {
+            for(String name : aliases)
+            {
+               Util.bind(ctx, name, target);               
+               if( trace )
+                  log.trace("Bound to alias: "+bindingInfo.name());
+            }
+         }
+      }
+      // If this is the unsetKernelControllerContext callback, unbind the target
+      else if( bindingInfo != null )
+      {
+         InitialContext ctx = new InitialContext(env);
+         Util.unbind(ctx, bindingInfo.name());
+         if( trace )
+            log.trace("Unbound: "+bindingInfo.name());
+         String[] aliases = bindingInfo.aliases();
+         if( aliases != null )
+         {
+            for(String name : aliases)
+            {
+               Util.unbind(ctx, name);               
+               if( trace )
+                  log.trace("Unbound alias: "+bindingInfo.name());
+            }
+         }
+      }
+      else if ( trace )
+      {
+         log.trace("Ignoring null binding info");
+      }
+
+      return null;
+   }
+
+   public void install(KernelControllerContext context) throws Exception
+   {
+      JndiBinding bindingInfo = readJndiAnnotation(context);
+      boolean trace = log.isTraceEnabled();
+      if( trace )
+         log.trace("Binding into JNDI: " + context.getName() + ", bindingInfo: " + bindingInfo);
+      // If this is the setKernelControllerContext callback, bind the target into jndi
+      InitialContext ctx = new InitialContext(env);
+      Object target = context.getTarget();
+      Util.bind(ctx, bindingInfo.name(), target);
+      if( trace )
+         log.trace("Bound to: "+bindingInfo.name());
+      String[] aliases = bindingInfo.aliases();
+      if( aliases != null )
+      {
+         for(String name : aliases)
+         {
+            Util.bind(ctx, name, target);               
+            if( trace )
+               log.trace("Bound to alias: "+bindingInfo.name());
+         }
+      }
+   }
+   
+   public void uninstall(KernelControllerContext context) throws Exception
+   {
+      JndiBinding bindingInfo = readJndiAnnotation(context);
+      boolean trace = log.isTraceEnabled();
+      InitialContext ctx = new InitialContext(env);
+      Util.unbind(ctx, bindingInfo.name());
+      if( trace )
+         log.trace("Unbound: "+bindingInfo.name());
+      String[] aliases = bindingInfo.aliases();
+      if( aliases != null )
+      {
+         for(String name : aliases)
+         {
+            Util.unbind(ctx, name);               
+            if( trace )
+               log.trace("Unbound alias: "+bindingInfo.name());
+         }
+      }
+   }
+   
+   private JndiBinding readJndiAnnotation(KernelControllerContext context)
+   {
+      if (context.getMetaData() != null)
+      {
+         return context.getMetaData().getAnnotation(JndiBinding.class);
+      }
+      return null;
+   }
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AbstractBinding.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AbstractBinding.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AbstractBinding.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,130 @@
+/*
+* 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.microcontainer.beans;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.advice.AspectDefinition;
+import org.jboss.logging.Logger;
+import org.jboss.util.id.GUID;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractBinding
+{
+   private static final Logger log = Logger.getLogger(AbstractBinding.class);
+   
+   protected AspectManager manager;
+   
+   protected String name = GUID.asString();
+   
+   protected AspectDefinition aspect;
+   
+   protected String method = "invoke";
+   
+   /**
+    * Get the aspectDefinition.
+    * 
+    * @return the aspectDefinition.
+    */
+   public AspectDefinition getAspect()
+   {
+      return aspect;
+   }
+
+   /**
+    * Set the aspectDefinition.
+    * 
+    * @param aspect The aspectDefinition to set.
+    */
+   public void setAspect(AspectDefinition aspect)
+   {
+      this.aspect = aspect;
+   }
+
+   /**
+    * Get the manager.
+    * 
+    * @return the manager.
+    */
+   public AspectManager getManager()
+   {
+      return manager;
+   }
+
+   /**
+    * Set the manager.
+    * 
+    * @param manager The manager to set.
+    */
+   public void setManager(AspectManager manager)
+   {
+      this.manager = manager;
+   }
+
+   /**
+    * Get the method.
+    * 
+    * @return the method.
+    */
+   public String getMethod()
+   {
+      return method;
+   }
+
+   /**
+    * Set the method.
+    * 
+    * @param method The method to set.
+    */
+   public void setMethod(String method)
+   {
+      this.method = method;
+   }
+
+   public void start() throws Exception
+   {
+      createAndAddBinding();
+   }
+   
+   public void stop() throws Exception
+   {
+      removeBinding();
+   }
+
+   public void uninstall() throws Exception
+   {
+      stop();
+   }
+   
+   public void rebind(AspectDefinition aspect) throws Exception
+   {
+      this.aspect = aspect;
+      stop();
+      start();
+   }
+   
+   protected abstract void createAndAddBinding() throws Exception;
+   protected abstract void removeBinding() throws Exception;
+}

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/Aspect.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/Aspect.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/Aspect.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -37,39 +37,59 @@
 
 /**
  * An Aspect.
- * 
+ *
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision$
  */
 public class Aspect implements ConfigureKernelControllerContextAware, Untransformable
 {
    private static final Logger log = Logger.getLogger(Aspect.class);
-   
+
    protected AspectManager manager;
-   
+
    protected String adviceName = GUID.asString();
-   
-   protected String adviceBean;
-   
-   protected String scope;
-   
+
+   /**
+    * The scope of the aspect we are creating
+    */
+   Scope scope;
+
    protected ManagedAspectDefinition definition;
-   
+
+   /**
+    * The beanfactory representing the advice. This should be used if the advice has no dependencies,
+    * in which case we have a real dependency on the beanfactory. If the advice has dependencies we need
+    * to use adviceBean instead;
+    */
    protected GenericBeanFactory advice;
 
+   /**
+    * The name of the beanfactory representing the advice. This should be used if the advice has dependencies,
+    * in which case we have no real dependency on the beanfactory. If the advice has no dependencies we need
+    * to use advice instead;
+    */
+   protected String adviceBean;
+
+   /**
+    * The KernelControllerContext for this Aspect
+    */
    protected ControllerContext context;
 
    /** The name of this bean */
    protected String myname;
-   
-   /** The name of the AspectDefinition. If not lazy, use myname. If lazy, use adviceBean */
+
+   /** The name of the AspectDefinition. If not lazy (i.e, bean has no dependencies), use myname.
+    * If lazy (i.e. bean has dependencies), use adviceBean */
    protected String aspectDefName;
-   
+
+   /**
+    * Reference to the kernel
+    */
    protected Kernel kernel;
-   
+
    /**
     * Get the adviceName.
-    * 
+    *
     * @return the adviceName.
     */
    public String getAdviceName()
@@ -79,7 +99,7 @@
 
    /**
     * Set the adviceName.
-    * 
+    *
     * @param adviceName The adviceName to set.
     */
    public void setAdviceName(String adviceName)
@@ -89,7 +109,7 @@
 
    /**
     * Get the adviceBean.
-    * 
+    *
     * @return the adviceBean.
     */
    public String getAdviceBean()
@@ -99,7 +119,7 @@
 
    /**
     * Set the adviceBean.
-    * 
+    *
     * @param adviceBean the adviceBean.
     */
    public void setAdviceBean(String adviceBean)
@@ -109,7 +129,7 @@
 
    /**
     * Get the definition.
-    * 
+    *
     * @return the definition.
     */
    public AspectDefinition getDefinition()
@@ -119,7 +139,7 @@
 
    /**
     * Get the manager.
-    * 
+    *
     * @return the manager.
     */
    public AspectManager getManager()
@@ -129,17 +149,17 @@
 
    /**
     * Set the manager.
-    * 
+    *
     * @param manager The manager to set.
     */
    public void setManager(AspectManager manager)
    {
       this.manager = manager;
    }
-   
+
    /**
     * Get the advice.
-    * 
+    *
     * @return the advice.
     */
    public GenericBeanFactory getAdvice()
@@ -149,7 +169,7 @@
 
    /**
     * Set the advice.
-    * 
+    *
     * @param advice The advice to set.
     */
    public void setAdvice(GenericBeanFactory advice)
@@ -159,22 +179,22 @@
 
    /**
     * Get the scope.
-    * 
+    *
     * @return the scope.
     */
    public String getScope()
    {
-      return scope;
+      return scope.toString();
    }
 
    /**
     * Set the scope.
-    * 
+    *
     * @param scope The scope to set.
     */
    public void setScope(String scope)
    {
-      this.scope = scope;
+      this.scope = ScopeUtil.parse(scope);
    }
 
    public void setKernelControllerContext(KernelControllerContext context) throws Exception
@@ -194,31 +214,31 @@
       this.advice = factory;
       start();
    }
-   
+
    public void start() throws Exception
    {
       if (definition == null)
       {
-         aspectDefName = (adviceBean != null) ? adviceBean : myname; 
+         aspectDefName = (adviceBean != null) ? adviceBean : myname;
          if (manager == null)
             throw new IllegalArgumentException("Null manager");
-         Scope theScope = ScopeUtil.parse(scope);
          if (advice != null)
          {
-            definition = new ManagedAspectDefinition(aspectDefName, theScope, new GenericBeanAspectFactory(adviceName, advice));
+            definition = getAspectDefinitionNoDependencies();
          }
          else if (adviceBean != null && context.getController() != null)
          {
-            definition = new ManagedAspectDefinition(aspectDefName, theScope, new GenericBeanAspectFactory(aspectDefName, advice), false);
+            definition = getAspectDefintionDependencies();
          }
          else
          {
-            definition = new ManagedAspectDefinition(aspectDefName, theScope, new GenericAspectFactory(adviceName, null));
+            //Not sure when this would get called???
+            definition = getAspectDefinitionPlainAspectFactory();
          }
-         manager.addAspectDefinition(definition);
+         addDefinitionToManager();
       }
-      
-      if (adviceBean != null && advice != null) 
+
+      if (adviceBean != null && advice != null)
       {
          definition.setDeployed(true);
          GenericBeanAspectFactory factory = (GenericBeanAspectFactory)definition.getFactory();
@@ -226,17 +246,36 @@
       }
       log.debug("Bound aspect " + aspectDefName + "; deployed:" + definition.isDeployed());
    }
-   
-   
+
+   protected ManagedAspectDefinition getAspectDefinitionNoDependencies()
+   {
+      return new ManagedAspectDefinition(aspectDefName, scope, new GenericBeanAspectFactory(adviceName, advice));
+   }
+
+   protected ManagedAspectDefinition getAspectDefintionDependencies()
+   {
+      return new ManagedAspectDefinition(aspectDefName, scope, new GenericBeanAspectFactory(aspectDefName, advice), false);
+   }
+
+   protected ManagedAspectDefinition getAspectDefinitionPlainAspectFactory()
+   {
+      return new ManagedAspectDefinition(aspectDefName, scope, new GenericAspectFactory(adviceName, null));
+   }
+
+   protected void addDefinitionToManager()
+   {
+      manager.addAspectDefinition(definition);
+   }
+
    public void uninstall() throws Exception
    {
       stop();
    }
-   
-   
+
+
    public void stop()
    {
-      aspectDefName = (adviceBean != null) ? adviceBean : myname; 
+      aspectDefName = (adviceBean != null) ? adviceBean : myname;
       log.debug("Unbinding aspect " + aspectDefName);
       manager.removeAspectDefinition(aspectDefName);
       if (definition != null)
@@ -244,5 +283,5 @@
          definition.undeploy();
          definition = null;
       }
-   }   
+   }
 }
\ No newline at end of file

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBeanMetaDataFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBeanMetaDataFactory.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBeanMetaDataFactory.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -37,7 +37,6 @@
 import org.jboss.beans.metadata.spi.InstallMetaData;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
 import org.jboss.beans.metadata.spi.ParameterMetaData;
-import org.jboss.beans.metadata.spi.PropertyMetaData;
 
 /**
  * AspectBeanMetaDataFactory.
@@ -50,20 +49,23 @@
 {
    private static final long serialVersionUID = 1L;
 
-   /** Unless specified use the bean with this name as the aspect manager */
-   final static String DEFAULT_ASPECT_MANAGER = "AspectManager";
-   
    /** The pointcut */
    private String pointcut;
    
-   /** The bean name of the aspect manager to use */
-   private String managerBean = DEFAULT_ASPECT_MANAGER;
-   
-   /** The property of the aspect manager bean, if any, containing the aspect manager */
-   private String managerProperty;
-   
    private String adviceMethod;
    
+   AspectBeanMetaDataUtil util = new AspectBeanMetaDataUtil();
+
+   public void setManagerBean(String managerBean)
+   {
+      util.setManagerBean(managerBean);
+   }
+
+   public void setManagerProperty(String aspectManagerProperty)
+   {
+      util.setManagerProperty(aspectManagerProperty);
+   }
+
    /**
     * Get the pointcut.
     * 
@@ -85,26 +87,6 @@
    }
 
 
-   public String getManager()
-   {
-      return managerBean;
-   }
-
-   public void setManagerBean(String managerBean)
-   {
-      this.managerBean = managerBean;
-   }
-
-   public String getManagerProperty()
-   {
-      return managerProperty;
-   }
-
-   public void setManagerProperty(String aspectManagerProperty)
-   {
-      this.managerProperty = aspectManagerProperty;
-   }   
-   
    public String getAdviceMethod()
    {
       return adviceMethod;
@@ -115,6 +97,11 @@
       this.adviceMethod = adviceMethod;
    }
 
+   /**
+    * See http://www.jboss.com/index.html?module=bb&op=viewtopic&t=79719&start=20
+    * for a description of the beans created
+    */
+   @Override
    public List<BeanMetaData> getBeans()
    {
       ArrayList<BeanMetaData> result = new ArrayList<BeanMetaData>();
@@ -125,20 +112,20 @@
       String aspectName = name + "$Aspect";
       AbstractBeanMetaData aspect = new AbstractBeanMetaData();
       aspect.setName(aspectName);
-      aspect.setBean("org.jboss.aop.microcontainer.beans.Aspect");
-      aspect.addProperty(getAspectManagerPropertyMetaData("manager"));
+      aspect.setBean(Aspect.class.getName());
+      util.setAspectManagerProperty(aspect, "manager");
       result.add(aspect);
       
       String aspectBindingName = name + "$AspectBinding";
       AbstractBeanMetaData aspectBinding = new AbstractBeanMetaData();
       aspectBinding.setName(aspectBindingName);
-      aspectBinding.setBean("org.jboss.aop.microcontainer.beans.AspectBinding");
-      aspectBinding.addProperty(new AbstractPropertyMetaData("pointcut", pointcut));
-      aspectBinding.addProperty(new AbstractPropertyMetaData("aspect", new AbstractDependencyValueMetaData(aspectName, "definition")));
-      aspectBinding.addProperty(getAspectManagerPropertyMetaData("manager"));
+      aspectBinding.setBean(AspectBinding.class.getName());
+      util.setSimpleProperty(aspectBinding, "pointcut", pointcut);
+      util.setDependencyProperty(aspectBinding, "aspect", aspectName, "definition");
+      util.setAspectManagerProperty(aspectBinding, "manager");
       if (adviceMethod != null)
       {
-         aspectBinding.addProperty(new AbstractPropertyMetaData("method", adviceMethod));
+         util.setSimpleProperty(aspectBinding, "method", adviceMethod);
       }
       result.add(aspectBinding);
       
@@ -155,11 +142,6 @@
       return result;
    }
    
-   protected PropertyMetaData getAspectManagerPropertyMetaData(String name)
-   {
-      return new AbstractPropertyMetaData(name, new AbstractDependencyValueMetaData(managerBean, managerProperty));
-   }
-   
    private void configureWithDependencies(AbstractBeanMetaData aspect, AbstractBeanMetaData aspectBinding)
    {
       aspect.addProperty(new AbstractPropertyMetaData("adviceBean", name));

Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBeanMetaDataUtil.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBeanMetaDataUtil.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBeanMetaDataUtil.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,90 @@
+/*
+* 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.microcontainer.beans;
+
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
+import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+import org.jboss.beans.metadata.plugins.factory.GenericBeanFactoryMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AspectBeanMetaDataUtil
+{
+   private static final long serialVersionUID = 1L;
+
+   /** Unless specified use the bean with this name as the aspect manager */
+   protected final static String DEFAULT_ASPECT_MANAGER = "AspectManager";
+   
+   /** The bean name of the aspect manager to use */
+   protected String managerBean = DEFAULT_ASPECT_MANAGER;
+
+   /** The property of the aspect manager bean, if any, containing the aspect manager */
+   protected String managerProperty;
+
+
+   public String getManager()
+   {
+      return managerBean;
+   }
+
+   public void setManagerBean(String managerBean)
+   {
+      this.managerBean = managerBean;
+   }
+
+   public String getManagerProperty()
+   {
+      return managerProperty;
+   }
+
+   public void setManagerProperty(String aspectManagerProperty)
+   {
+      this.managerProperty = aspectManagerProperty;
+   }
+
+   protected void setSimpleProperty(AbstractBeanMetaData bean, String propertyName, Object value)
+   {
+      bean.addProperty(new AbstractPropertyMetaData(propertyName, value));
+   }
+
+   protected void setDependencyProperty(AbstractBeanMetaData bean, String propertyName, Object dependencyBean)
+   {
+      setDependencyProperty(bean, propertyName, dependencyBean, null);
+   }
+
+   protected void setDependencyProperty(AbstractBeanMetaData bean, String propertyName, Object dependencyBean, String dependencyProperty)
+   {
+      bean.addProperty(new AbstractPropertyMetaData(propertyName, new AbstractDependencyValueMetaData(dependencyBean, dependencyProperty)));
+   }
+
+   protected void setAspectManagerProperty(AbstractBeanMetaData bean, String propertyName)
+   {
+      setDependencyProperty(bean, propertyName, managerBean, managerProperty);
+   }
+
+}

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBinding.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBinding.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/AspectBinding.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -30,27 +30,27 @@
 
 /**
  * An AspectBinding.
- * 
+ *
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision$
  */
 public class AspectBinding
 {
    private static final Logger log = Logger.getLogger(AspectBinding.class);
-   
+
    protected AspectManager manager;
-   
+
    protected String name = GUID.asString();
-   
+
    protected String pointcut;
-   
+
    protected AspectDefinition aspect;
-   
+
    protected String method = "invoke";
-   
+
    /**
     * Get the aspectDefinition.
-    * 
+    *
     * @return the aspectDefinition.
     */
    public AspectDefinition getAspect()
@@ -60,7 +60,7 @@
 
    /**
     * Set the aspectDefinition.
-    * 
+    *
     * @param aspect The aspectDefinition to set.
     */
    public void setAspect(AspectDefinition aspect)
@@ -70,7 +70,7 @@
 
    /**
     * Get the manager.
-    * 
+    *
     * @return the manager.
     */
    public AspectManager getManager()
@@ -80,7 +80,7 @@
 
    /**
     * Set the manager.
-    * 
+    *
     * @param manager The manager to set.
     */
    public void setManager(AspectManager manager)
@@ -90,7 +90,7 @@
 
    /**
     * Get the method.
-    * 
+    *
     * @return the method.
     */
    public String getMethod()
@@ -100,7 +100,7 @@
 
    /**
     * Set the method.
-    * 
+    *
     * @param method The method to set.
     */
    public void setMethod(String method)
@@ -110,7 +110,7 @@
 
    /**
     * Get the pointcut.
-    * 
+    *
     * @return the pointcut.
     */
    public String getPointcut()
@@ -120,7 +120,7 @@
 
    /**
     * Set the pointcut.
-    * 
+    *
     * @param pointcut The pointcut to set.
     */
    public void setPointcut(String pointcut)
@@ -139,10 +139,9 @@
       AdviceBinding binding = new AdviceBinding(name, pointcut, null);
       binding.addInterceptorFactory(new AdviceFactory(aspect, method));
       manager.addBinding(binding);
-//      System.out.println("----> Added binding " + pointcut);
       log.debug("Bound binding " + name);
    }
-   
+
    public void stop() throws Exception
    {
       manager.removeBinding(name);
@@ -152,7 +151,7 @@
    {
       stop();
    }
-   
+
    public void rebind(AspectDefinition aspect) throws Exception
    {
       this.aspect = aspect;

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/ConfigureLifecycleBeanMetaDataFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/ConfigureLifecycleBeanMetaDataFactory.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/ConfigureLifecycleBeanMetaDataFactory.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -21,6 +21,8 @@
 */ 
 package org.jboss.aop.microcontainer.beans;
 
+import org.jboss.dependency.spi.ControllerState;
+
 /**
  * 
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
@@ -31,8 +33,16 @@
    private static final long serialVersionUID = 1L;
 
    @Override
-   protected String getControllerInterface()
+   protected ControllerState getState()
    {
-      return "org.jboss.kernel.spi.dependency.ConfigureKernelControllerContextAware";
+      return ControllerState.CONFIGURED;
    }
+
+//   @Override
+//   protected String getControllerInterface()
+//   {
+//      return "org.jboss.kernel.spi.dependency.ConfigureKernelControllerContextAware";
+//   }
+   
+   
 }

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/CreateLifecycleBeanMetaDataFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/CreateLifecycleBeanMetaDataFactory.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/CreateLifecycleBeanMetaDataFactory.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -21,6 +21,8 @@
 */ 
 package org.jboss.aop.microcontainer.beans;
 
+import org.jboss.dependency.spi.ControllerState;
+
 /**
  * 
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
@@ -31,8 +33,8 @@
    private static final long serialVersionUID = 1L;
 
    @Override
-   protected String getControllerInterface()
+   protected ControllerState getState()
    {
-      return "org.jboss.kernel.spi.dependency.CreateKernelControllerContextAware";
+      return ControllerState.CREATE;
    }
 }

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/DescribeLifecycleBeanMetaDataFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/DescribeLifecycleBeanMetaDataFactory.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/DescribeLifecycleBeanMetaDataFactory.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -21,6 +21,8 @@
 */ 
 package org.jboss.aop.microcontainer.beans;
 
+import org.jboss.dependency.spi.ControllerState;
+
 /**
  * 
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
@@ -31,8 +33,14 @@
    private static final long serialVersionUID = 1L;
 
    @Override
-   protected String getControllerInterface()
+   protected ControllerState getState()
    {
-      return "org.jboss.kernel.spi.dependency.DescribeKernelControllerContextAware";
+      return ControllerState.DESCRIBED;
    }
+
+//   @Override
+//   protected String getControllerInterface()
+//   {
+//      return "org.jboss.kernel.spi.dependency.DescribeKernelControllerContextAware";
+//   }
 }

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/InstallLifecycleBeanMetaDataFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/InstallLifecycleBeanMetaDataFactory.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/InstallLifecycleBeanMetaDataFactory.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -21,6 +21,8 @@
 */ 
 package org.jboss.aop.microcontainer.beans;
 
+import org.jboss.dependency.spi.ControllerState;
+
 /**
  * 
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
@@ -31,8 +33,14 @@
    private static final long serialVersionUID = 1L;
 
    @Override
-   protected String getControllerInterface()
+   protected ControllerState getState()
    {
-      return "org.jboss.kernel.spi.dependency.InstallKernelControllerContextAware";
+      return ControllerState.INSTALLED;
    }
+
+//   @Override
+//   protected String getControllerInterface()
+//   {
+//      return "org.jboss.kernel.spi.dependency.InstallKernelControllerContextAware";
+//   }
 }

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/InstantiateLifecycleBeanMetaDataFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/InstantiateLifecycleBeanMetaDataFactory.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/InstantiateLifecycleBeanMetaDataFactory.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -21,6 +21,8 @@
 */ 
 package org.jboss.aop.microcontainer.beans;
 
+import org.jboss.dependency.spi.ControllerState;
+
 /**
  * 
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
@@ -31,8 +33,14 @@
    private static final long serialVersionUID = 1L;
 
    @Override
-   protected String getControllerInterface()
+   protected ControllerState getState()
    {
-      return "org.jboss.kernel.spi.dependency.InstantiateKernelControllerContextAware";
+      return ControllerState.INSTANTIATED;
    }
+
+//   @Override
+//   protected String getControllerInterface()
+//   {
+//      return "org.jboss.kernel.spi.dependency.InstantiateKernelControllerContextAware";
+//   }
 }

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/LifecycleBeanMetaDataFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/LifecycleBeanMetaDataFactory.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/LifecycleBeanMetaDataFactory.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -21,60 +21,153 @@
 */ 
 package org.jboss.aop.microcontainer.beans;
 
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 
 import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.plugins.AbstractListMetaData;
-import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
-import org.jboss.beans.metadata.plugins.StringValueMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
+import org.jboss.beans.metadata.plugins.factory.GenericBeanFactoryMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
-import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+import org.jboss.dependency.spi.ControllerState;
 
 /**
  * 
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
  * @version $Revision: 1.1 $
  */
-public abstract class LifecycleBeanMetaDataFactory extends AspectBeanMetaDataFactory implements BeanMetaDataFactory
+public abstract class LifecycleBeanMetaDataFactory extends GenericBeanFactoryMetaData
+implements BeanMetaDataFactory
 {
    private static final long serialVersionUID = 1L;
 
    private String classes;
+   private String expr;
+   private String installMethod;
+   private String uninstallMethod;
 
-   public String getClasses()
+   AspectBeanMetaDataUtil util = new AspectBeanMetaDataUtil();
+   HashSet<PropertyMetaData> properties = new HashSet<PropertyMetaData>();
+
+   public void setManagerBean(String managerBean)
    {
-      return classes;
+      util.setManagerBean(managerBean);
    }
 
+   public void setManagerProperty(String aspectManagerProperty)
+   {
+      util.setManagerProperty(aspectManagerProperty);
+   }
+
    public void setClasses(String classes)
    {
       this.classes = classes;
    }
    
+   public void setExpr(String classes)
+   {
+      this.expr = classes;
+   }
+   
+   public void setInstallMethod(String installMethod)
+   {
+      this.installMethod = installMethod;
+   }
+
+   public void setUninstallMethod(String uninstallMethod)
+   {
+      this.uninstallMethod = uninstallMethod;
+   }
+
+   protected abstract ControllerState getState();
+
    public List<BeanMetaData> getBeans()
    {
-      List<BeanMetaData> beans = super.getBeans();
+      ArrayList<BeanMetaData> result = new ArrayList<BeanMetaData>();
 
-      String aspectBindingName = name + "$IntroductionBinding";
-      AbstractBeanMetaData introductionBinding = new AbstractBeanMetaData();
-      introductionBinding.setName(aspectBindingName);
-      introductionBinding.setBean("org.jboss.aop.microcontainer.beans.IntroductionBinding");
-      introductionBinding.addProperty(getAspectManagerPropertyMetaData("manager"));
-      introductionBinding.addProperty(new AbstractPropertyMetaData("interfaces", getInterfaces()));
-      introductionBinding.addProperty(new AbstractPropertyMetaData("classes", getClasses()));
-      beans.add(introductionBinding);
+      //Do not include the bean factory here, just install the bean directly and the binding 
+      AbstractBeanMetaData lifecycle = new AbstractBeanMetaData();
+      lifecycle.setName(name);
+      lifecycle.setBean(getBeanClass());
+      for (PropertyMetaData pmd : properties)
+      {
+         lifecycle.addProperty(pmd);   
+      }
+      lifecycle.setDepends(getDepends());
+      result.add(lifecycle);
       
-      return beans;
+      
+      String aspectBindingName = name + "$AspectBinding";
+      AbstractBeanMetaData aspectBinding = new AbstractBeanMetaData();
+      aspectBinding.setName(aspectBindingName);
+      aspectBinding.setBean(LifecycleBinding.class.getName());
+
+      util.setSimpleProperty(aspectBinding, "callbackBean", name);
+      util.setAspectManagerProperty(aspectBinding, "manager");
+      if (expr != null)
+      {
+         util.setSimpleProperty(aspectBinding, "expr", expr);
+      }
+      else if (classes != null) 
+      {
+         util.setSimpleProperty(aspectBinding, "classes", classes);         
+      }
+      util.setSimpleProperty(aspectBinding, "state", getState());
+      if (installMethod != null)
+      {
+         util.setSimpleProperty(aspectBinding, "installMethod", installMethod);
+      }
+      if (uninstallMethod != null)
+      {
+         util.setSimpleProperty(aspectBinding, "uninstallMethod", uninstallMethod);
+      }
+      result.add(aspectBinding);
+      
+      return result;
    }
-   
-   private ValueMetaData getInterfaces()
+
+
+   protected boolean hasInjectedBeans()
    {
-      AbstractListMetaData interfaces = new AbstractListMetaData();
-      interfaces.setElementType("java.lang.String");
-      interfaces.add(new StringValueMetaData(getControllerInterface()));
-      return interfaces;
+      ArrayList<AbstractDependencyValueMetaData> dependencies = new ArrayList<AbstractDependencyValueMetaData>();
+      getDependencies(dependencies, this);
+      
+      for (AbstractDependencyValueMetaData dep : dependencies)
+      {
+         if(!((String)dep.getValue()).startsWith("jboss.kernel:service="))
+         {
+            return true;
+         }
+      }
+      return false;
    }
-   
-   protected abstract String getControllerInterface();
+
+   private void getDependencies(ArrayList<AbstractDependencyValueMetaData> dependencies, MetaDataVisitorNode node)
+   {
+      Iterator children = node.getChildren();
+      
+      if (children != null)
+      {
+         while (children.hasNext())
+         {
+            MetaDataVisitorNode child = (MetaDataVisitorNode)children.next();
+            if (child instanceof AbstractDependencyValueMetaData)
+            {
+               dependencies.add((AbstractDependencyValueMetaData)child);
+            }
+            getDependencies(dependencies, child);
+         }
+      }
+   }
+
+   @Override
+   public void addBeanProperty(PropertyMetaData property)
+   {
+      properties.add(property);
+   }
+
 }

Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/LifecycleBinding.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/LifecycleBinding.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/LifecycleBinding.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,109 @@
+/*
+* 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.microcontainer.beans;
+
+import org.jboss.aop.AspectManager;
+import org.jboss.aop.microcontainer.lifecycle.LifecycleCallbackBinding;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.util.id.GUID;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifecycleBinding
+{
+   protected String name = GUID.asString();
+   protected AspectManager manager;   
+   private String classes;
+   private String expr;
+   private String callbackBean;
+   private ControllerState state;
+   private String installMethod = "install";
+   private String uninstallMethod = "uninstall";
+
+   public void setClasses(String classes)
+   {
+      this.classes = classes;
+   }
+   
+   public String getExpr()
+   {
+      return expr;
+   }
+
+   public void setExpr(String classes)
+   {
+      this.expr = classes;
+   }
+   
+   public void setCallbackBean(String name)
+   {
+      callbackBean = name;
+   }
+   
+   public void setManager(AspectManager manager)
+   {
+      this.manager = manager;
+   }
+   
+   public void setState(ControllerState state)
+   {
+      this.state = state;
+   }
+   
+   public void setInstallMethod(String installMethod)
+   {
+      this.installMethod = installMethod;
+   }
+
+   public void setUninstallMethod(String uninstallMethod)
+   {
+      this.uninstallMethod = uninstallMethod;
+   }
+
+   public void start() throws Exception
+   {
+      if (expr == null && classes == null)
+         throw new IllegalArgumentException("Null classes and null expr");
+      if (expr != null && classes != null)
+         throw new IllegalArgumentException("Both classes and expr were set");
+      if (manager == null)
+         throw new IllegalArgumentException("Null manager");
+      if (callbackBean == null)
+         throw new IllegalArgumentException("Null callback bean");
+      if (state == null)
+         throw new IllegalArgumentException("Null controller state");
+      
+      LifecycleCallbackBinding binding = new LifecycleCallbackBinding(name, classes, expr, state);
+      binding.addLifecycleCallback(callbackBean, installMethod, uninstallMethod);
+      manager.addLifecycleBinding(binding);
+   }
+
+   
+   public void stop() throws Exception
+   {
+      manager.removeLifecycleBinding(name);
+   }
+
+}

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/StartLifecycleBeanMetaDataFactory.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/StartLifecycleBeanMetaDataFactory.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/StartLifecycleBeanMetaDataFactory.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -21,6 +21,8 @@
 */ 
 package org.jboss.aop.microcontainer.beans;
 
+import org.jboss.dependency.spi.ControllerState;
+
 /**
  * 
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
@@ -31,9 +33,14 @@
    private static final long serialVersionUID = 1L;
 
    @Override
-   protected String getControllerInterface()
+   protected ControllerState getState()
    {
-      return "org.jboss.kernel.spi.dependency.StartKernelControllerContextAware";
+      return ControllerState.START;
    }
 
+//   @Override
+//   protected String getControllerInterface()
+//   {
+//      return "org.jboss.kernel.spi.dependency.StartKernelControllerContextAware";
+//   }
 }

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/xml/AOPBeansSchemaInitializer.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/xml/AOPBeansSchemaInitializer.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/beans/xml/AOPBeansSchemaInitializer.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -56,24 +56,9 @@
    private static final QName aspectTypeQName = new QName(AOP_BEANS_NS, "aspectType");
    
    /** The lifecycle configure aspect binding */
-   private static final QName lifecycleConfigureTypeQName = new QName(AOP_BEANS_NS, "lifecycleConfigureType");
+   private static final QName lifecycleTypeQName = new QName(AOP_BEANS_NS, "lifecycleType");
    
-   /** The lifecycle create aspect binding */
-   private static final QName lifecycleCreateTypeQName = new QName(AOP_BEANS_NS, "lifecycleCreateType");
    
-   /** The lifecycle describe aspect binding */
-   private static final QName lifecycleDescribeTypeQName = new QName(AOP_BEANS_NS, "lifecycleDescribeType");
-   
-   /** The lifecycle aspect binding */
-   private static final QName lifecycleInstallTypeQName = new QName(AOP_BEANS_NS, "lifecycleInstallType");
-   
-   /** The lifecycle aspect binding */
-   private static final QName lifecycleInstantiateTypeQName = new QName(AOP_BEANS_NS, "lifecycleInstantiateType");
-   
-   /** The lifecycle start aspect binding */
-   private static final QName lifecycleStartTypeQName = new QName(AOP_BEANS_NS, "lifecycleStartType");
-
-   
    public SchemaBinding init(SchemaBinding schema)
    {
       // ignore XB property replacement
@@ -85,35 +70,10 @@
       aspectType.setHandler(new AspectBeanFactoryHandler());
 
       //Configure binding
-      TypeBinding lifecycleConfigureTypeQ = schema.getType(lifecycleConfigureTypeQName);
+      TypeBinding lifecycleConfigureTypeQ = schema.getType(lifecycleTypeQName);
       BeanSchemaBindingHelper.initBeanFactoryHandlers(lifecycleConfigureTypeQ);
-      lifecycleConfigureTypeQ.setHandler(new ConfigureLifecycleBeanFactoryHandler());
+      lifecycleConfigureTypeQ.setHandler(new LifecycleBeanFactoryHandler());
 
-      //Create binding
-      TypeBinding lifecycleCreateType = schema.getType(lifecycleCreateTypeQName);
-      BeanSchemaBindingHelper.initBeanFactoryHandlers(lifecycleCreateType);
-      lifecycleCreateType.setHandler(new CreateLifecycleBeanFactoryHandler());
-
-      //Describe binding
-      TypeBinding lifecycleDescribeType = schema.getType(lifecycleDescribeTypeQName);
-      BeanSchemaBindingHelper.initBeanFactoryHandlers(lifecycleDescribeType);
-      lifecycleDescribeType.setHandler(new DescribeLifecycleBeanFactoryHandler());
-
-      //Install binding
-      TypeBinding lifecycleInstallType = schema.getType(lifecycleInstallTypeQName);
-      BeanSchemaBindingHelper.initBeanFactoryHandlers(lifecycleInstallType);
-      lifecycleInstallType.setHandler(new InstallLifecycleBeanFactoryHandler());
-      
-      //Instantiate binding
-      TypeBinding lifecycleInstantiateType = schema.getType(lifecycleInstantiateTypeQName);
-      BeanSchemaBindingHelper.initBeanFactoryHandlers(lifecycleInstantiateType);
-      lifecycleInstantiateType.setHandler(new InstantiateLifecycleBeanFactoryHandler());
-      
-      //Start binding
-      TypeBinding lifecycleStartType = schema.getType(lifecycleStartTypeQName);
-      BeanSchemaBindingHelper.initBeanFactoryHandlers(lifecycleStartType);
-      lifecycleStartType.setHandler(new StartLifecycleBeanFactoryHandler());
-      
       // TODO FIXME???
       BeanSchemaBinding20.initArtifacts(schema);
       
@@ -141,6 +101,7 @@
       
       protected void setAttribute(AspectBeanMetaDataFactory factory, String localName, String attr)
       {
+         
          if ("pointcut".equals(localName))
          {
             factory.setPointcut(attr);
@@ -160,68 +121,79 @@
       }
    }
 
-   private static class LifecycleBeanFactoryHandler extends AspectBeanFactoryHandler
+   private static class LifecycleBeanFactoryHandler extends BeanFactoryHandler
    {
       public Object startElement(Object parent, QName name, ElementBinding element)
       {
-         throw new RuntimeException("Do not use <lifecycle> directly");
+         String localname = name.getLocalPart();
+         if (localname.equals("lifecycle-configure"))
+         {
+            return new ConfigureLifecycleBeanMetaDataFactory();
+         }
+         if (localname.equals("lifecycle-create"))
+         {      
+            return new CreateLifecycleBeanMetaDataFactory();
+         }
+         if (localname.equals("lifecycle-describe"))
+         {      
+            return new DescribeLifecycleBeanMetaDataFactory();
+         }
+         if (localname.equals("lifecycle-install"))
+         {      
+            return new InstallLifecycleBeanMetaDataFactory();
+         }
+         if (localname.equals("lifecycle-instantiate"))
+         {      
+            return new InstantiateLifecycleBeanMetaDataFactory();
+         }
+         if (localname.equals("lifecycle-start"))
+         {      
+            return new StartLifecycleBeanMetaDataFactory();
+         }
+         
+         throw new IllegalStateException(name + " is not a recognized element");
       }
 
-      protected void setAttribute(AspectBeanMetaDataFactory factory, String localName, String attr)
+      public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
       {
-         super.setAttribute(factory, localName, attr);
-         if ("classes".equals(localName))
+         //TODO see TODO in setAttribute()
+         super.attributes(o, elementName, element, attrs, nsCtx);
+
+         LifecycleBeanMetaDataFactory factory = (LifecycleBeanMetaDataFactory) o;
+         for (int i = 0; i < attrs.getLength(); ++i)
          {
-            ((LifecycleBeanMetaDataFactory)factory).setClasses(attr);
+            String localName = attrs.getLocalName(i);
+            setAttribute(factory, localName, attrs.getValue(i));
          }
       }
-   }
-   
-   private static class ConfigureLifecycleBeanFactoryHandler extends LifecycleBeanFactoryHandler
-   {
-      public Object startElement(Object parent, QName name, ElementBinding element)
+
+      protected void setAttribute(LifecycleBeanMetaDataFactory factory, String localName, String attr)
       {
-         return new ConfigureLifecycleBeanMetaDataFactory();
+         if ("classes".equals(localName))
+         {
+            factory.setClasses(attr);
+         }
+         else if ("expr".equals(localName))
+         {
+            factory.setExpr(attr);
+            return;
+         }         
+         else if ("manager-bean".equals(localName))
+         {
+            factory.setManagerBean(attr);
+         }
+         else if ("manager-property".equals(localName))
+         {
+            factory.setManagerProperty(attr);
+         }
+         else if ("install".equals(localName))
+         {
+            factory.setInstallMethod(attr);
+         }
+         else if ("uninstall".equals(localName))
+         {
+            factory.setUninstallMethod(attr);
+         }
       }
    }
-   
-   private static class CreateLifecycleBeanFactoryHandler extends LifecycleBeanFactoryHandler
-   {
-      public Object startElement(Object parent, QName name, ElementBinding element)
-      {
-         return new CreateLifecycleBeanMetaDataFactory();
-      }
-   }
-   
-   private static class DescribeLifecycleBeanFactoryHandler extends LifecycleBeanFactoryHandler
-   {
-      public Object startElement(Object parent, QName name, ElementBinding element)
-      {
-         return new DescribeLifecycleBeanMetaDataFactory();
-      }
-   }
-   
-   private static class InstallLifecycleBeanFactoryHandler extends LifecycleBeanFactoryHandler
-   {
-      public Object startElement(Object parent, QName name, ElementBinding element)
-      {
-         return new InstallLifecycleBeanMetaDataFactory();
-      }
-   }
-   
-   private static class InstantiateLifecycleBeanFactoryHandler extends LifecycleBeanFactoryHandler
-   {
-      public Object startElement(Object parent, QName name, ElementBinding element)
-      {
-         return new InstantiateLifecycleBeanMetaDataFactory();
-      }
-   }
-   
-   private static class StartLifecycleBeanFactoryHandler extends LifecycleBeanFactoryHandler
-   {
-      public Object startElement(Object parent, QName name, ElementBinding element)
-      {
-         return new StartLifecycleBeanMetaDataFactory();
-      }
-   }
 }

Modified: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AOPDependencyBuilder.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -18,7 +18,7 @@
 * 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.microcontainer.integration;
 
 import java.util.ArrayList;
@@ -28,18 +28,23 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Map.Entry;
 
 import org.jboss.aop.Advisor;
 import org.jboss.aop.AspectManager;
 import org.jboss.aop.ReflectiveAspectBinder;
 import org.jboss.aop.advice.AspectDefinition;
 import org.jboss.aop.microcontainer.beans.ManagedAspectDefinition;
+import org.jboss.aop.microcontainer.lifecycle.LifecycleCallbackBinding;
+import org.jboss.aop.microcontainer.lifecycle.LifecycleCallbackDefinition;
 import org.jboss.aop.proxy.container.ContainerCache;
 import org.jboss.aop.util.Advisable;
 import org.jboss.aop.util.ClassInfoMethodHashing;
 import org.jboss.classadapter.plugins.dependency.AbstractDependencyBuilder;
 import org.jboss.classadapter.spi.ClassAdapter;
 import org.jboss.classadapter.spi.Dependency;
+import org.jboss.classadapter.spi.DependencyBuilderListItem;
+import org.jboss.dependency.spi.ControllerState;
 import org.jboss.metadata.spi.MetaData;
 import org.jboss.metadata.spi.signature.MethodSignature;
 import org.jboss.reflect.plugins.AnnotationValueFactory;
@@ -55,9 +60,9 @@
 import org.jboss.reflect.spi.Value;
 
 /**
- * Finds all managed aspects that apply 
+ * Finds all managed aspects that apply
  * to the bean and includes their dependencies as dependencies of the bean
- *  
+ *
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision$
@@ -68,7 +73,6 @@
    private static final String DEPENDENCY_NAME_ATTRIBUTE = "name";
    private static final IntrospectionTypeInfoFactoryImpl typeInfoFactory = new IntrospectionTypeInfoFactoryImpl();
 
-   static int i = 0;
    public List<Object> getDependencies(ClassAdapter classAdapter, MetaData metaData)
    {
       AspectManager manager = AspectManager.instance();
@@ -91,10 +95,10 @@
                ContainerCache cache = ContainerCache.initialise(manager, clazz, metaData, true);
                advisor = cache.getAdvisor();
             }
-            
+
             ReflectiveAspectBinder binder = new ReflectiveAspectBinder(clazz, advisor);
             Set aspects = binder.getAspects();
-            
+
             ArrayList<Object> depends = new ArrayList<Object>();
             if (aspects != null && aspects.size() > 0)
             {
@@ -104,24 +108,40 @@
                   AspectDefinition def = (AspectDefinition) it.next();
                   if (def instanceof ManagedAspectDefinition)
                   {
-                     depends.add(def.getName());
+                     depends.add(new AspectDependencyBuilderListItem(def.getName()));
                   }
                }
             }
 
+            Map<Object, Set<LifecycleCallbackDefinition>> lifecycleCallbacks = binder.getLifecycleCallbacks();
+            if (lifecycleCallbacks != null && lifecycleCallbacks.size() > 0)
+            {
+               for (Entry<Object, Set<LifecycleCallbackDefinition>> states : lifecycleCallbacks.entrySet())
+               {
+                  for (LifecycleCallbackDefinition callback : states.getValue())
+                  {
+                     depends.add(new LifecycleAspectDependencyBuilderListItem(
+                           callback.getBean(), (ControllerState)states.getKey(), callback.getInstallMethod(), callback.getUninstallMethod()));
+                  }
+               }
+            }
+
             HashSet<Object> annotationDependencies = getAnnotationDependencies(classInfo, metaData);
-            depends.addAll(annotationDependencies);
+            for (Object dependency : annotationDependencies)
+            {
+               depends.add(new AnnotationDependencyBuilderListItem((String)dependency));
+            }
             return depends;
          }
          return null;
-         
+
       }
       catch (ClassNotFoundException e)
       {
          throw new RuntimeException(e);
       }
    }
-   
+
    private HashSet<Object> getAnnotationDependencies(ClassInfo classInfo, MetaData metaData)
    {
       try
@@ -149,17 +169,17 @@
       getMetaDataClassAnnotationDependencies(metaData, metaMap);
       addAllDependenciesToSet(dependencies, realMap, metaMap);
    }
-   
+
    private void getRealClassAnnotationDependencies(ClassInfo classInfo, HashMap<String, ArrayList<String>> dependencies) throws Exception
    {
       AnnotationValue[] annotations = classInfo.getAnnotations();
-      
+
       for (int i = 0 ; i < annotations.length ; i++)
       {
          getDependenciesForAnnotation(annotations[i].getType().getName(), annotations[i], dependencies);
       }
    }
-   
+
    private void getMetaDataClassAnnotationDependencies(MetaData metaData, HashMap<String, ArrayList<String>> dependencies) throws Exception
    {
       if (metaData != null)
@@ -170,7 +190,7 @@
          }
       }
    }
-   
+
    private void getMethodAnnotationDependencies(ClassInfo classInfo, MetaData metaData, HashSet<Object> dependencies) throws Exception
    {
       Map methodMap = ClassInfoMethodHashing.getMethodMap(classInfo);
@@ -190,7 +210,7 @@
          }
       }
    }
-   
+
    private void getRealMethodAnnotationDependencies(MethodInfo methodInfo, HashMap<String, ArrayList<String>> dependencies) throws Exception
    {
       AnnotationValue[] annotations = methodInfo.getAnnotations();
@@ -202,7 +222,7 @@
          }
       }
    }
-   
+
    private void getMetaDataMethodAnnotationDependencies(MethodInfo method, MetaData metaData, HashMap<String, ArrayList<String>> dependencies) throws Exception
    {
       if (metaData != null)
@@ -221,7 +241,7 @@
          }
       }
    }
-   
+
    private void getDependenciesForMetaDataAnnotation(Object annotation, HashMap<String, ArrayList<String>> dependencies) throws Exception
    {
       AnnotationInfo info;
@@ -238,13 +258,13 @@
       AnnotationValue value = AnnotationValueFactory.createAnnotationValue(typeInfoFactory, typeInfoFactory, info, annotation);
       getDependenciesForAnnotation(info.getName(), value, dependencies);
    }
-   
+
    private void getDependenciesForAnnotation(String topLevelAnnotationName, AnnotationValue annotation, HashMap<String, ArrayList<String>> dependencies)
    {
       if (annotation != null)
       {
          addAnnotationAttributeDependencies(topLevelAnnotationName, annotation, dependencies);
-         
+
          AnnotationValue[] annotationAnnotations = annotation.getAnnotationType().getAnnotations();
          for (int i = 0 ; i < annotationAnnotations.length ; i++)
          {
@@ -257,7 +277,7 @@
          }
       }
    }
-   
+
    private void addAnnotationAttributeDependencies(String topLevelAnnotationName, AnnotationValue annotation, HashMap<String, ArrayList<String>> dependencies)
    {
       MethodInfo[] attributes = annotation.getAnnotationType().getDeclaredMethods();
@@ -266,7 +286,7 @@
          for (int i = 0 ; i < attributes.length ; i++)
          {
             Value value = annotation.getValue(attributes[i].getName());
-            
+
             if (value instanceof AnnotationValue)
             {
                getDependenciesForAnnotation(topLevelAnnotationName, (AnnotationValue)value, dependencies);
@@ -287,7 +307,7 @@
          }
       }
    }
-   
+
    private void addDependency(String topLevelAnnotationName, StringValue dependency, HashMap<String, ArrayList<String>> dependencies)
    {
       ArrayList<String> list = dependencies.get(topLevelAnnotationName);
@@ -296,7 +316,7 @@
          list = new ArrayList<String>();
          dependencies.put(topLevelAnnotationName, list);
       }
-      
+
       list.add(dependency.getValue());
    }
 
@@ -311,7 +331,7 @@
          }
       }
    }
-   
+
    private HashMap<String, ArrayList<String>> mergeClassAndOverrideMaps(HashMap<String, ArrayList<String>> classMap, HashMap<String, ArrayList<String>> overrideMap)
    {
       if (classMap.size() == 0 && overrideMap.size() == 0)
@@ -326,7 +346,7 @@
       {
          return overrideMap;
       }
-      
+
       for (String key : overrideMap.keySet())
       {
          classMap.put(key, overrideMap.get(key));

Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AnnotationDependencyBuilderListItem.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AnnotationDependencyBuilderListItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AnnotationDependencyBuilderListItem.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,39 @@
+/*
+* 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.microcontainer.integration;
+
+import org.jboss.classadapter.spi.DependencyBuilderListItem;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class AnnotationDependencyBuilderListItem extends AspectDependencyBuilderListItem
+implements DependencyBuilderListItem
+{
+   AnnotationDependencyBuilderListItem(String name)
+   {
+      super(name);
+   }
+
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AspectDependencyBuilderListItem.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AspectDependencyBuilderListItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/AspectDependencyBuilderListItem.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,66 @@
+/*
+* 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.microcontainer.integration;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.classadapter.spi.DependencyBuilderListItem;
+import org.jboss.dependency.plugins.AbstractDependencyItem;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class AspectDependencyBuilderListItem implements DependencyBuilderListItem
+{
+   String dependencyName;
+   AspectDependencyBuilderListItem(String name)
+   {
+      this.dependencyName = name; 
+   }
+   
+   public void addDependency(Object ctx)
+   {
+      KernelControllerContext context = (KernelControllerContext)ctx;
+      BeanMetaData metaData = context.getBeanMetaData();
+      AbstractDependencyItem dependency = new AbstractDependencyItem(metaData.getName(), dependencyName, ControllerState.INSTANTIATED, ControllerState.INSTALLED);
+      DependencyInfo depends = context.getDependencyInfo();
+      depends.addIDependOn(dependency);
+   }
+   
+   public boolean equals(Object o)
+   {
+      if (o instanceof AspectDependencyBuilderListItem)
+      {
+         return dependencyName.equals(((AspectDependencyBuilderListItem)o).dependencyName);
+      }
+      return false;
+   }
+   
+   public int hashCode()
+   {
+      return dependencyName.hashCode();
+   }
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/LifecycleAspectDependencyBuilderListItem.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/LifecycleAspectDependencyBuilderListItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/main/org/jboss/aop/microcontainer/integration/LifecycleAspectDependencyBuilderListItem.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,87 @@
+/*
+* 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.microcontainer.integration;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractLifecycleCallbackMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.LifecycleCallbackMetaData;
+import org.jboss.classadapter.spi.DependencyBuilderListItem;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+class LifecycleAspectDependencyBuilderListItem extends AspectDependencyBuilderListItem implements DependencyBuilderListItem
+{
+   ControllerState state;
+   String installMethod;
+   String uninstallMethod;
+   
+   LifecycleAspectDependencyBuilderListItem(String beanName, ControllerState state, String installMethod, String uninstallMethod)
+   {
+      super(beanName);
+      this.state = state;
+      this.installMethod = installMethod;
+      this.uninstallMethod = uninstallMethod;
+   }
+
+   public boolean equals(Object o)
+   {
+      if (super.equals(o))
+      {
+         if (o instanceof LifecycleAspectDependencyBuilderListItem)
+         {
+            return state.equals(((LifecycleAspectDependencyBuilderListItem)o).state);
+         }
+      }
+      return false;
+   }
+   
+   public int hashCode()
+   {
+      return dependencyName.hashCode();
+   }
+
+   public void addDependency(Object ctx)
+   {
+      KernelControllerContext context = (KernelControllerContext)ctx;
+      BeanMetaData metaData = context.getBeanMetaData();
+      List<LifecycleCallbackMetaData> callbacks = metaData.getLifecycleCallbacks();
+      if (callbacks == null)
+      {
+         callbacks = new ArrayList<LifecycleCallbackMetaData>();
+         ((AbstractBeanMetaData)metaData).setLifecycleCallbacks(callbacks);
+      }
+      AbstractLifecycleCallbackMetaData callback = new AbstractLifecycleCallbackMetaData(dependencyName, state, ControllerState.INSTALLED, installMethod, uninstallMethod);
+      callbacks.add(callback);
+      
+      //We need to manually add the dependency since this is happening after the metadata visitors run
+      super.addDependency(ctx);
+   }
+}

Modified: projects/microcontainer/trunk/aop-mc-int/src/resources/schema/aop-beans_1_0.xsd
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/schema/aop-beans_1_0.xsd	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/schema/aop-beans_1_0.xsd	2007-03-07 14:36:24 UTC (rev 61194)
@@ -31,86 +31,67 @@
       </xsd:annotation>
    </xsd:element>
    
-   <xsd:complexType name="aspectType">
+   <xsd:complexType name="aspectBaseType">
       <xsd:annotation>
          <xsd:documentation>
            <![CDATA[
-           An aspect
+           Base type for aspects or lifecycle aspects
            ]]>
          </xsd:documentation>
       </xsd:annotation>
       <xsd:complexContent>
          <xsd:extension base="mc:beanfactoryType">
-            <xsd:attribute name="pointcut" type="xsd:string" use="required"/>
             <xsd:attribute name="manager-bean" type="xsd:string" use="optional"/>
             <xsd:attribute name="manager-property" type="xsd:string" use="optional"/>
+            <xsd:attribute name="method" type="xsd:string" use="optional"/>
          </xsd:extension>
       </xsd:complexContent>
    </xsd:complexType>
-<!--   
-   <xsd:element name="lifecycle" type="lifecycleType">
+   
+   <xsd:complexType name="aspectType">
       <xsd:annotation>
          <xsd:documentation>
            <![CDATA[
-           An aspect intercepting when a bean is installed/uninstalled
-           ]]>
-         </xsd:documentation>
-      </xsd:annotation>
-   </xsd:element>
--->
-   <xsd:complexType name="lifecycleType">
-      <xsd:annotation>
-         <xsd:documentation>
-           <![CDATA[
            An aspect
            ]]>
          </xsd:documentation>
       </xsd:annotation>
       <xsd:complexContent>
-         <xsd:extension base="mc:beanfactoryType">
-            <xsd:attribute name="pointcut" type="xsd:string" use="optional"/>
-            <xsd:attribute name="manager-bean" type="xsd:string" use="optional"/>
-            <xsd:attribute name="manager-property" type="xsd:string" use="optional"/>
-            <xsd:attribute name="classes" type="xsd:string" use="required"/>
-            <xsd:attribute name="method" type="xsd:string" use="optional"/>
+         <xsd:extension base="aspectBaseType">
+            <xsd:attribute name="pointcut" type="xsd:string" use="required"/>
          </xsd:extension>
       </xsd:complexContent>
    </xsd:complexType>
-   
-   <xsd:element name="lifecycle-configure" type="lifecycleConfigureType">
+
+   <xsd:complexType name="lifecycleType">
       <xsd:annotation>
          <xsd:documentation>
            <![CDATA[
-           An aspect intercepting when a bean is configured/unconfigured
+           A lifecycle aspect
            ]]>
          </xsd:documentation>
       </xsd:annotation>
-   </xsd:element>
-   
-   <xsd:complexType name="lifecycleConfigureType">
-      <xsd:annotation>
-         <xsd:documentation>
-           <![CDATA[
-           An aspect intercepting when a bean is configured/unconfigured
-           ]]>
-         </xsd:documentation>
-      </xsd:annotation>
       <xsd:complexContent>
-         <xsd:extension base="lifecycleType"/>
+         <xsd:extension base="aspectBaseType">
+            <xsd:attribute name="classes" type="xsd:string" use="optional"/>
+            <xsd:attribute name="expr" type="xsd:string" use="optional"/>
+            <xsd:attribute name="install" type="xsd:string" use="optional"/>
+            <xsd:attribute name="uninstall" type="xsd:string" use="optional"/>
+         </xsd:extension>
       </xsd:complexContent>
    </xsd:complexType>
    
-   <xsd:element name="lifecycle-create" type="lifecycleCreateType">
+   <xsd:element name="lifecycle-configure" type="lifecycleType">
       <xsd:annotation>
          <xsd:documentation>
            <![CDATA[
-           An aspect intercepting when a bean is created/destroyed
+           An aspect intercepting when a bean is configured/unconfigured
            ]]>
          </xsd:documentation>
       </xsd:annotation>
    </xsd:element>
    
-   <xsd:complexType name="lifecycleCreateType">
+   <xsd:element name="lifecycle-create" type="lifecycleType">
       <xsd:annotation>
          <xsd:documentation>
            <![CDATA[
@@ -118,22 +99,9 @@
            ]]>
          </xsd:documentation>
       </xsd:annotation>
-      <xsd:complexContent>
-         <xsd:extension base="lifecycleType"/>
-      </xsd:complexContent>
-   </xsd:complexType>
-   
-   <xsd:element name="lifecycle-describe" type="lifecycleDescribeType">
-      <xsd:annotation>
-         <xsd:documentation>
-           <![CDATA[
-           An aspect intercepting when a bean is described/undescribed
-           ]]>
-         </xsd:documentation>
-      </xsd:annotation>
    </xsd:element>
-   
-   <xsd:complexType name="lifecycleDescribeType">
+
+   <xsd:element name="lifecycle-describe" type="lifecycleType">
       <xsd:annotation>
          <xsd:documentation>
            <![CDATA[
@@ -141,22 +109,9 @@
            ]]>
          </xsd:documentation>
       </xsd:annotation>
-      <xsd:complexContent>
-         <xsd:extension base="lifecycleType"/>
-      </xsd:complexContent>
-   </xsd:complexType>
-   
-   <xsd:element name="lifecycle-install" type="lifecycleInstallType">
-      <xsd:annotation>
-         <xsd:documentation>
-           <![CDATA[
-           An aspect intercepting when a bean is installed/uninstalled
-           ]]>
-         </xsd:documentation>
-      </xsd:annotation>
    </xsd:element>
-   
-   <xsd:complexType name="lifecycleInstallType">
+
+   <xsd:element name="lifecycle-install" type="lifecycleType">
       <xsd:annotation>
          <xsd:documentation>
            <![CDATA[
@@ -164,22 +119,9 @@
            ]]>
          </xsd:documentation>
       </xsd:annotation>
-      <xsd:complexContent>
-         <xsd:extension base="lifecycleType"/>
-      </xsd:complexContent>
-   </xsd:complexType>
-   
-   <xsd:element name="lifecycle-instantiate" type="lifecycleInstantiateType">
-      <xsd:annotation>
-         <xsd:documentation>
-           <![CDATA[
-           An aspect intercepting when a bean is instantiated/uninstantiated
-           ]]>
-         </xsd:documentation>
-      </xsd:annotation>
    </xsd:element>
    
-   <xsd:complexType name="lifecycleInstantiateType">
+   <xsd:element name="lifecycle-instantiate" type="lifecycleType">
       <xsd:annotation>
          <xsd:documentation>
            <![CDATA[
@@ -187,22 +129,9 @@
            ]]>
          </xsd:documentation>
       </xsd:annotation>
-      <xsd:complexContent>
-         <xsd:extension base="lifecycleType"/>
-      </xsd:complexContent>
-   </xsd:complexType>
-   
-   <xsd:element name="lifecycle-start" type="lifecycleStartType">
-      <xsd:annotation>
-         <xsd:documentation>
-           <![CDATA[
-           An aspect intercepting when a bean is started/stopped
-           ]]>
-         </xsd:documentation>
-      </xsd:annotation>
    </xsd:element>
    
-   <xsd:complexType name="lifecycleStartType">
+   <xsd:element name="lifecycle-start" type="lifecycleType">
       <xsd:annotation>
          <xsd:documentation>
            <![CDATA[
@@ -210,9 +139,6 @@
            ]]>
          </xsd:documentation>
       </xsd:annotation>
-      <xsd:complexContent>
-         <xsd:extension base="lifecycleType"/>
-      </xsd:complexContent>
-   </xsd:complexType>
-   
+   </xsd:element>
+
 </xsd:schema>

Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackTestCaseNotAutomatic.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackTestCaseNotAutomatic.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackTestCaseNotAutomatic.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+   
+   <bean name="LifecycleCallback" class="org.jboss.test.microcontainer.support.SimpleLifecycleCallback"/>
+   
+   <bean name="LifecycleCallback$Binding" class="org.jboss.aop.microcontainer.beans.LifecycleBinding">
+      <property name="callbackBean">LifecycleCallback</property>
+      <property name="manager"><inject bean="AspectManager"/></property>
+      <property name="classes">org.jboss.test.microcontainer.support.SimpleBeanImpl</property>
+      <property name="state">Configured</property>
+   </bean>
+            
+   <bean name="Intercepted" class="org.jboss.test.microcontainer.support.SimpleBeanImpl"/>
+   
+</deployment>

Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="Dependency" class="java.lang.Object"/>
+
+</deployment>

Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+   
+   <bean name="LifecycleCallback" class="org.jboss.test.microcontainer.support.LifecycleCallbackWithBeanDependency">
+      <property name="dependency"><inject bean="Dependency"/></property>
+   </bean>
+   
+   <bean name="LifecycleCallback$Binding" class="org.jboss.aop.microcontainer.beans.LifecycleBinding">
+      <property name="callbackBean">LifecycleCallback</property>
+      <property name="manager"><inject bean="AspectManager"/></property>
+      <property name="classes">org.jboss.test.microcontainer.support.SimpleBeanImpl</property>
+      <property name="state">Configured</property>
+   </bean>
+            
+   <bean name="Intercepted" class="org.jboss.test.microcontainer.support.SimpleBeanImpl"/>
+   
+</deployment>

Deleted: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.xml	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-   <bean name="JBossServer" class="org.jboss.test.microcontainer.support.deployers.JBossServer"/>
-
-   <bean name="ProfileService" class="java.lang.Object"/>
-   
-   <bean name="JMXKernel" class="org.jboss.test.microcontainer.support.deployers.JMXKernel">
-      <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
-      <property name="serverImpl"><inject bean="JBossServer"/></property>
-   </bean>
-
-   <bean name="AspectManager" class="org.jboss.test.microcontainer.support.deployers.AspectManagerBean">
-      <constructor>
-         <parameter><![CDATA[
-	         <aop>
-				</aop>]]>
-	      </parameter>
-      </constructor>
-       <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
-   </bean>
-
-   <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
-      name="Deployers"
-      class="org.jboss.test.microcontainer.support.deployers.DeployerAspects"
-      classes="org.jboss.test.microcontainer.support.deployers.IDeployer"
-      manager-bean="AspectManager"
-      manager-property="aspectManager"
-      pointcut="execution(* $instanceof{org.jboss.test.microcontainer.support.deployers.IDeployer}->$implements{org.jboss.test.microcontainer.support.deployers.IDeployer}(..))">
-   </aop:lifecycle-configure>
-
-   
-   <bean name="MainDeployer" class="org.jboss.test.microcontainer.support.deployers.SampleMainDeployer">
-      <property name="deployers">
-         <list>
-            <bean name="SampleDeployer1" class="org.jboss.test.microcontainer.support.deployers.SampleDeployer">
-               <property name="type">aop</property>
-            </bean>
-            <bean name="SampleDeployer2" class="org.jboss.test.microcontainer.support.deployers.SampleDeployer">
-               <property name="type">beans</property>
-            </bean>
-         </list>
-      </property>
-   </bean>
-
-</deployment>

Deleted: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.xml	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-
-   <bean name="Repository" class="org.jboss.metadata.plugins.repository.basic.BasicMetaDataRepository"/>
-
-   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
-      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
-   </bean>
-
-   <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
-      name="DeployerAspects"
-      class="org.jboss.test.microcontainer.support.deployers.DeployerAspects"
-      classes="org.jboss.test.microcontainer.support.deployers.IDeployer"
-      manager-bean="AspectManager"
-      pointcut="execution(* $instanceof{org.jboss.test.microcontainer.support.deployers.IDeployer}->*(..))">
-   </aop:lifecycle-configure>
-   <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
-      name="MainDeployerAspects"
-      class="org.jboss.test.microcontainer.support.deployers.MainDeployerAspects"
-      classes="org.jboss.test.microcontainer.support.deployers.IMainDeployer"
-      manager-bean="AspectManager"
-      pointcut="execution(* $instanceof{org.jboss.test.microcontainer.support.deployers.IMainDeployer}->*(..))">
-   </aop:lifecycle-configure>
-
-   <bean name="MainDeployer" class="org.jboss.test.microcontainer.support.deployers.SampleMainDeployer">
-      <property name="deployers">
-         <list>
-            <bean name="SampleDeployer1" class="org.jboss.test.microcontainer.support.deployers.SampleDeployer">
-               <property name="type">aop</property>
-            </bean>
-            <bean name="SampleDeployer2" class="org.jboss.test.microcontainer.support.deployers.SampleDeployer">
-               <property name="type">beans</property>
-            </bean>
-         </list>
-      </property>
-   </bean>
-</deployment>

Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackTestCaseNotAutomatic.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackTestCaseNotAutomatic.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackTestCaseNotAutomatic.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+
+   <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
+               name="LifecycleCallback"
+               class="org.jboss.test.microcontainer.support.SimpleLifecycleCallback"
+               classes="org.jboss.test.microcontainer.support.SimpleBeanImpl">
+		<property name="testProperty">Test123</property>               
+   </aop:lifecycle-configure>
+            
+   <bean name="Intercepted" class="org.jboss.test.microcontainer.support.SimpleBeanImpl"/>
+   
+</deployment>

Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="Dependency" class="java.lang.Object"/>
+
+</deployment>

Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="TheAspectManager" class="org.jboss.aop.AspectManager">
+      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
+   </bean>
+
+   <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
+               name="LifecycleCallback"
+               class="org.jboss.test.microcontainer.support.LifecycleCallbackWithBeanDependency"
+               expr="class(org.jboss.test.microcontainer.support.SimpleBeanImpl)"
+               manager-bean="TheAspectManager">
+      <property name="dependency"><inject bean="Dependency"/></property>
+   </aop:lifecycle-configure>
+
+   <bean name="Intercepted" class="org.jboss.test.microcontainer.support.SimpleBeanImpl"/>
+   
+</deployment>

Modified: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JMXLifecycleTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JMXLifecycleTestCase.xml	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JMXLifecycleTestCase.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -14,9 +14,8 @@
 
    <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
                name="DependencyAdvice"
-               class="org.jboss.aop.microcontainer.aspects.jmx.JMXIntroduction"
-               classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX"
-               pointcut="execution(* @org.jboss.aop.microcontainer.aspects.jmx.JMX->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
+               class="org.jboss.aop.microcontainer.aspects.jmx.JMXLifecycleCallback"
+               classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX">
       <property name="mbeanServer"><inject bean="MBeanServer"/></property>
    </aop:lifecycle-configure>
 

Modified: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JndiLifeCycleTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JndiLifeCycleTestCase.xml	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/JndiLifeCycleTestCase.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -10,9 +10,8 @@
 
    <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
       name="DependencyAdvice"
-      class="org.jboss.aop.microcontainer.aspects.jndi.JndiIntroduction"
-      classes="@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding"
-      pointcut="execution(* @org.jboss.aop.microcontainer.aspects.jndi.JndiBinding->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
+      class="org.jboss.aop.microcontainer.aspects.jndi.JndiLifecycleCallback"
+      classes="@org.jboss.aop.microcontainer.aspects.jndi.JndiBinding">
       <property name="env">
          <map class="java.util.Properties" keyClass="java.lang.String" valueClass="java.lang.String">
             <entry><key>java.naming.factory.initial</key><value>org.jboss.test.microcontainer.support.jndi.MockInitialContextFactory</value></entry>

Deleted: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/LifecycleAspectTestCaseNotAutomatic.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/LifecycleAspectTestCaseNotAutomatic.xml	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/LifecycleAspectTestCaseNotAutomatic.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<deployment xmlns="urn:jboss:bean-deployer:2.0">
-   <bean name="Repository" class="org.jboss.metadata.plugins.repository.basic.BasicMetaDataRepository"/>
-
-   <bean name="AspectManager" class="org.jboss.aop.AspectManager">
-      <constructor factoryClass="org.jboss.aop.AspectManager" factoryMethod="instance"/>
-   </bean>
-
-   <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
-               name="JMXLifecycle"
-               class="org.jboss.test.microcontainer.support.TestAspect"
-               classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX"
-               method="foo"
-               pointcut="execution(* @org.jboss.aop.microcontainer.aspects.jmx.JMX->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
-      <property name="shouldInvoke">false</property>
-   </aop:lifecycle-configure>
-
-   <bean name="Bean" class="org.jboss.test.microcontainer.support.SimpleBeanImpl">
-      <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="", exposedInterface=org.jboss.test.microcontainer.support.SimpleBean.class)</annotation>
-   </bean>
-</deployment>

Modified: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/LifecycleTestCaseNotAutomatic.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/LifecycleTestCaseNotAutomatic.xml	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/LifecycleTestCaseNotAutomatic.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -14,44 +14,38 @@
 
    <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
                name="ConfigureAdvice"
-               class="org.jboss.test.microcontainer.support.LifecycleInterceptor"
-               classes="@org.jboss.test.microcontainer.support.Configure"
-               pointcut="execution(* @org.jboss.test.microcontainer.support.Configure->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
+               class="org.jboss.test.microcontainer.support.LifecycleCallback"
+               classes="@org.jboss.test.microcontainer.support.Configure">
    </aop:lifecycle-configure>
 
    <aop:lifecycle-create xmlns:aop="urn:jboss:aop-beans:1.0"
                name="CreateAdvice"
-               class="org.jboss.test.microcontainer.support.LifecycleInterceptor"
-               classes="@org.jboss.test.microcontainer.support.Create"
-               pointcut="execution(* @org.jboss.test.microcontainer.support.Create->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
+               class="org.jboss.test.microcontainer.support.LifecycleCallback"
+               classes="@org.jboss.test.microcontainer.support.Create">
    </aop:lifecycle-create>
 
    <aop:lifecycle-describe xmlns:aop="urn:jboss:aop-beans:1.0"
                name="DescribeAdvice"
-               class="org.jboss.test.microcontainer.support.LifecycleInterceptor"
-               classes="@org.jboss.test.microcontainer.support.Describe"
-               pointcut="execution(* @org.jboss.test.microcontainer.support.Describe->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
+               class="org.jboss.test.microcontainer.support.LifecycleCallback"
+               classes="@org.jboss.test.microcontainer.support.Describe">
    </aop:lifecycle-describe>
 
    <aop:lifecycle-install xmlns:aop="urn:jboss:aop-beans:1.0"
                name="InstallAdvice"
-               class="org.jboss.test.microcontainer.support.LifecycleInterceptor"
-               classes="@org.jboss.test.microcontainer.support.Install"
-               pointcut="execution(* @org.jboss.test.microcontainer.support.Install->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
+               class="org.jboss.test.microcontainer.support.LifecycleCallback"
+               classes="@org.jboss.test.microcontainer.support.Install">
    </aop:lifecycle-install>
 
    <aop:lifecycle-instantiate xmlns:aop="urn:jboss:aop-beans:1.0"
                name="InstantiateAdvice"
-               class="org.jboss.test.microcontainer.support.LifecycleInterceptor"
-               classes="@org.jboss.test.microcontainer.support.Instantiate"
-               pointcut="execution(* @org.jboss.test.microcontainer.support.Instantiate->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
+               class="org.jboss.test.microcontainer.support.LifecycleCallback"
+               classes="@org.jboss.test.microcontainer.support.Instantiate">
    </aop:lifecycle-instantiate>
 
    <aop:lifecycle-start xmlns:aop="urn:jboss:aop-beans:1.0"
                name="StartAdvice"
-               class="org.jboss.test.microcontainer.support.LifecycleInterceptor"
-               classes="@org.jboss.test.microcontainer.support.Start"
-               pointcut="execution(* @org.jboss.test.microcontainer.support.Start->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
+               class="org.jboss.test.microcontainer.support.LifecycleCallback"
+               classes="@org.jboss.test.microcontainer.support.Start">
    </aop:lifecycle-start>
 
    <bean name="ConfigureBean" class="org.jboss.test.microcontainer.support.SimpleBeanImpl">

Modified: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/MultipleLifecycleTestCase.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/MultipleLifecycleTestCase.xml	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/MultipleLifecycleTestCase.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -14,17 +14,15 @@
 
    <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
                name="JMXAdvice"
-               class="org.jboss.aop.microcontainer.aspects.jmx.JMXIntroduction"
-               classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX"
-               pointcut="execution(* @org.jboss.aop.microcontainer.aspects.jmx.JMX->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
+               class="org.jboss.aop.microcontainer.aspects.jmx.JMXLifecycleCallback"
+               classes="@org.jboss.aop.microcontainer.aspects.jmx.JMX">
       <property name="mbeanServer"><inject bean="MBeanServer"/></property>
    </aop:lifecycle-configure>
 
    <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
                name="JndiAdvice"
-               class="org.jboss.test.microcontainer.support.CalledInterceptor"
-               classes="org.jboss.test.microcontainer.support.SimpleBeanImpl"
-               pointcut="execution(* org.jboss.test.microcontainer.support.SimpleBeanImpl->$implements{org.jboss.kernel.spi.dependency.KernelControllerContextAware}(..))">
+               class="org.jboss.test.microcontainer.support.SimpleLifecycleCallback"
+               classes="org.jboss.test.microcontainer.support.SimpleBeanImpl">
    </aop:lifecycle-configure>
 
    <bean name="Bean" class="org.jboss.test.microcontainer.support.SimpleBeanImpl">

Added: projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/NonDefaultMethodsLifecycleCallbackTestCaseNotAutomatic.xml
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/NonDefaultMethodsLifecycleCallbackTestCaseNotAutomatic.xml	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/resources/tests/org/jboss/test/microcontainer/test/NonDefaultMethodsLifecycleCallbackTestCaseNotAutomatic.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="TheAspectManager" class="org.jboss.test.microcontainer.support.AspectManagerBean">
+   </bean>
+
+   <aop:lifecycle-configure xmlns:aop="urn:jboss:aop-beans:1.0"
+               name="LifecycleCallback"
+               class="org.jboss.test.microcontainer.support.NonDefaultMethodsLifecycleCallback"
+               classes="org.jboss.test.microcontainer.support.SimpleBeanImpl"
+               install="init"
+               uninstall="uninit"
+               manager-bean="TheAspectManager"
+               manager-property="manager">
+   </aop:lifecycle-configure>
+   
+
+   <bean name="Intercepted" class="org.jboss.test.microcontainer.support.SimpleBeanImpl"/>
+   
+</deployment>

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/AspectManagerBean.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/AspectManagerBean.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/AspectManagerBean.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,39 @@
+/*
+* 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.test.microcontainer.support;
+
+import org.jboss.aop.AspectManager;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AspectManagerBean
+{
+   AspectManager manager = AspectManager.instance();
+   
+   public AspectManager getManager()
+   {
+      return manager;
+   }
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/LifecycleCallback.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/LifecycleCallback.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/LifecycleCallback.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,79 @@
+/*
+* 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.test.microcontainer.support;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.metadata.spi.MetaData;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifecycleCallback
+{
+   public static Map<String, ArrayList<Class>> interceptions = new HashMap<String, ArrayList<Class>>();
+   Class[] lifecycleAnnotations = new Class[] {Configure.class, Create.class, Describe.class, Install.class, Instantiate.class, Start.class}; 
+   public String getName()
+   {
+      return this.getClass().getName();
+   }
+
+   public void install(KernelControllerContext context)
+   {
+      handle(context);
+   }
+   
+   public void uninstall(KernelControllerContext context) 
+   {
+      handle(context);
+   }
+   
+   private void handle(KernelControllerContext context)
+   {
+      for (int i = 0 ; i < lifecycleAnnotations.length ; i++)
+      {
+         MetaData metaData = context.getMetaData();
+         Object cur = metaData.getAnnotation(lifecycleAnnotations[i]);
+         if (cur != null)
+         {
+            addInterception(context, lifecycleAnnotations[i]);
+         }
+      }
+   }
+   
+   private void addInterception(KernelControllerContext context, Class annotation)
+   {
+      String name = (String)context.getName();
+      ArrayList<Class> beanInterceptions = interceptions.get(name);
+      if (beanInterceptions == null)
+      {
+         beanInterceptions = new ArrayList<Class>();
+         interceptions.put(name, beanInterceptions);
+      }
+      beanInterceptions.add(annotation);
+   }
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/LifecycleCallbackWithBeanDependency.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/LifecycleCallbackWithBeanDependency.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/LifecycleCallbackWithBeanDependency.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,70 @@
+/*
+* 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.test.microcontainer.support;
+
+import java.util.ArrayList;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class LifecycleCallbackWithBeanDependency
+{
+   Object dependency;
+   public static ArrayList<Handled>  interceptions = new ArrayList<Handled>();
+   public void install(KernelControllerContext context)
+   {
+      interceptions.add(new Handled((String)context.getName(), context.getState()));
+   }
+   
+   public void uninstall(KernelControllerContext context)
+   {
+      interceptions.add(new Handled((String)context.getName(), context.getState()));
+   }
+   
+   public static class Handled
+   {
+      public String contextName;
+      public ControllerState fromState;
+
+      public Handled(String contextName, ControllerState fromState)
+      {
+         super();
+         this.contextName = contextName;
+         this.fromState = fromState;
+      }
+   }
+
+   public Object getDependency()
+   {
+      return dependency;
+   }
+
+   public void setDependency(Object dependency)
+   {
+      this.dependency = dependency;
+   }
+}

Deleted: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/LifecycleInterceptor.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/LifecycleInterceptor.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/LifecycleInterceptor.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -1,75 +0,0 @@
-/*
-* 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.test.microcontainer.support;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class LifecycleInterceptor implements Interceptor
-{
-   public static Map<String, ArrayList<Class>> interceptions = new HashMap<String, ArrayList<Class>>();
-   Class[] lifecycleAnnotations = new Class[] {Configure.class, Create.class, Describe.class, Install.class, Instantiate.class, Start.class}; 
-   public String getName()
-   {
-      return this.getClass().getName();
-   }
-
-   public Object invoke(Invocation invocation) throws Throwable
-   {
-      MethodInvocation mi = (MethodInvocation)invocation;
-      KernelControllerContext context = (KernelControllerContext) mi.getArguments()[0];
-
-      for (int i = 0 ; i < lifecycleAnnotations.length ; i++)
-      {
-         Object cur = invocation.resolveClassAnnotation(lifecycleAnnotations[i]);
-         if (cur != null)
-         {
-            addInterception(context, lifecycleAnnotations[i]);
-         }
-      }
-      
-      return null;
-   }
-   
-   private void addInterception(KernelControllerContext context, Class annotation)
-   {
-      String name = (String)context.getName();
-      ArrayList<Class> beanInterceptions = interceptions.get(name);
-      if (beanInterceptions == null)
-      {
-         beanInterceptions = new ArrayList<Class>();
-         interceptions.put(name, beanInterceptions);
-      }
-      beanInterceptions.add(annotation);
-   }
-}

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/NonDefaultMethodsLifecycleCallback.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/NonDefaultMethodsLifecycleCallback.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/NonDefaultMethodsLifecycleCallback.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,63 @@
+/*
+* 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.test.microcontainer.support;
+
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class NonDefaultMethodsLifecycleCallback
+{
+   public static boolean inited;
+   public static boolean uninited;
+   
+   public void install(KernelControllerContext context)
+   {
+      throw new IllegalStateException("install should not have been called");
+   }
+   
+   public void uninstall(KernelControllerContext context)
+   {
+      throw new IllegalStateException("uninstall should not have been called");      
+   }
+
+   public void init(KernelControllerContext context)
+   {
+      if (inited)
+      {
+         throw new IllegalStateException("Has already been installed");
+      }
+      inited = true;
+   }
+   
+   public void uninit(KernelControllerContext context)
+   {
+      if (uninited)
+      {
+         throw new IllegalStateException("Has already been uninstalled");
+      }
+      uninited = true;
+   }
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/SimpleLifecycleCallback.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/SimpleLifecycleCallback.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/support/SimpleLifecycleCallback.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,70 @@
+/*
+* 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.test.microcontainer.support;
+
+import java.util.ArrayList;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class SimpleLifecycleCallback
+{
+   public static ArrayList<Handled>  interceptions = new ArrayList<Handled>();
+   private String testProperty;
+   public void install(KernelControllerContext context)
+   {
+      interceptions.add(new Handled((String)context.getName(), context.getState()));
+   }
+   
+   public void uninstall(KernelControllerContext context)
+   {
+      interceptions.add(new Handled((String)context.getName(), context.getState()));
+   }
+   
+   public String getTestProperty()
+   {
+      return testProperty;
+   }
+
+   public void setTestProperty(String testProperty)
+   {
+      this.testProperty = testProperty;
+   }
+   
+   public static class Handled
+   {
+      public String contextName;
+      public ControllerState fromState;
+
+      public Handled(String contextName, ControllerState fromState)
+      {
+         super();
+         this.contextName = contextName;
+         this.fromState = fromState;
+      }
+   }
+}

Modified: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/AspectMCAllTestSuite.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/AspectMCAllTestSuite.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/AspectMCAllTestSuite.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -55,6 +55,7 @@
       suite.addTest(InterceptorWithOverriddenMethodAnnotationDependencyForChildTestCase.suite());
       suite.addTest(InterceptorWithOverriddenMethodAnnotationDependencyTestCase.suite());
       suite.addTest(IntroductionDependencyTestCase.suite());
+      suite.addTest(LifecycleTestCase.suite());
       suite.addTest(JMXDecoratedTestCase.suite());
       suite.addTest(JMXLifecycleTestCase.suite());
       suite.addTest(JndiDecoratedTestCase.suite());
@@ -63,6 +64,9 @@
       suite.addTest(MixinTestCase.suite());
       suite.addTest(MultipleLifecycleTestCase.suite());
       suite.addTest(ScopingAopTestCase.suite());
+      suite.addTest(CreatedBeansLifecycleCallbackTestCase.suite());
+      suite.addTest(CreatedBeansLifecycleCallbackWithDependencyTestCase.suite());
+      suite.addTest(NonDefaultMethodsLifecycleCallbackTestCase.suite());
 
       return suite;
    }

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackTestCase.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,86 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, 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.test.microcontainer.test;
+
+import junit.framework.Test;
+
+import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.test.microcontainer.support.SimpleLifecycleCallback;
+
+/**
+ * Tests the beans that are created under the hood using the <aop:configure/> <aop:instantiate/> etc.
+ * configuration 
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class CreatedBeansLifecycleCallbackTestCase extends AOPMicrocontainerTest
+{
+   public static Test suite()
+   {
+      return suite(CreatedBeansLifecycleCallbackTestCase.class);
+   }
+   
+   public CreatedBeansLifecycleCallbackTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testLifecycleInterceptions() throws Exception
+   {
+      boolean itworked = false;
+      try
+      {
+         SimpleLifecycleCallback.interceptions.clear();
+         deploy("CreatedBeansLifecycleCallbackTestCaseNotAutomatic.xml");
+         getCheckBeanExists("Intercepted");
+
+         assertEquals(1, SimpleLifecycleCallback.interceptions.size());
+         SimpleLifecycleCallback.Handled handled = SimpleLifecycleCallback.interceptions.get(0);
+         assertEquals("Intercepted", handled.contextName);
+         assertEquals(ControllerState.INSTANTIATED, handled.fromState);
+         
+         itworked = true;
+         
+      }
+      finally
+      {
+         SimpleLifecycleCallback.interceptions.clear();
+         undeploy("CreatedBeansLifecycleCallbackTestCaseNotAutomatic.xml");
+         if (itworked)
+         {
+            assertEquals(1, SimpleLifecycleCallback.interceptions.size());
+            SimpleLifecycleCallback.Handled handled = SimpleLifecycleCallback.interceptions.get(0);
+            assertEquals("Intercepted", handled.contextName);
+            assertEquals(ControllerState.CONFIGURED, handled.fromState);
+         }
+      }
+   }
+   
+   public Object getCheckBeanExists(String name)
+   {
+      Object bean = getBean(name);
+      assertNotNull(bean);
+      return bean;
+   }
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackWithDependencyTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackWithDependencyTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/CreatedBeansLifecycleCallbackWithDependencyTestCase.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,362 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, 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.test.microcontainer.test;
+
+import junit.framework.Test;
+
+import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.test.microcontainer.support.LifecycleCallbackWithBeanDependency;
+import org.jboss.test.microcontainer.support.SimpleBean;
+
+/**
+ * Tests the beans that are created under the hood using the <aop:configure/> <aop:instantiate/> etc.
+ * configuration 
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class CreatedBeansLifecycleCallbackWithDependencyTestCase extends AOPMicrocontainerTest
+{
+   public static Test suite()
+   {
+      return suite(CreatedBeansLifecycleCallbackWithDependencyTestCase.class);
+   }
+   
+   public CreatedBeansLifecycleCallbackWithDependencyTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testLifecycleInterceptionsWithDependencyCorrectOrder() throws Exception
+   {
+      deploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+      try
+      {
+         Object dependency = (Object) getCheckBeanExists("Dependency");
+         assertNotNull(dependency);
+         boolean itworked = false;
+
+         LifecycleCallbackWithBeanDependency.interceptions.clear();
+         deploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+         try
+         {
+            validate();
+            getCheckBeanExists("Intercepted");
+            LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
+            assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+            LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+            assertEquals("Intercepted", handled.contextName);
+            assertEquals(ControllerState.INSTANTIATED, handled.fromState);
+            assertNotNull(lifecycle.getDependency());
+            assertEquals(dependency, lifecycle.getDependency());
+            itworked = true;
+         }
+         finally
+         {
+            LifecycleCallbackWithBeanDependency.interceptions.clear();
+            undeploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+            if (itworked)
+            {
+               assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+               LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+               assertEquals("Intercepted", handled.contextName);
+               assertEquals(ControllerState.CONFIGURED, handled.fromState);
+            }
+         }
+      }
+      finally
+      {
+         undeploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+      }
+   }
+   
+   public void testLifecycleInterceptionsWithDependencyWrongOrder() throws Exception
+   {
+      deploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+      try
+      {
+         SimpleBean bean;
+         try
+         {
+            bean = (SimpleBean) getBean("Intercepted");
+            fail("'Interceped' should not be installed yet");
+         }
+         catch (IllegalStateException expected)
+         {
+         }
+         
+         bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
+         assertNull("This should not be deployed until the interceptor is", bean);
+
+         boolean itworked = false;
+         LifecycleCallbackWithBeanDependency.interceptions.clear();
+         deploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+         try
+         {
+            validate();
+            Object dependency = getCheckBeanExists("Dependency");
+            LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
+            getCheckBeanExists("Intercepted");
+            assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+            LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+            assertEquals("Intercepted", handled.contextName);
+            assertEquals(ControllerState.INSTANTIATED, handled.fromState);
+            assertNotNull(lifecycle.getDependency());
+            assertEquals(dependency, lifecycle.getDependency());
+            
+            itworked = true;
+            
+         }
+         finally
+         {
+            LifecycleCallbackWithBeanDependency.interceptions.clear();
+            undeploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+            if (itworked)
+            {
+               assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+               LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+               assertEquals("Intercepted", handled.contextName);
+               assertEquals(ControllerState.CONFIGURED, handled.fromState);
+            }
+
+            try
+            {
+               bean = (SimpleBean) getBean("Intercepted");
+               fail("'Interceped' should not be installed yet");
+            }
+            catch (IllegalStateException expected)
+            {
+            }
+            
+            bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
+            assertNull("This should not be deployed until the interceptor is", bean);
+         }
+      }
+      finally
+      {
+         undeploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+      }
+   }
+   
+   public void testLifecycleInterceptionsWithDependencyRedeploy() throws Exception
+   {
+      deploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+      try
+      {
+         SimpleBean bean;
+         try
+         {
+            bean = (SimpleBean) getBean("Intercepted");
+            fail("'Interceped' should not be installed yet");
+         }
+         catch (IllegalStateException expected)
+         {
+         }
+         
+         bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
+         assertNull("This should not be deployed until the interceptor is", bean);
+
+         boolean itworked = false;
+         LifecycleCallbackWithBeanDependency.interceptions.clear();
+         deploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+         try
+         {
+            validate();
+            Object dependency = getCheckBeanExists("Dependency");
+            LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
+            getCheckBeanExists("Intercepted");
+            assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+            LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+            assertEquals("Intercepted", handled.contextName);
+            assertEquals(ControllerState.INSTANTIATED, handled.fromState);
+            assertNotNull(lifecycle.getDependency());
+            assertEquals(dependency, lifecycle.getDependency());
+            
+            itworked = true;
+            
+         }
+         finally
+         {
+            LifecycleCallbackWithBeanDependency.interceptions.clear();
+            undeploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+            if (itworked)
+            {
+               assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+               LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+               assertEquals("Intercepted", handled.contextName);
+               assertEquals(ControllerState.CONFIGURED, handled.fromState);
+            }
+
+            try
+            {
+               bean = (SimpleBean) getBean("Intercepted");
+               fail("'Interceped' should not be installed yet");
+            }
+            catch (IllegalStateException expected)
+            {
+            }
+            
+            bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
+            assertNull("This should not be deployed until the interceptor is", bean);
+         }
+         
+         try
+         {
+            bean = (SimpleBean) getBean("Intercepted");
+            fail("'Interceped' should not be installed yet");
+         }
+         catch (IllegalStateException expected)
+         {
+            KernelControllerContext context = getControllerContext("Intercepted", ControllerState.DESCRIBED);
+            assertNotNull(context);
+         }
+
+         itworked = false;
+         LifecycleCallbackWithBeanDependency.interceptions.clear();
+         deploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+         try
+         {
+            validate();
+            Object dependency = getCheckBeanExists("Dependency");
+            LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
+            getCheckBeanExists("Intercepted");
+            assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+            LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+            assertEquals("Intercepted", handled.contextName);
+            assertEquals(ControllerState.INSTANTIATED, handled.fromState);
+            assertNotNull(lifecycle.getDependency());
+            assertTrue("Should not be caching the lifecycle's callback across rebinding", dependency == lifecycle.getDependency());
+            
+            itworked = true;
+         }
+         finally
+         {
+            LifecycleCallbackWithBeanDependency.interceptions.clear();
+            undeploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+            if (itworked)
+            {
+               assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+               LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+               assertEquals("Intercepted", handled.contextName);
+               assertEquals(ControllerState.CONFIGURED, handled.fromState);
+            }
+
+            try
+            {
+               bean = (SimpleBean) getBean("Intercepted");
+               fail("'Interceped' should not be installed yet");
+            }
+            catch (IllegalStateException expected)
+            {
+            }
+            
+            bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
+            assertNull("This should not be deployed until the interceptor is", bean);
+         }
+      }
+      finally
+      {
+         undeploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+      }
+   }
+
+   public void testLifecycleInterceptionsWithDependencyRedeploy2() throws Exception
+   {
+      deploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+      try
+      {
+         Object dependency = getCheckBeanExists("Dependency");
+         boolean itworked = false;
+
+         LifecycleCallbackWithBeanDependency.interceptions.clear();
+         deploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+         try
+         {
+            validate();
+            getCheckBeanExists("Intercepted");
+            LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
+            assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+            LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+            assertEquals("Intercepted", handled.contextName);
+            assertEquals(ControllerState.INSTANTIATED, handled.fromState);
+            assertNotNull(lifecycle.getDependency());
+            assertTrue(dependency == lifecycle.getDependency());
+            itworked = true;
+         }
+         finally
+         {
+            LifecycleCallbackWithBeanDependency.interceptions.clear();
+            undeploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+            if (itworked)
+            {
+               assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+               LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+               assertEquals("Intercepted", handled.contextName);
+               assertEquals(ControllerState.CONFIGURED, handled.fromState);
+            }
+         }
+         
+         Object dependency2 = getCheckBeanExists("Dependency");
+         assertTrue(dependency == dependency2);
+         LifecycleCallbackWithBeanDependency.interceptions.clear();
+         deploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+         try
+         {
+            validate();
+            getCheckBeanExists("Intercepted");
+            LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
+            assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+            LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+            assertEquals("Intercepted", handled.contextName);
+            assertEquals(ControllerState.INSTANTIATED, handled.fromState);
+            assertNotNull(lifecycle.getDependency());
+            assertTrue(dependency == lifecycle.getDependency());
+            itworked = true;
+         }
+         finally
+         {
+            LifecycleCallbackWithBeanDependency.interceptions.clear();
+            undeploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+            if (itworked)
+            {
+               assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+               LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+               assertEquals("Intercepted", handled.contextName);
+               assertEquals(ControllerState.CONFIGURED, handled.fromState);
+            }
+         }
+      }
+      finally
+      {
+         undeploy("CreatedBeansLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+      }
+   }
+   
+   public Object getCheckBeanExists(String name)
+   {
+      Object bean = getBean(name);
+      assertNotNull(bean);
+      return bean;
+   }
+}

Deleted: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleAspectManagerJMXTestCase.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -1,95 +0,0 @@
-/*
-* 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.test.microcontainer.test;
-
-import java.util.HashSet;
-
-import junit.framework.Test;
-
-import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
-import org.jboss.test.microcontainer.support.deployers.DeployerAspects;
-import org.jboss.test.microcontainer.support.deployers.IMainDeployer;
-import org.jboss.test.microcontainer.support.deployers.SampleDeployer;
-import org.jboss.test.microcontainer.support.deployers.IDeployer.IDeployerMethod;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 1.1 $
- */
-public class DeployersLifecycleAspectManagerJMXTestCase extends AOPMicrocontainerTest
-{
-   public static Test suite()
-   {
-      return suite(DeployersLifecycleAspectManagerJMXTestCase.class);
-   }
-   
-   public DeployersLifecycleAspectManagerJMXTestCase(String name)
-   {
-      super(name);
-   }
-   
-   public void testBean() throws Exception
-   {
-      IMainDeployer md = (IMainDeployer) getBean("MainDeployer");
-      assertNotNull(md);
-
-      assertEquals("2 deployers", 2, md.getDeployers().size());
-
-      md.addDeployment("thing.xar");
-      md.process();
-
-      HashSet<IDeployerMethod> interceptedCalled = DeployerAspects.getCalled();
-      SampleDeployer d1 = (SampleDeployer) getBean("SampleDeployer1");
-      SampleDeployer d2 = (SampleDeployer) getBean("SampleDeployer2");
-      assertTrue("SampleDeployer1.prepareDeploy",
-            d1.getCalled().contains(IDeployerMethod.prepareDeploy));
-      assertTrue("SampleDeployer1.commitDeploy",
-            d1.getCalled().contains(IDeployerMethod.commitDeploy));
-      assertTrue("SampleDeployer2.prepareDeploy",
-            d2.getCalled().contains(IDeployerMethod.prepareDeploy));
-      assertTrue("SampleDeployer2.commitDeploy",
-            d2.getCalled().contains(IDeployerMethod.commitDeploy));
-
-      assertTrue("DeployerAspects.prepareDeploy",
-            interceptedCalled.contains(IDeployerMethod.prepareDeploy));
-      assertTrue("DeployerAspects.commitDeploy",
-            interceptedCalled.contains(IDeployerMethod.commitDeploy));
-
-      md.removeDeployment("thing.xar");
-      md.process();
-
-      assertTrue("SampleDeployer1.prepareUndeploy",
-            d1.getCalled().contains(IDeployerMethod.prepareUndeploy));
-      assertTrue("SampleDeployer1.commitUndeploy",
-            d1.getCalled().contains(IDeployerMethod.commitUndeploy));
-      assertTrue("SampleDeployer2.prepareUndeploy",
-            d2.getCalled().contains(IDeployerMethod.prepareUndeploy));
-      assertTrue("SampleDeployer2.commitUndeploy",
-            d2.getCalled().contains(IDeployerMethod.commitUndeploy));
-
-      assertTrue("DeployerAspects.prepareUndeploy",
-            interceptedCalled.contains(IDeployerMethod.prepareUndeploy));
-      assertTrue("DeployerAspects.commitUndeploy",
-            interceptedCalled.contains(IDeployerMethod.commitUndeploy));
-   }
-}

Deleted: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/DeployersLifecycleTestCase.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -1,102 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, 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.test.microcontainer.test;
-
-import java.util.HashSet;
-
-import junit.framework.Test;
-
-import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
-import org.jboss.test.microcontainer.support.deployers.DeployerAspects;
-import org.jboss.test.microcontainer.support.deployers.IMainDeployer;
-import org.jboss.test.microcontainer.support.deployers.MainDeployerAspects;
-import org.jboss.test.microcontainer.support.deployers.SampleDeployer;
-import org.jboss.test.microcontainer.support.deployers.IDeployer.IDeployerMethod;
-
-/**
- * Tests of deployer/main deployer type of aspects.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class DeployersLifecycleTestCase extends AOPMicrocontainerTest
-{
-   public static Test suite()
-   {
-      return suite(DeployersLifecycleTestCase.class);
-   }
-   
-   public DeployersLifecycleTestCase(String name)
-   {
-      super(name);
-   }
-   
-   public void testBean() throws Exception
-   {
-      IMainDeployer md = (IMainDeployer) getBean("MainDeployer");
-      assertNotNull(md);
-
-      assertEquals("2 deployers", 2, md.getDeployers().size());
-
-      md.addDeployment("thing.xar");
-      md.process();
-
-      assertTrue("MainDeployerAspects.process", MainDeployerAspects.isProcessCalled());
-
-      HashSet<IDeployerMethod> interceptedCalled = DeployerAspects.getCalled();
-      SampleDeployer d1 = (SampleDeployer) getBean("SampleDeployer1");
-      SampleDeployer d2 = (SampleDeployer) getBean("SampleDeployer2");
-      assertTrue("SampleDeployer1.prepareDeploy",
-            d1.getCalled().contains(IDeployerMethod.prepareDeploy));
-      assertTrue("SampleDeployer1.commitDeploy",
-            d1.getCalled().contains(IDeployerMethod.commitDeploy));
-      assertTrue("SampleDeployer2.prepareDeploy",
-            d2.getCalled().contains(IDeployerMethod.prepareDeploy));
-      assertTrue("SampleDeployer2.commitDeploy",
-            d2.getCalled().contains(IDeployerMethod.commitDeploy));
-
-      assertTrue("DeployerAspects.prepareDeploy",
-            interceptedCalled.contains(IDeployerMethod.prepareDeploy));
-      assertTrue("DeployerAspects.commitDeploy",
-            interceptedCalled.contains(IDeployerMethod.commitDeploy));
-
-      MainDeployerAspects.setProcessCalled(false);
-      md.removeDeployment("thing.xar");
-      md.process();
-      assertTrue("MainDeployerAspects.process", MainDeployerAspects.isProcessCalled());
-
-      assertTrue("SampleDeployer1.prepareUndeploy",
-            d1.getCalled().contains(IDeployerMethod.prepareUndeploy));
-      assertTrue("SampleDeployer1.commitUndeploy",
-            d1.getCalled().contains(IDeployerMethod.commitUndeploy));
-      assertTrue("SampleDeployer2.prepareUndeploy",
-            d2.getCalled().contains(IDeployerMethod.prepareUndeploy));
-      assertTrue("SampleDeployer2.commitUndeploy",
-            d2.getCalled().contains(IDeployerMethod.commitUndeploy));
-
-      assertTrue("DeployerAspects.prepareUndeploy",
-            interceptedCalled.contains(IDeployerMethod.prepareUndeploy));
-      assertTrue("DeployerAspects.commitUndeploy",
-            interceptedCalled.contains(IDeployerMethod.commitUndeploy));
-
-   }
-}

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackTestCase.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,89 @@
+/*
+* 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.test.microcontainer.test;
+
+import junit.framework.Test;
+
+import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.test.microcontainer.support.SimpleLifecycleCallback;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class InitialLifecycleCallbackTestCase extends AOPMicrocontainerTest
+{
+   public static Test suite()
+   {
+      return suite(InitialLifecycleCallbackTestCase.class);
+   }
+   
+   public InitialLifecycleCallbackTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testLifecycleInterceptions() throws Exception
+   {
+      boolean itworked = false;
+      try
+      {
+         SimpleLifecycleCallback.interceptions.clear();
+         deploy("InitialLifecycleCallbackTestCaseNotAutomatic.xml");
+         getCheckBeanExists("Intercepted");
+
+         assertEquals(1, SimpleLifecycleCallback.interceptions.size());
+         SimpleLifecycleCallback.Handled handled = SimpleLifecycleCallback.interceptions.get(0);
+         assertEquals("Intercepted", handled.contextName);
+         assertEquals(ControllerState.INSTANTIATED, handled.fromState);
+
+         SimpleLifecycleCallback callback = (SimpleLifecycleCallback)getBean("LifecycleCallback");
+         assertEquals("Test123", callback.getTestProperty());
+         itworked = true;
+         
+      }
+      finally
+      {
+         SimpleLifecycleCallback.interceptions.clear();
+         undeploy("InitialLifecycleCallbackTestCaseNotAutomatic.xml");
+         if (itworked)
+         {
+            assertEquals(1, SimpleLifecycleCallback.interceptions.size());
+            SimpleLifecycleCallback.Handled handled = SimpleLifecycleCallback.interceptions.get(0);
+            assertEquals("Intercepted", handled.contextName);
+            assertEquals(ControllerState.CONFIGURED, handled.fromState);
+         }
+      }
+   }
+   
+   public Object getCheckBeanExists(String name)
+   {
+      Object bean = getBean(name);
+      assertNotNull(bean);
+      return bean;
+   }
+
+   
+   //InitialLifecycleTestCaseNotAutomatic.xml
+}

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/InitialLifecycleCallbackWithDependencyTestCase.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,360 @@
+/*
+* 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.test.microcontainer.test;
+
+import junit.framework.Test;
+
+import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.test.microcontainer.support.LifecycleCallbackWithBeanDependency;
+import org.jboss.test.microcontainer.support.SimpleBean;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class InitialLifecycleCallbackWithDependencyTestCase extends AOPMicrocontainerTest
+{
+   public static Test suite()
+   {
+      return suite(InitialLifecycleCallbackWithDependencyTestCase.class);
+   }
+   
+   public InitialLifecycleCallbackWithDependencyTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testLifecycleInterceptionsWithDependencyCorrectOrder() throws Exception
+   {
+      deploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+      try
+      {
+         Object dependency = (Object) getCheckBeanExists("Dependency");
+         assertNotNull(dependency);
+         boolean itworked = false;
+
+         LifecycleCallbackWithBeanDependency.interceptions.clear();
+         deploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+         try
+         {
+            validate();
+            getCheckBeanExists("Intercepted");
+            LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
+            assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+            LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+            assertEquals("Intercepted", handled.contextName);
+            assertEquals(ControllerState.INSTANTIATED, handled.fromState);
+            assertNotNull(lifecycle.getDependency());
+            assertEquals(dependency, lifecycle.getDependency());
+            itworked = true;
+         }
+         finally
+         {
+            LifecycleCallbackWithBeanDependency.interceptions.clear();
+            undeploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+            if (itworked)
+            {
+               assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+               LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+               assertEquals("Intercepted", handled.contextName);
+               assertEquals(ControllerState.CONFIGURED, handled.fromState);
+            }
+         }
+      }
+      finally
+      {
+         undeploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+      }
+   }
+   
+   public void testLifecycleInterceptionsWithDependencyWrongOrder() throws Exception
+   {
+      deploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+      try
+      {
+         SimpleBean bean;
+         try
+         {
+            bean = (SimpleBean) getBean("Intercepted");
+            fail("'Interceped' should not be installed yet");
+         }
+         catch (IllegalStateException expected)
+         {
+         }
+         
+         bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
+         assertNull("This should not be deployed until the interceptor is", bean);
+
+         boolean itworked = false;
+         LifecycleCallbackWithBeanDependency.interceptions.clear();
+         deploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+         try
+         {
+            validate();
+            Object dependency = getCheckBeanExists("Dependency");
+            LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
+            getCheckBeanExists("Intercepted");
+            assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+            LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+            assertEquals("Intercepted", handled.contextName);
+            assertEquals(ControllerState.INSTANTIATED, handled.fromState);
+            assertNotNull(lifecycle.getDependency());
+            assertEquals(dependency, lifecycle.getDependency());
+            
+            itworked = true;
+            
+         }
+         finally
+         {
+            LifecycleCallbackWithBeanDependency.interceptions.clear();
+            undeploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+            if (itworked)
+            {
+               assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+               LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+               assertEquals("Intercepted", handled.contextName);
+               assertEquals(ControllerState.CONFIGURED, handled.fromState);
+            }
+
+            try
+            {
+               bean = (SimpleBean) getBean("Intercepted");
+               fail("'Interceped' should not be installed yet");
+            }
+            catch (IllegalStateException expected)
+            {
+            }
+            
+            bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
+            assertNull("This should not be deployed until the interceptor is", bean);
+         }
+      }
+      finally
+      {
+         undeploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+      }
+   }
+   
+   public void testLifecycleInterceptionsWithDependencyRedeploy() throws Exception
+   {
+      deploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+      try
+      {
+         SimpleBean bean;
+         try
+         {
+            bean = (SimpleBean) getBean("Intercepted");
+            fail("'Interceped' should not be installed yet");
+         }
+         catch (IllegalStateException expected)
+         {
+         }
+         
+         bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
+         assertNull("This should not be deployed until the interceptor is", bean);
+
+         boolean itworked = false;
+         LifecycleCallbackWithBeanDependency.interceptions.clear();
+         deploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+         try
+         {
+            validate();
+            Object dependency = getCheckBeanExists("Dependency");
+            LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
+            getCheckBeanExists("Intercepted");
+            assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+            LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+            assertEquals("Intercepted", handled.contextName);
+            assertEquals(ControllerState.INSTANTIATED, handled.fromState);
+            assertNotNull(lifecycle.getDependency());
+            assertEquals(dependency, lifecycle.getDependency());
+            
+            itworked = true;
+            
+         }
+         finally
+         {
+            LifecycleCallbackWithBeanDependency.interceptions.clear();
+            undeploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+            if (itworked)
+            {
+               assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+               LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+               assertEquals("Intercepted", handled.contextName);
+               assertEquals(ControllerState.CONFIGURED, handled.fromState);
+            }
+
+            try
+            {
+               bean = (SimpleBean) getBean("Intercepted");
+               fail("'Interceped' should not be installed yet");
+            }
+            catch (IllegalStateException expected)
+            {
+            }
+            
+            bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
+            assertNull("This should not be deployed until the interceptor is", bean);
+         }
+         
+         try
+         {
+            bean = (SimpleBean) getBean("Intercepted");
+            fail("'Interceped' should not be installed yet");
+         }
+         catch (IllegalStateException expected)
+         {
+            KernelControllerContext context = getControllerContext("Intercepted", ControllerState.DESCRIBED);
+            assertNotNull(context);
+         }
+
+         itworked = false;
+         LifecycleCallbackWithBeanDependency.interceptions.clear();
+         deploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+         try
+         {
+            validate();
+            Object dependency = getCheckBeanExists("Dependency");
+            LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
+            getCheckBeanExists("Intercepted");
+            assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+            LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+            assertEquals("Intercepted", handled.contextName);
+            assertEquals(ControllerState.INSTANTIATED, handled.fromState);
+            assertNotNull(lifecycle.getDependency());
+            assertTrue("Should not be caching the lifecycle's callback across rebinding", dependency == lifecycle.getDependency());
+            
+            itworked = true;
+         }
+         finally
+         {
+            LifecycleCallbackWithBeanDependency.interceptions.clear();
+            undeploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+            if (itworked)
+            {
+               assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+               LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+               assertEquals("Intercepted", handled.contextName);
+               assertEquals(ControllerState.CONFIGURED, handled.fromState);
+            }
+
+            try
+            {
+               bean = (SimpleBean) getBean("Intercepted");
+               fail("'Interceped' should not be installed yet");
+            }
+            catch (IllegalStateException expected)
+            {
+            }
+            
+            bean = (SimpleBean) getBean("Intercepted", ControllerState.DESCRIBED);
+            assertNull("This should not be deployed until the interceptor is", bean);
+         }
+      }
+      finally
+      {
+         undeploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+      }
+   }
+
+   public void testLifecycleInterceptionsWithDependencyRedeploy2() throws Exception
+   {
+      deploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+      try
+      {
+         Object dependency = getCheckBeanExists("Dependency");
+         boolean itworked = false;
+
+         LifecycleCallbackWithBeanDependency.interceptions.clear();
+         deploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+         try
+         {
+            validate();
+            getCheckBeanExists("Intercepted");
+            LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
+            assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+            LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+            assertEquals("Intercepted", handled.contextName);
+            assertEquals(ControllerState.INSTANTIATED, handled.fromState);
+            assertNotNull(lifecycle.getDependency());
+            assertTrue(dependency == lifecycle.getDependency());
+            itworked = true;
+         }
+         finally
+         {
+            LifecycleCallbackWithBeanDependency.interceptions.clear();
+            undeploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+            if (itworked)
+            {
+               assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+               LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+               assertEquals("Intercepted", handled.contextName);
+               assertEquals(ControllerState.CONFIGURED, handled.fromState);
+            }
+         }
+         
+         Object dependency2 = getCheckBeanExists("Dependency");
+         assertTrue(dependency == dependency2);
+         LifecycleCallbackWithBeanDependency.interceptions.clear();
+         deploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+         try
+         {
+            validate();
+            getCheckBeanExists("Intercepted");
+            LifecycleCallbackWithBeanDependency lifecycle = (LifecycleCallbackWithBeanDependency)getCheckBeanExists("LifecycleCallback");
+            assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+            LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+            assertEquals("Intercepted", handled.contextName);
+            assertEquals(ControllerState.INSTANTIATED, handled.fromState);
+            assertNotNull(lifecycle.getDependency());
+            assertTrue(dependency == lifecycle.getDependency());
+            itworked = true;
+         }
+         finally
+         {
+            LifecycleCallbackWithBeanDependency.interceptions.clear();
+            undeploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic1.xml");
+            if (itworked)
+            {
+               assertEquals(1, LifecycleCallbackWithBeanDependency.interceptions.size());
+               LifecycleCallbackWithBeanDependency.Handled handled = LifecycleCallbackWithBeanDependency.interceptions.get(0);
+               assertEquals("Intercepted", handled.contextName);
+               assertEquals(ControllerState.CONFIGURED, handled.fromState);
+            }
+         }
+      }
+      finally
+      {
+         undeploy("InitialLifecycleCallbackWithDependencyTestCaseNotAutomatic0.xml");
+      }
+   }
+   
+   public Object getCheckBeanExists(String name)
+   {
+      Object bean = getBean(name);
+      assertNotNull(bean);
+      return bean;
+   }
+}

Deleted: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/LifecycleAspectTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/LifecycleAspectTestCase.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/LifecycleAspectTestCase.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -1,81 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, 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.test.microcontainer.test;
-
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-
-import junit.framework.Test;
-
-import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
-import org.jboss.test.microcontainer.support.TestAspect;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision: 43840 $
- */
-public class LifecycleAspectTestCase extends AOPMicrocontainerTest
-{
-   public static Test suite()
-   {
-      return suite(LifecycleAspectTestCase.class);
-   }
-   
-   public LifecycleAspectTestCase(String name)
-   {
-      super(name);
-   }
-   
-   
-   public void testBean() throws Exception
-   {
-      assertFalse(TestAspect.barCalled);
-      assertFalse(TestAspect.fooCalled);
-      Object bean = null; 
-      try
-      {
-         bean = getBean("Bean");
-      }
-      catch (RuntimeException expected)
-      {
-      }
-      
-      if (bean != null)
-      {
-         fail("Should not be deployed yet");
-      }
-
-      deploy("LifecycleAspectTestCaseNotAutomatic.xml");
-      
-      bean = getBean("Bean");
-      assertNotNull(bean);
-      assertTrue(TestAspect.fooCalled);
-      assertFalse(TestAspect.barCalled);
-      TestAspect.fooCalled = false;
-      undeploy("LifecycleAspectTestCaseNotAutomatic.xml");
-      assertTrue(TestAspect.fooCalled);
-      assertFalse(TestAspect.barCalled);
-   }
-}

Modified: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/LifecycleTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/LifecycleTestCase.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/LifecycleTestCase.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -26,14 +26,12 @@
 import junit.framework.Test;
 
 import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
-import org.jboss.kernel.plugins.deployment.xml.LifecycleAnnotationsInterceptor;
 import org.jboss.test.microcontainer.support.Configure;
 import org.jboss.test.microcontainer.support.Create;
 import org.jboss.test.microcontainer.support.Describe;
 import org.jboss.test.microcontainer.support.Install;
 import org.jboss.test.microcontainer.support.Instantiate;
-import org.jboss.test.microcontainer.support.LifecycleInterceptor;
-import org.jboss.test.microcontainer.support.SimpleBeanImpl;
+import org.jboss.test.microcontainer.support.LifecycleCallback;
 import org.jboss.test.microcontainer.support.Start;
 
 public class LifecycleTestCase extends AOPMicrocontainerTest
@@ -53,13 +51,13 @@
       boolean undeployed = false;
       try
       {
-         LifecycleInterceptor.interceptions.clear();
+         LifecycleCallback.interceptions.clear();
          deploy("LifecycleTestCaseNotAutomatic.xml");
          
          //Verify the beans exist
          checkBeanExists("ConfigureBean");
          checkBeanExists("CreateBean");
-//         checkBeanExists("DescribeBean"); 
+         checkBeanExists("DescribeBean"); 
          checkBeanExists("InstallBean");
          checkBeanExists("InstantiateBean"); 
          checkBeanExists("StartBean"); 
@@ -67,20 +65,20 @@
          //Now check the expected lifecycle events for each bean
          checkExpectedAnnotations("ConfigureBean", Configure.class);
          checkExpectedAnnotations("CreateBean", Create.class);
-//         checkExpectedAnnotations("DescribeBean", Describe.class);
+         checkExpectedAnnotations("DescribeBean", Describe.class);
          checkExpectedAnnotations("InstallBean", Install.class);
          checkExpectedAnnotations("InstantiateBean", Instantiate.class);
          checkExpectedAnnotations("StartBean", Start.class);
          
          
-         LifecycleInterceptor.interceptions.clear();
+         LifecycleCallback.interceptions.clear();
          
          undeploy("LifecycleTestCaseNotAutomatic.xml");
          undeployed = true;
          
          checkExpectedAnnotations("ConfigureBean", Configure.class);
          checkExpectedAnnotations("CreateBean", Create.class);
-//         checkExpectedAnnotations("DescribeBean", Describe.class);
+         checkExpectedAnnotations("DescribeBean", Describe.class);
          checkExpectedAnnotations("InstallBean", Install.class);
          checkExpectedAnnotations("InstantiateBean", Instantiate.class);
          checkExpectedAnnotations("StartBean", Start.class);
@@ -103,7 +101,7 @@
    
    public void checkExpectedAnnotations(String name, Class annotation)
    {
-      ArrayList<Class> events = LifecycleInterceptor.interceptions.get(name);
+      ArrayList<Class> events = LifecycleCallback.interceptions.get(name);
       assertNotNull(events);
       assertEquals("Wrong events, expected one element only " + events, 1, events.size());
       Class actualAnnotation = events.get(0);

Modified: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/MultipleLifecycleTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/MultipleLifecycleTestCase.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/MultipleLifecycleTestCase.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -29,6 +29,7 @@
 import junit.framework.Test;
 
 import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.support.SimpleLifecycleCallback;
 
 /**
  * 
@@ -59,5 +60,8 @@
       MBeanOperationInfo[] ops = info.getOperations();
       assertEquals(1, ops.length);
       assertEquals("someMethod", ops[0].getName());
+      
+      assertNotNull(SimpleLifecycleCallback.interceptions);
+      assertEquals(1, SimpleLifecycleCallback.interceptions.size());
    }
 }

Added: projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/NonDefaultMethodsLifecycleCallbackTestCase.java
===================================================================
--- projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/NonDefaultMethodsLifecycleCallbackTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/aop-mc-int/src/tests/org/jboss/test/microcontainer/test/NonDefaultMethodsLifecycleCallbackTestCase.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,81 @@
+/*
+* 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.test.microcontainer.test;
+
+import junit.framework.Test;
+
+import org.jboss.aop.microcontainer.junit.AOPMicrocontainerTest;
+import org.jboss.test.microcontainer.support.NonDefaultMethodsLifecycleCallback;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class NonDefaultMethodsLifecycleCallbackTestCase extends AOPMicrocontainerTest
+{
+   public static Test suite()
+   {
+      return suite(NonDefaultMethodsLifecycleCallbackTestCase.class);
+   }
+   
+   public NonDefaultMethodsLifecycleCallbackTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testLifecycleInterceptions() throws Exception
+   {
+      boolean itworked = false;
+      try
+      {
+         deploy("NonDefaultMethodsLifecycleCallbackTestCaseNotAutomatic.xml");
+         validate();
+         getCheckBeanExists("Intercepted");
+
+         assertTrue(NonDefaultMethodsLifecycleCallback.inited);
+         assertFalse(NonDefaultMethodsLifecycleCallback.uninited);
+
+         itworked = true;
+         
+      }
+      finally
+      {
+         undeploy("NonDefaultMethodsLifecycleCallbackTestCaseNotAutomatic.xml");
+         if (itworked)
+         {
+            assertTrue(NonDefaultMethodsLifecycleCallback.inited);
+            assertTrue(NonDefaultMethodsLifecycleCallback.uninited);
+         }
+      }
+   }
+   
+   public Object getCheckBeanExists(String name)
+   {
+      Object bean = getBean(name);
+      assertNotNull(bean);
+      return bean;
+   }
+
+   
+   //InitialLifecycleTestCaseNotAutomatic.xml
+}

Modified: projects/microcontainer/trunk/build/build-thirdparty.xml
===================================================================
--- projects/microcontainer/trunk/build/build-thirdparty.xml	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/build/build-thirdparty.xml	2007-03-07 14:36:24 UTC (rev 61194)
@@ -55,7 +55,7 @@
       <componentref name="jboss/profiler/jvmti" version="1.0.0.CR4"/>
       <componentref name="junit" version="3.8.1"/>
       <componentref name="junit4" version="4.1"/>
-      <componentref name="jboss/aop" version="2.0.0.alpha3" />
+      <componentref name="jboss/aop" version="snapshot"/>
       <componentref name="jboss/backport-concurrent" version="2.1.0.GA"/>
       <componentref name="jboss/jbossretro" version="1.0.4.GA"/>
       <componentref name="jboss/test" version="snapshot"/>

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/plugins/AbstractBeanInfo.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -33,6 +33,7 @@
 import org.jboss.beans.info.spi.EventInfo;
 import org.jboss.beans.info.spi.PropertyInfo;
 import org.jboss.classadapter.spi.ClassAdapter;
+import org.jboss.classadapter.spi.DependencyBuilderListItem;
 import org.jboss.joinpoint.plugins.Config;
 import org.jboss.joinpoint.spi.ConstructorJoinpoint;
 import org.jboss.joinpoint.spi.JoinpointFactory;

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/beans/info/spi/BeanInfo.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -24,6 +24,7 @@
 import java.util.List;
 import java.util.Set;
 
+import org.jboss.classadapter.spi.DependencyBuilderListItem;
 import org.jboss.joinpoint.spi.JoinpointFactory;
 import org.jboss.metadata.spi.MetaData;
 import org.jboss.reflect.spi.ClassInfo;

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/BasicClassAdapter.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/BasicClassAdapter.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/BasicClassAdapter.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -26,6 +26,7 @@
 import org.jboss.classadapter.spi.ClassAdapter;
 import org.jboss.classadapter.spi.ClassAdapterFactory;
 import org.jboss.classadapter.spi.DependencyBuilder;
+import org.jboss.classadapter.spi.DependencyBuilderListItem;
 import org.jboss.joinpoint.spi.JoinpointFactory;
 import org.jboss.joinpoint.spi.JoinpointFactoryBuilder;
 import org.jboss.metadata.spi.MetaData;

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/dependency/AbstractDependencyBuilder.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/dependency/AbstractDependencyBuilder.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/plugins/dependency/AbstractDependencyBuilder.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -39,4 +39,5 @@
    {
       return null;
    }
+   
 }

Added: projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/spi/DependencyBuilderListItem.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/spi/DependencyBuilderListItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/classadapter/spi/DependencyBuilderListItem.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,33 @@
+/*
+* 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.classadapter.spi;
+
+/**
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface DependencyBuilderListItem
+{
+   //TODO This sucks, should be the KernelControllerContext passed in
+   void addDependency(Object ctx);
+}


Property changes on: projects/microcontainer/trunk/kernel
___________________________________________________________________
Name: svn:ignore
   - output
build.log

   + output
build.log
junit*.properties


Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractBeanMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractBeanMetaData.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractBeanMetaData.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -36,6 +36,7 @@
 import org.jboss.beans.metadata.spi.DemandMetaData;
 import org.jboss.beans.metadata.spi.DependencyMetaData;
 import org.jboss.beans.metadata.spi.InstallMetaData;
+import org.jboss.beans.metadata.spi.LifecycleCallbackMetaData;
 import org.jboss.beans.metadata.spi.LifecycleMetaData;
 import org.jboss.beans.metadata.spi.MetaDataVisitor;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
@@ -54,7 +55,7 @@
 
 /**
  * Metadata for a bean.
- * 
+ *
  * @author <a href="adrian at jboss.com">Adrian Brock</a>
  * @version $Revision$
  */
@@ -63,6 +64,8 @@
 {
    private static final long serialVersionUID = 1L;
 
+   private static final List<LifecycleCallbackMetaData> EMPTY_LIFECYCLE_CALLBACKS = Collections.unmodifiableList(new ArrayList<LifecycleCallbackMetaData>());
+
    /** The bean fully qualified class name */
    protected String bean;
 
@@ -88,9 +91,7 @@
    protected LifecycleMetaData start;
 
    /** The stop lifecycle */
-   protected LifecycleMetaData stop;
-
-   /** The destroy lifecycle */
+   protected LifecycleMetaData stop;   /** The destroy lifecycle */
    protected LifecycleMetaData destroy;
 
    /** What the bean demands Set<DemandMetaData> */
@@ -108,6 +109,9 @@
    /** The uninstall operations List<InstallMetaData> */
    protected List<InstallMetaData> uninstalls;
 
+   /** The uninstall operations List<LifecycleCallbackMetaData> */
+   protected List<LifecycleCallbackMetaData> lifecycleCallbacks;
+
    /** The context */
    protected transient ControllerContext context;
 
@@ -121,7 +125,7 @@
 
    /**
     * Create a new bean meta data
-    * 
+    *
     * @param bean the bean class name
     */
    public AbstractBeanMetaData(String bean)
@@ -130,7 +134,7 @@
    }
    /**
     * Create a new bean meta data
-    * 
+    *
     * @param name the name
     * @param bean the bean class name
     */
@@ -192,7 +196,7 @@
 
    /**
     * Set the bean class name and flush the object cache.
-    * 
+    *
     * @param bean The bean class name to set.
     */
    public void setBean(String bean)
@@ -203,7 +207,7 @@
 
    /**
     * Get a property
-    * 
+    *
     * @param name the name
     * @return the property name
     */
@@ -224,7 +228,7 @@
 
    /**
     * Add a property
-    * 
+    *
     * @param property the property
     */
    public void addProperty(PropertyMetaData property)
@@ -239,7 +243,7 @@
 
    /**
     * Set the propertiess.
-    * 
+    *
     * @param properties Set<PropertyMetaData>
     */
    public void setProperties(Set<PropertyMetaData> properties)
@@ -260,7 +264,7 @@
 
    /**
     * Set the constructor
-    * 
+    *
     * @param constructor the constructor metadata
     */
    public void setConstructor(ConstructorMetaData constructor)
@@ -270,7 +274,7 @@
 
    /**
     * Set what the bean demands.
-    * 
+    *
     * @param demands Set<DemandMetaData>
     */
    public void setDemands(Set<DemandMetaData> demands)
@@ -281,7 +285,7 @@
 
    /**
     * Set what the bean supplies.
-    * 
+    *
     * @param supplies Set<SupplyMetaData>
     */
    public void setSupplies(Set<SupplyMetaData> supplies)
@@ -292,7 +296,7 @@
 
    /**
     * Set what the bean depends.
-    * 
+    *
     * @param depends Set<DependencyMetaData>
     */
    public void setDepends(Set<DependencyMetaData> depends)
@@ -308,7 +312,7 @@
 
    /**
     * Set the name.
-    * 
+    *
     * @param name The name to set.
     */
    public void setName(String name)
@@ -345,7 +349,7 @@
 
    /**
     * Set the lifecycle metadata
-    * 
+    *
     * @param lifecycle the lifecycle metadata
     */
    public void setCreate(LifecycleMetaData lifecycle)
@@ -361,7 +365,7 @@
 
    /**
     * Set the start metadata
-    * 
+    *
     * @param lifecycle the lifecycle metadata
     */
    public void setStart(LifecycleMetaData lifecycle)
@@ -377,7 +381,7 @@
 
    /**
     * Set the stop metadata
-    * 
+    *
     * @param lifecycle the lifecycle metadata
     */
    public void setStop(LifecycleMetaData lifecycle)
@@ -393,7 +397,7 @@
 
    /**
     * Set the destroy metadata
-    * 
+    *
     * @param lifecycle the lifecycle metadata
     */
    public void setDestroy(LifecycleMetaData lifecycle)
@@ -422,9 +426,20 @@
       return installs;
    }
 
+   public List<LifecycleCallbackMetaData> getLifecycleCallbacks()
+   {
+      return lifecycleCallbacks;
+   }
+
+   public void setLifecycleCallbacks(List<LifecycleCallbackMetaData> lifecycleCallbacks)
+   {
+      this.lifecycleCallbacks = lifecycleCallbacks;
+      flushJBossObjectCache();
+   }
+
    /**
     * Set the installs
-    * 
+    *
     * @param installs List<InstallMetaData>
     */
    public void setInstalls(List<InstallMetaData> installs)
@@ -440,7 +455,7 @@
 
    /**
     * Set the uninstalls
-    * 
+    *
     * @param uninstalls List<InstallMetaData>
     */
    public void setUninstalls(List<InstallMetaData> uninstalls)
@@ -493,6 +508,8 @@
          children.addAll(installs);
       if (uninstalls != null)
          children.addAll(uninstalls);
+      if (lifecycleCallbacks != null)
+         children.addAll(lifecycleCallbacks);
    }
 
    public Class getType(MetaDataVisitor visitor, MetaDataVisitorNode previous) throws Throwable
@@ -571,8 +588,34 @@
          buffer.append(" uninstalls=");
          JBossObject.list(buffer, uninstalls);
       }
+      if (lifecycleCallbacks != null)
+      {
+         buffer.append(" lifecycleCallbacks=");
+         JBossObject.list(buffer, lifecycleCallbacks);
+      }
    }
 
+   public List<LifecycleCallbackMetaData> getLifecycleCallbacks(ControllerState state)
+   {
+      List<LifecycleCallbackMetaData> callbacks = EMPTY_LIFECYCLE_CALLBACKS;
+      List<LifecycleCallbackMetaData> allCallbacks = getLifecycleCallbacks();
+      if (allCallbacks != null && allCallbacks.size() > 0)
+      {
+         for (LifecycleCallbackMetaData lifecycleCallback : allCallbacks)
+         {
+            if (lifecycleCallback.getWhenRequired().equals(state))
+            {
+               if (callbacks == EMPTY_LIFECYCLE_CALLBACKS)
+               {
+                  callbacks = new ArrayList<LifecycleCallbackMetaData>();
+               }
+               callbacks.add(lifecycleCallback);
+            }
+         }
+      }
+      return callbacks;
+   }
+
    public void toShortString(JBossStringBuilder buffer)
    {
       buffer.append(bean);

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractLifecycleCallbackMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractLifecycleCallbackMetaData.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractLifecycleCallbackMetaData.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,118 @@
+/*
+* 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.beans.metadata.plugins;
+
+import java.util.Iterator;
+
+import org.jboss.beans.metadata.spi.LifecycleCallbackMetaData;
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Metadata about lifecycle callbacks that should be invoked once a 
+ * bean reaches a certain lifecycle state
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public class AbstractLifecycleCallbackMetaData extends JBossObject 
+implements LifecycleCallbackMetaData, MetaDataVisitorNode
+{
+   String bean;
+   ControllerState whenRequired;
+   ControllerState dependentState;
+   String installMethod;
+   String uninstallMethod;
+   
+   public AbstractLifecycleCallbackMetaData(String bean, ControllerState whenRequired, ControllerState dependentState, String installMethod, String uninstallMethod)
+   {
+      super();
+      this.bean = bean;
+      this.whenRequired  = whenRequired;
+      this.dependentState = dependentState;
+      this.installMethod = installMethod;
+      this.uninstallMethod = uninstallMethod;
+   }
+
+   public String getBean()
+   {
+      return bean;
+   }
+
+   public ControllerState getDependentState()
+   {
+      return dependentState;
+   }
+
+   public ControllerState getWhenRequired()
+   {
+      return whenRequired;
+   }
+
+   public String getInstallMethod()
+   {
+      return installMethod;
+   }
+
+   public String getUninstallMethod()
+   {
+      return uninstallMethod;
+   }
+
+   public void describeVisit(MetaDataVisitor visitor)
+   {
+      visitor.describeVisit(this);
+   }
+
+   public Iterator<? extends MetaDataVisitorNode> getChildren()
+   {
+      return null;
+   }
+
+   public void initialVisit(MetaDataVisitor visitor)
+   {
+      visitor.initialVisit(this);
+   }
+
+   public String toShortString()
+   {
+      JBossStringBuilder buffer = new JBossStringBuilder();
+      toShortString(buffer);
+      return buffer.toString();
+   }
+
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      if (bean != null)
+         buffer.append(bean);
+      if (whenRequired != null)
+         buffer.append("." + whenRequired.toString());
+   }
+   
+   public String toString()
+   {
+      return toShortString();
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/BeanMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/BeanMetaData.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/BeanMetaData.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -25,6 +25,7 @@
 import java.util.Set;
 
 import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.dependency.spi.ControllerState;
 
 /**
  * Metadata about a bean.
@@ -161,9 +162,23 @@
    List<InstallMetaData> getInstalls();
 
    /**
-    * Get the uninstallation oeprations.
+    * Get the uninstallation operations.
     * 
     * @return List<InstallMetaData>
     */
    List<InstallMetaData> getUninstalls();
+   
+   /**
+    * Get the lifecycle callbacks.
+    * 
+    * @return List<LifecycleCallbackMetaData>
+    */
+   List<LifecycleCallbackMetaData> getLifecycleCallbacks();
+   
+   /**
+    * Get the lifecycle callbacks for a particular state.
+    * 
+    * @return List<LifecycleCallbackMetaData>
+    */
+   List<LifecycleCallbackMetaData> getLifecycleCallbacks(ControllerState state);
 }

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/LifecycleCallbackMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/LifecycleCallbackMetaData.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/LifecycleCallbackMetaData.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -0,0 +1,63 @@
+/*
+* 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.beans.metadata.spi;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.util.JBossInterface;
+
+/**
+ * Metadata about lifecycle callbacks
+ * 
+ * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
+ * @version $Revision: 1.1 $
+ */
+public interface LifecycleCallbackMetaData extends JBossInterface, MetaDataVisitorNode
+{
+   /**
+    * Get the target state of the bean this callback applies to indicating when this callback should trigger
+    * @return the state 
+    */
+   ControllerState getWhenRequired();
+   
+   /**
+    * The required state of the lifecycle callback bean
+    */
+   ControllerState getDependentState();
+   
+   /**
+    * Get the bean this callback should be made on
+    * @return the state 
+    */
+   String getBean();
+
+   /**
+    * Get the method on the bean that should be called when reaching the required state on installation
+    */
+   public String getInstallMethod();
+
+
+   /**
+    * Get the method on the bean that should be called when reaching the required state on uninstallation
+    */
+   public String getUninstallMethod();
+
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -25,11 +25,13 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 import java.util.Stack;
 
 import org.jboss.beans.info.spi.BeanInfo;
 import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.LifecycleCallbackMetaData;
 import org.jboss.beans.metadata.spi.MetaDataVisitor;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
 import org.jboss.dependency.plugins.AbstractControllerContext;
@@ -172,6 +174,12 @@
       this.installScope = key;
    }
 
+   public List<LifecycleCallbackMetaData> getLifecycleCallbacks(ControllerState state)
+   {
+      return metaData.getLifecycleCallbacks(state);
+   }
+
+   
    public void toString(JBossStringBuilder buffer)
    {
       if (metaData != null)

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -24,10 +24,7 @@
 import java.util.List;
 
 import org.jboss.beans.info.spi.BeanInfo;
-import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.dependency.plugins.AbstractDependencyItem;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.classadapter.spi.DependencyBuilderListItem;
 import org.jboss.kernel.spi.dependency.KernelController;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
@@ -49,17 +46,14 @@
          KernelController controller = (KernelController)context.getController();
          KernelMetaDataRepository repository = controller.getKernel().getMetaDataRepository();
          MetaData md = repository.getMetaData(context);
-         DependencyInfo depends = context.getDependencyInfo();
          // add custom dependencies (e.g. AOP layer).
          List<Object> dependencies = info.getDependencies(md);
          log.trace("Extra dependencies for " + context.getName() + " " + dependencies);
          if (dependencies != null)
          {
-            BeanMetaData metaData = context.getBeanMetaData();
-            for (Object dependencyName : dependencies)
+            for (Object dependencyItem : dependencies)
             {
-               AbstractDependencyItem dependency = new AbstractDependencyItem(metaData.getName(), dependencyName, ControllerState.INSTANTIATED, ControllerState.INSTALLED);
-               depends.addIDependOn(dependency);
+               ((DependencyBuilderListItem)dependencyItem).addDependency(context);
             }
          }
       }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/KernelControllerContextAction.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -25,9 +25,12 @@
 import java.util.List;
 
 import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.LifecycleCallbackMetaData;
 import org.jboss.beans.metadata.spi.ParameterMetaData;
 import org.jboss.dependency.plugins.spi.action.ControllerContextAction;
+import org.jboss.dependency.spi.Controller;
 import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
 import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
 import org.jboss.joinpoint.spi.Joinpoint;
 import org.jboss.kernel.plugins.config.Configurator;
@@ -192,9 +195,16 @@
       }
    }
 
+
    public void installAction(KernelControllerContext context) throws Throwable
    {
       installActionInternal(context);
+      setKernelControllerContext(context);
+      installLifecycleCallbacks(context);
+   }
+
+   private void setKernelControllerContext(KernelControllerContext context) throws Throwable
+   {
       Object target = context.getTarget();
       if (target != null)
       {
@@ -204,12 +214,36 @@
                awareInterface.equals(KernelControllerContextAware.class) == false &&
                awareInterface.isAssignableFrom(target.getClass()))
          {
-            //System.out.println("-----> " + context.getName() + " " + target.getClass() + " " + context.getState());
             ((KernelControllerContextAware)target).setKernelControllerContext(context);
          }
       }
    }
 
+   private void installLifecycleCallbacks(KernelControllerContext context) throws Throwable
+   {
+      Controller controller = context.getController();
+      List<ControllerState> states = controller.getStates();
+      int toIndex = states.indexOf(context.getState());
+      ControllerState toState = states.get(toIndex + 1);
+
+      List<LifecycleCallbackMetaData> callbacks = context.getLifecycleCallbacks(toState);
+      if (callbacks.size() > 0)
+      {
+         for (LifecycleCallbackMetaData callback : callbacks)
+         {
+            ControllerContext callbackContext = controller.getContext(callback.getBean(), callback.getDependentState());
+            if (callbackContext instanceof InvokeDispatchContext)
+            {
+               ((InvokeDispatchContext)callbackContext).invoke(callback.getInstallMethod(), new Object[]{context}, new String[]{KernelControllerContext.class.getName()});
+            }
+            else
+            {
+               throw new IllegalArgumentException("Cannot install, context " + callbackContext + " does not implement InvokeDispatchContext");
+            }
+         }
+      }
+   }
+
    protected void installActionInternal(KernelControllerContext context) throws Throwable
    {
    }
@@ -221,7 +255,20 @@
 
    public void uninstallAction(KernelControllerContext context)
    {
+      uninstallLifecycleCallbacks(context);
+      unsetKernelControllerContext(context);
+      uninstallActionInternal(context);
+
+   }
+
+   protected void uninstallActionInternal(KernelControllerContext context)
+   {
+   }
+
+   private void unsetKernelControllerContext(KernelControllerContext context)
+   {
       Object target = context.getTarget();
+
       if (target != null)
       {
          Class<? extends KernelControllerContextAware> awareInterface = getActionAwareInterface();
@@ -236,15 +283,40 @@
             }
             catch (Exception ignored)
             {
-               log.debug("Ignored error unsetting context ", ignored);
+               log.debug("Ignored error unsetting context " + context.getName(), ignored);
             }
          }
       }
-      uninstallActionInternal(context);
    }
 
-   protected void uninstallActionInternal(KernelControllerContext context)
+   private void uninstallLifecycleCallbacks(KernelControllerContext context)
    {
+
+      List<LifecycleCallbackMetaData> callbacks = context.getLifecycleCallbacks(context.getState());
+      if (callbacks.size() > 0)
+      {
+         Controller controller = context.getController();
+         for (LifecycleCallbackMetaData callback : callbacks)
+         {
+            ControllerContext callbackContext = controller.getContext(callback.getBean(), callback.getDependentState());
+            if (callbackContext instanceof InvokeDispatchContext)
+            {
+
+               try
+               {
+                  ((InvokeDispatchContext)callbackContext).invoke(callback.getUninstallMethod(), new Object[]{context}, new String[]{KernelControllerContext.class.getName()});
+               }
+               catch (Throwable ignored)
+               {
+                  log.debug("Ignored error uninstalling context " + context.getName(), ignored);
+               }
+            }
+            else
+            {
+               throw new IllegalArgumentException("Cannot uninstall, context " + callbackContext + " does not implement InvokeDispatchContext");
+            }
+         }
+      }
    }
 
    // DispatchContext util methods

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java	2007-03-07 14:14:57 UTC (rev 61193)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java	2007-03-07 14:36:24 UTC (rev 61194)
@@ -21,8 +21,12 @@
 */
 package org.jboss.kernel.spi.dependency;
 
+import java.util.List;
+
 import org.jboss.beans.info.spi.BeanInfo;
 import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.LifecycleCallbackMetaData;
+import org.jboss.dependency.spi.ControllerState;
 import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
 import org.jboss.kernel.Kernel;
 import org.jboss.kernel.spi.registry.KernelRegistryEntry;
@@ -106,4 +110,11 @@
     * @param key the scope key
     */
    void setInstallScope(ScopeKey key);
+   
+   /**
+    * Get the lifecycle callbacks for a particular state.
+    * 
+    * @return List<LifecycleCallbackMetaData>
+    */
+   List<LifecycleCallbackMetaData> getLifecycleCallbacks(ControllerState state);
 }




More information about the jboss-cvs-commits mailing list