[jboss-cvs] JBossAS SVN: r62474 - in projects/microcontainer/trunk: dependency/src/main/org/jboss/dependency/plugins and 16 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Apr 21 17:20:20 EDT 2007


Author: alesj
Date: 2007-04-21 17:20:20 -0400 (Sat, 21 Apr 2007)
New Revision: 62474

Added:
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractCallbackItem.java
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AttributeCallbackItem.java
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/NamedCallbackItem.java
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/SingleCallbackItem.java
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/CallbackItem.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractCallbackMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InjectionOption.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InstallCallbackMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/UninstallCallbackMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/CallbackMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/InjectOption.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CallbackDependencyItem.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ClassDependencyItem.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItem.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItemFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ListCallbackItem.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/QueueCallbackItem.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SetCallbackItem.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanInstallCallbackInterceptor.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanUninstallCallbackInterceptor.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/CallbackAnnotationsInterceptor.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/CallbackHandler.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/ManualMicrocontainerTest.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/ManualMicrocontainerTestDelegate.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/ModeMicrocontainerTestDelegate.java
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithInstallCallback.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithInstallCallbacks.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithUninstallCallback.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithUninstallCallbacks.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithInstallCallback.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithInstallCallbacks.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithUninstallCallback.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithUninstallCallbacks.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallBadMethodProperty.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithAnnotation.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithAnnotations.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithCardinality.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithMethod.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithProperty.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithSignature.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithState.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallBadMethodProperty.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithAnnotation.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithAnnotations.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithCardinality.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithMethod.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithProperty.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithSignature.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithState.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/AdditionCallbackTestCase.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CollectionCallbackTestCase.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/InjectionValueCallbackTestCase.xml
   projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/MultipleContextualInjection.xml
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/CallbackTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/CallbackTestObject.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/AdditionCallbackTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CollectionCallbackTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/InjectionValueCallbackTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/MultipleContextualInjectionTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/SimpleCallbackTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/SingleContextualInjectionAdapter.java
Removed:
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/spi/
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/InstallItem.java
Modified:
   projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfo.java
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractDependencyInfo.java
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/Cardinality.java
   projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/DependencyInfo.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractBeanMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyValueMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractInjectionValueMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractInstallMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractTypeMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InjectionType.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/TypeProvider.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/BeanMetaData.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/MetaDataVisitor.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/Inject.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/InjectType.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.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/ClassContextDependencyItem.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ScopedKernelController.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployer.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/BasicKernelDeployer.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BasicXMLDeployer.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding20.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBindingHelper.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/InjectionHandler.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelController.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java
   projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_1_0.xsd
   projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_2_0.xsd
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/AnnotatedLifecycleTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/AbstractXMLTest.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BeanTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/XMLTestSuite.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ConstructorContextualInjectionTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionAdapter.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/LifecycleContextualInjectionTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/PropertyContextualInjectionTestCase.java
Log:
Callback / Install item impl.

Modified: projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfo.java
===================================================================
--- projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfo.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/container/src/main/org/jboss/reflect/spi/TypeInfo.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -136,7 +136,7 @@
     * @see java.lang.Class#isAssignableFrom
     * NumberInfo tests for progression
     *
-    * @param info
+    * @param info type info
     * @return the boolean value indicating whether objects of the
     *         TypeInfo info can be assigned to objects of this TypeInfo
     * @exception NullPointerException if the specified TypeInfo parameter is

Added: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractCallbackItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractCallbackItem.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,101 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.dependency.plugins;
+
+import org.jboss.dependency.spi.CallbackItem;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Abstract callback item.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractCallbackItem<T> extends JBossObject implements CallbackItem<T>
+{
+   protected T name;
+   protected ControllerState whenRequired = ControllerState.CONFIGURED;
+   protected ControllerState dependentState = ControllerState.INSTALLED;
+
+   protected AbstractCallbackItem(T name)
+   {
+      this.name = name;
+   }
+
+   protected AbstractCallbackItem(T name, ControllerState whenRequired, ControllerState dependentState)
+   {
+      this.name = name;
+      if (whenRequired != null)
+         this.whenRequired = whenRequired;
+      if (dependentState != null)
+         this.dependentState = dependentState;
+   }
+
+   public void ownerCallback(Controller controller) throws Throwable
+   {
+   }
+
+   /**
+    * Helper method.
+    *
+    * @param context new installed context
+    * @throws Throwable for any error
+    */
+   protected void additionCallback(ControllerContext context) throws Throwable
+   {
+   }
+
+   public void additionCallback(Controller controller, ControllerContext context) throws Throwable
+   {
+      additionCallback(context);
+   }
+
+   public T getIDependOn()
+   {
+      return name;
+   }
+
+   public ControllerState getWhenRequired()
+   {
+      return whenRequired;
+   }
+
+   public ControllerState getDependentState()
+   {
+      return dependentState;
+   }
+
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      buffer.append("name=").append(name);
+   }
+
+   protected void toString(JBossStringBuilder buffer)
+   {
+      buffer.append("name=").append(name);
+      buffer.append(" whenRequired=").append(whenRequired);
+      buffer.append(" dependentState=").append(dependentState);
+   }
+}

Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -21,12 +21,15 @@
 */
 package org.jboss.dependency.plugins;
 
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
+import org.jboss.dependency.spi.CallbackItem;
 import org.jboss.dependency.spi.Controller;
 import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.dependency.spi.ControllerMode;
@@ -65,6 +68,10 @@
    /** The child controllers */
    private Set<AbstractController> childControllers = CollectionsFactory.createCopyOnWriteSet();
 
+   /** The callback items */
+   private Map<Object, Set<CallbackItem>> installCallbacks = new ConcurrentHashMap<Object, Set<CallbackItem>>();
+   private Map<Object, Set<CallbackItem>> uninstallCallbacks = new ConcurrentHashMap<Object, Set<CallbackItem>>();
+
    /** Whether an on demand context has been enabled */
    private boolean onDemandEnabled = true;
 
@@ -146,7 +153,7 @@
 
    /**
     * Whether the controller has contexts
-    * 
+    *
     * @return true when there are registered contexts
     */
    public boolean isActive()
@@ -298,7 +305,7 @@
          }
          else
          {
-            for(AbstractController controller : childControllers)
+            for (AbstractController controller : childControllers)
             {
                context = controller.uninstall(name, level + 1);
                if (context != null)
@@ -319,7 +326,7 @@
     * Install a context
     *
     * @param context the context
-    * @param trace whether trace is enabled
+    * @param trace   whether trace is enabled
     * @throws Throwable for any error
     */
    protected void install(ControllerContext context, boolean trace) throws Throwable
@@ -332,7 +339,7 @@
          // Check the name is not already registered
          if (getRegisterControllerContext(name, false) != null)
             throw new IllegalStateException(name + " is already installed.");
-         
+
          // Check any alias is not already registered
          Set<Object> aliases = context.getAliases();
          if (aliases != null && aliases.isEmpty() == false)
@@ -355,10 +362,10 @@
          if (trace)
          {
             String dependsOn = null;
-            if( dependencies != null )
+            if (dependencies != null)
             {
                Set set = dependencies.getIDependOn(null);
-               if( set != null )
+               if (set != null)
                   dependsOn = set.toString();
             }
             log.trace("Dependencies for " + name + ": " + dependsOn);
@@ -398,8 +405,8 @@
     * Change a context's state
     *
     * @param context the context
-    * @param state the required state
-    * @param trace whether trace is enabled
+    * @param state   the required state
+    * @param trace   whether trace is enabled
     * @throws Throwable for any error
     */
    protected void change(ControllerContext context, ControllerState state, boolean trace) throws Throwable
@@ -446,7 +453,7 @@
     * Enable an on demand context
     *
     * @param context the context
-    * @param trace whether trace is enabled
+    * @param trace   whether trace is enabled
     * @throws Throwable for any error
     */
    protected void enableOnDemand(ControllerContext context, boolean trace) throws Throwable
@@ -478,11 +485,11 @@
 
    /**
     * Increment state<p>
-    *
+    * <p/>
     * This method must be invoked with the write lock taken.
     *
     * @param context the context
-    * @param trace whether trace is enabled
+    * @param trace   whether trace is enabled
     * @return whether the suceeded
     */
    protected boolean incrementState(ControllerContext context, boolean trace)
@@ -537,6 +544,15 @@
       try
       {
          install(context, fromState, toState);
+
+         if (fromContexts != null)
+            fromContexts.remove(context);
+         Controller toController = context.getController();
+         Set<ControllerContext> toContexts = toController.getContextsByState(toState);
+         toContexts.add(context);
+         context.setState(toState);
+
+         resolveCallbacks(context, toState, true);      
       }
       catch (Throwable t)
       {
@@ -555,18 +571,12 @@
          }
       }
 
-      if (fromContexts != null)
-         fromContexts.remove(context);
-      Controller toController = context.getController();
-      Set<ControllerContext> toContexts = toController.getContextsByState(toState);
-      toContexts.add(context);
-      context.setState(toState);
       return true;
    }
 
    /**
     * Resolve unresolved contexts<p>
-    *
+    * <p/>
     * This method must be invoked with the write lock taken
     *
     * @param trace whether trace is enabled
@@ -578,10 +588,10 @@
       {
          onDemandEnabled = false;
          resolutions = false;
-         for (int i = 0; i < states.size()-1; ++i)
+         for (int i = 0; i < states.size() - 1; ++i)
          {
             ControllerState fromState = states.get(i);
-            ControllerState toState = states.get(i+1);
+            ControllerState toState = states.get(i + 1);
             if (resolveContexts(fromState, toState, trace))
             {
                resolutions = true;
@@ -592,10 +602,10 @@
 
       if (trace)
       {
-         for (int i = 0; i < states.size()-1; ++i)
+         for (int i = 0; i < states.size() - 1; ++i)
          {
             ControllerState state = states.get(i);
-            ControllerState nextState = states.get(i+1);
+            ControllerState nextState = states.get(i + 1);
             Set<ControllerContext> stillUnresolved = contextsByState.get(state);
             if (stillUnresolved.isEmpty() == false)
             {
@@ -625,12 +635,12 @@
 
    /**
     * Resolve contexts<p>
-    *
+    * <p/>
     * This method must be invoked with the write lock taken
     *
     * @param fromState the from state
-    * @param toState the to state
-    * @param trace whether trace is enabled
+    * @param toState   the to state
+    * @param trace     whether trace is enabled
     * @return true when there were resolutions
     */
    protected boolean resolveContexts(ControllerState fromState, ControllerState toState, boolean trace)
@@ -680,12 +690,12 @@
 
    /**
     * Resolve contexts<p>
-    *
+    * <p/>
     * This method must be invoked with the write lock taken
     *
     * @param contexts the contexts
-    * @param state the state
-    * @param trace whether trace is enabled
+    * @param state    the state
+    * @param trace    whether trace is enabled
     * @return the set of resolved contexts
     */
    protected Set<ControllerContext> resolveContexts(Set<ControllerContext> contexts, ControllerState state, boolean trace)
@@ -710,12 +720,12 @@
 
    /**
     * Uninstall a context
-    *
+    * <p/>
     * This method must be invoked with the write lock taken
     *
     * @param context the context to uninstall
     * @param toState the target state
-    * @param trace whether trace is enabled
+    * @param trace   whether trace is enabled
     */
    protected void uninstallContext(ControllerContext context, ControllerState toState, boolean trace)
    {
@@ -740,11 +750,11 @@
 
    /**
     * Uninstall a context<p>
-    *
+    * <p/>
     * This method must be invoked with the write lock taken
     *
     * @param context the context to uninstall
-    * @param trace whether trace is enabled
+    * @param trace   whether trace is enabled
     */
    protected void uninstallContext(ControllerContext context, boolean trace)
    {
@@ -790,7 +800,7 @@
          }
       }
 
-      int toIndex = currentIndex-1;
+      int toIndex = currentIndex - 1;
       if (toIndex == -1)
       {
          context.setError(new IllegalStateException("Cannot uninstall from " + fromState));
@@ -808,6 +818,8 @@
          Set<ControllerContext> toContexts = toController.getContextsByState(toState);
          toContexts.add(context);
          context.setState(toState);
+
+         resolveCallbacks(context, fromState, false);
       }
       catch (Throwable t)
       {
@@ -820,13 +832,213 @@
    }
 
    /**
+    * Add callback item under demand name.
+    *
+    * @param name demand name
+    * @param isInstallPhase install or uninstall phase
+    * @param callback callback item
+    */
+   protected void addCallback(Object name, boolean isInstallPhase, CallbackItem callback)
+   {
+      lockWrite();
+      try
+      {
+         Map<Object, Set<CallbackItem>> map = (isInstallPhase ? installCallbacks : uninstallCallbacks);
+         Set<CallbackItem> callbacks = map.get(name);
+         if (callbacks == null)
+         {
+            callbacks = new HashSet<CallbackItem>();
+            map.put(name, callbacks);
+         }
+         callbacks.add(callback);
+      }
+      finally
+      {
+         unlockWrite();
+      }
+   }
+
+   /**
+    * Remove callback item under demand name.
+    *
+    * @param name demand name
+    * @param isInstallPhase install or uninstall phase
+    * @param callback callback item
+    */
+   protected void removeCallback(Object name, boolean isInstallPhase, CallbackItem callback)
+   {
+      lockWrite();
+      try
+      {
+         Map<Object, Set<CallbackItem>> map = (isInstallPhase ? installCallbacks : uninstallCallbacks);
+         Set<CallbackItem> callbacks = map.get(name);
+         if (callbacks != null)
+         {
+            callbacks.remove(callback);
+            if (callbacks.isEmpty())
+               map.remove(name);
+         }
+      }
+      finally
+      {
+         unlockWrite();
+      }
+   }
+
+   /**
+    * Get calbacks from context.
+    *
+    * @param context current context
+    * @param isInstallPhase install or uninstall phase
+    * @return callback items from dependency info
+    */
+   protected Set<CallbackItem> getDependencyCallbacks(ControllerContext context, boolean isInstallPhase)
+   {
+      DependencyInfo di = context.getDependencyInfo();
+      if (di != null)
+      {
+         return isInstallPhase ? di.getInstallItems() : di.getUninstallItems();
+      }
+      return null;
+   }
+
+   /**
+    * Get the matching callbacks.
+    *
+    * @param name demand name
+    * @param isInstallPhase install or uninstall phase
+    * @return all matching registered callbacks or empty set if no such item
+    */
+   protected Set<CallbackItem> getCallbacks(Object name, boolean isInstallPhase)
+   {
+      lockRead();
+      try
+      {
+         Map<Object, Set<CallbackItem>> map = (isInstallPhase ? installCallbacks : uninstallCallbacks);
+         Set<CallbackItem> callbacks = map.get(name);
+         return callbacks != null ? callbacks : new HashSet<CallbackItem>();
+      }
+      finally
+      {
+         unlockRead();
+      }
+   }
+
+   /**
+    * Resolve callbacks.
+    *
+    * @param callbacks the callbacks
+    * @param state current context state
+    * @param execute do execute callback
+    * @param isInstallPhase install or uninstall phase
+    * @param type install or uninstall type
+    * @throws Throwable for any error
+    */
+   protected void resolveCallbacks(Set<CallbackItem> callbacks, ControllerState state, boolean execute, boolean isInstallPhase, boolean type) throws Throwable
+   {
+      if (callbacks != null && callbacks.isEmpty() == false)
+      {
+         for (CallbackItem callback : callbacks)
+         {
+            if (callback.getWhenRequired().equals(state))
+            {
+               if (isInstallPhase)
+               {
+                  addCallback(callback.getIDependOn(), type, callback);
+               }
+               else
+               {
+                  removeCallback(callback.getIDependOn(), type, callback);
+               }
+               if (execute)
+                  callback.ownerCallback(this);
+            }
+         }
+      }
+   }
+
+   /**
+    * Resolve callback items.
+    *
+    * @param context current context
+    * @param state current context state
+    * @param isInstallPhase install or uninstall phase
+    * @throws Throwable for any error
+    */
+   protected void resolveCallbacks(ControllerContext context, ControllerState state, boolean isInstallPhase) throws Throwable
+   {
+      Set<CallbackItem> installs = getDependencyCallbacks(context, true);
+      resolveCallbacks(installs, state, isInstallPhase, isInstallPhase, true);
+      Set<CallbackItem> uninstalls = getDependencyCallbacks(context, false);
+      resolveCallbacks(uninstalls, state, isInstallPhase == false, isInstallPhase, false);
+
+      // match callbacks by name
+      Set<CallbackItem> existingCallbacks = getCallbacks(context.getName(), isInstallPhase);
+      // match by classes
+      Collection<Class<?>> classes = getClassesImplemented(context.getTarget());
+      if (classes != null && classes.isEmpty() == false)
+      {
+         for (Class clazz : classes)
+         {
+            existingCallbacks.addAll(getCallbacks(clazz, isInstallPhase));
+         }
+      }
+
+      // Do the installs if we are at the required state
+      if (existingCallbacks != null && existingCallbacks.isEmpty() == false)
+      {
+         for(CallbackItem callback : existingCallbacks)
+         {
+            if (state.equals(callback.getDependentState()))
+               callback.additionCallback(this, context);
+         }
+      }
+   }
+
+   /**
+    * Get implemented classes.
+    *
+    * @param target target value / bean
+    * @return collection of implementing classes by target
+    */
+   protected Collection<Class<?>> getClassesImplemented(Object target)
+   {
+      if (target == null)
+         return null;
+      Set<Class<?>> classes = new HashSet<Class<?>>();
+      traverseClass(target.getClass(), classes);
+      return classes;
+   }
+
+   /**
+    * Recurse over classes.
+    *
+    * @param clazz current class
+    * @param classes classes holder set
+    */
+   protected void traverseClass(Class clazz, Set<Class<?>> classes)
+   {
+      if (clazz != null && Object.class.equals(clazz) == false)
+      {
+         classes.add(clazz);
+         traverseClass(clazz.getSuperclass(), classes);
+         Class[] interfaces = clazz.getInterfaces();
+         // traverse interfaces
+         for (Class intface : interfaces)
+         {
+            traverseClass(intface, classes);
+         }
+      }
+   }
+
+   /**
     * Install a context<p>
-    *
+    * <p/>
     * This method must be invoked with NO locks taken
     *
-    * @param context the context
+    * @param context   the context
     * @param fromState the from state
-    * @param toState the toState
+    * @param toState   the toState
     * @throws Throwable for any error
     */
    protected void install(ControllerContext context, ControllerState fromState, ControllerState toState) throws Throwable
@@ -836,12 +1048,12 @@
 
    /**
     * Uninstall a context<p>
-    *
+    * <p/>
     * This method must be invoked with NO locks taken
     *
-    * @param context the context
+    * @param context   the context
     * @param fromState the from state
-    * @param toState the to state
+    * @param toState   the to state
     */
    protected void uninstall(ControllerContext context, ControllerState fromState, ControllerState toState)
    {
@@ -850,7 +1062,7 @@
 
    /**
     * Whether we should advance the context<p>
-    *
+    * <p/>
     * This method must be invoked with the write lock taken
     *
     * @param context the context
@@ -906,14 +1118,14 @@
 
    /**
     * Get a registered context<p>
-    * 
+    * <p/>
     * This method should be invoked with at least the read lock taken
-    * 
-    * @param name the name with which to register it
+    *
+    * @param name      the name with which to register it
     * @param mustExist whether to throw an error when the context does not exist
     * @return context the registered context
     * @throws IllegalArgumentException for null parameters
-    * @throws IllegalStateException if the context if must exist is true and the context does not exist
+    * @throws IllegalStateException    if the context if must exist is true and the context does not exist
     */
    protected ControllerContext getRegisterControllerContext(Object name, boolean mustExist)
    {
@@ -928,12 +1140,12 @@
 
    /**
     * Register a context and all its aliases<p>
-    * 
+    * <p/>
     * This method must be invoked with the write lock taken
-    * 
+    *
     * @param context the context to register
     * @throws IllegalArgumentException for null parameters
-    * @throws IllegalStateException if the context is already registered with that name or alias
+    * @throws IllegalStateException    if the context is already registered with that name or alias
     */
    protected void registerControllerContext(ControllerContext context)
    {
@@ -941,7 +1153,7 @@
          throw new IllegalArgumentException("Null context");
 
       Set<Object> aliases = context.getAliases();
-      
+
       // Register the context
       Object name = context.getName();
       registerControllerContext(name, context);
@@ -977,7 +1189,7 @@
                      log.debug("Error unregistering alias: " + alias, ignored);
                   }
                }
-               
+
                // Unregister the context
                try
                {
@@ -994,12 +1206,12 @@
 
    /**
     * Unregister a context and all its aliases<p>
-    * 
+    * <p/>
     * This method must be invoked with the write lock taken
-    * 
+    *
     * @param context the context
     * @throws IllegalArgumentException for null parameters
-    * @throws IllegalStateException if the context is not registered
+    * @throws IllegalStateException    if the context is not registered
     */
    protected void unregisterControllerContext(ControllerContext context)
    {
@@ -1007,7 +1219,7 @@
          throw new IllegalArgumentException("Null context");
 
       Set<Object> aliases = context.getAliases();
-      
+
       // Unregister the context
       Object name = context.getName();
       unregisterControllerContext(name);
@@ -1031,15 +1243,15 @@
 
    /**
     * Register a context<p>
-    * 
+    * <p/>
     * This method must be invoked with the write lock taken<p>
-    * 
+    * <p/>
     * NOTE: You probably want to use the {@link #registerControllerContext(ControllerContext)}
-    * 
-    * @param name the name with which to register it
+    *
+    * @param name    the name with which to register it
     * @param context the context to register
     * @throws IllegalArgumentException for null parameters
-    * @throws IllegalStateException if the context is already registered with that name
+    * @throws IllegalStateException    if the context is already registered with that name
     */
    protected void registerControllerContext(Object name, ControllerContext context)
    {
@@ -1047,7 +1259,7 @@
          throw new IllegalArgumentException("Null name");
       if (context == null)
          throw new IllegalArgumentException("Null context");
-      
+
       if (allContexts.containsKey(name) == false)
          allContexts.put(name, context);
       else
@@ -1056,11 +1268,11 @@
 
    /**
     * Unregister a context<p>
-    * 
+    * <p/>
     * This method must be invoked with the write lock taken<p>
-    * 
+    * <p/>
     * NOTE: You probably want to use the {@link #unregisterControllerContext(ControllerContext)}
-    * 
+    *
     * @param name the name it was registered with
     * @throws IllegalArgumentException for null parameters
     */

Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractDependencyInfo.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractDependencyInfo.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractDependencyInfo.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -22,9 +22,9 @@
 package org.jboss.dependency.plugins;
 
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 
+import org.jboss.dependency.spi.CallbackItem;
 import org.jboss.dependency.spi.Controller;
 import org.jboss.dependency.spi.ControllerState;
 import org.jboss.dependency.spi.DependencyInfo;
@@ -50,6 +50,12 @@
    /** Unresolved dependencies */
    private Set<DependencyItem> unresolved = CollectionsFactory.createCopyOnWriteSet();
 
+   /** Install callbacks */
+   private Set<CallbackItem> installCallbacks = CollectionsFactory.createCopyOnWriteSet();
+
+   /** Uninstall callbacks */
+   private Set<CallbackItem> uninstallCallbacks = CollectionsFactory.createCopyOnWriteSet();
+
    /**
     * Create an abstract dependency info
     */
@@ -64,9 +70,8 @@
       else
       {
          HashSet<DependencyItem> set = new HashSet<DependencyItem>();
-         for (Iterator i = iDependOn.iterator(); i.hasNext();)
+         for (DependencyItem item : iDependOn)
          {
-            DependencyItem item = (DependencyItem) i.next();
             if (type.isInstance(item))
                set.add(item);
          }
@@ -95,9 +100,8 @@
       else
       {
          HashSet<DependencyItem> set = new HashSet<DependencyItem>();
-         for (Iterator i = dependsOnMe.iterator(); i.hasNext();)
+         for (DependencyItem item : dependsOnMe)
          {
-            DependencyItem item = (DependencyItem) i.next();
             if (type.isInstance(item))
                set.add(item);
          }
@@ -122,9 +126,8 @@
       boolean resolved = true;
       if (unresolved.isEmpty() == false)
       {
-         for (Iterator i = unresolved.iterator(); i.hasNext();)
+         for (DependencyItem item : unresolved)
          {
-            DependencyItem item = (DependencyItem) i.next();
             if (state.equals(item.getWhenRequired()) && item.resolve(controller) == false)
             {
                resolved = false;
@@ -139,7 +142,41 @@
    {
       return unresolved;
    }
-   
+
+   public void addInstallItem(CallbackItem callbackItem)
+   {
+      installCallbacks.add(callbackItem);
+      flushJBossObjectCache();
+   }
+
+   public void removeInstallItem(CallbackItem callbackItem)
+   {
+      installCallbacks.remove(callbackItem);
+      flushJBossObjectCache();
+   }
+
+   public Set<CallbackItem> getInstallItems()
+   {
+      return installCallbacks;
+   }
+
+   public void addUninstallItem(CallbackItem callbackItem)
+   {
+      uninstallCallbacks.add(callbackItem);
+      flushJBossObjectCache();
+   }
+
+   public void removeUninstallItem(CallbackItem callbackItem)
+   {
+      uninstallCallbacks.remove(callbackItem);
+      flushJBossObjectCache();
+   }
+
+   public Set<CallbackItem> getUninstallItems()
+   {
+      return uninstallCallbacks;
+   }
+
    public void toString(JBossStringBuilder buffer)
    {
       buffer.append("idependOn=").append(iDependOn);

Added: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AttributeCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AttributeCallbackItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AttributeCallbackItem.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,77 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.dependency.plugins;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.dispatch.AttributeDispatchContext;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Attribute callback item.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AttributeCallbackItem<T> extends AbstractCallbackItem<T>
+{
+   protected AttributeDispatchContext owner;
+   protected String attribute;
+
+   public AttributeCallbackItem(T name, AttributeDispatchContext owner, String attribute)
+   {
+      this(name, null, null, owner, attribute);
+   }
+
+   public AttributeCallbackItem(T name, ControllerState whenRequired, ControllerState dependentState, AttributeDispatchContext owner, String attribute)
+   {
+      super(name, whenRequired, dependentState);
+      init(owner, attribute);
+   }
+
+   protected void init(AttributeDispatchContext owner, String attribute)
+   {
+      if (owner == null)
+         throw new IllegalArgumentException("Null owner!");
+      if (attribute == null)
+         throw new IllegalArgumentException("Null attribute!");
+
+      this.owner = owner;
+      this.attribute = attribute;
+   }
+
+   protected void execute(Object target) throws Throwable
+   {
+      owner.set(attribute, target);      
+   }
+
+   protected void additionCallback(ControllerContext context) throws Throwable
+   {
+      execute(context.getTarget());
+   }
+
+   protected void toString(JBossStringBuilder buffer)
+   {
+      super.toString(buffer);
+      buffer.append(" owner=").append(owner);
+      buffer.append(" attribute=").append(attribute);
+   }
+}

Added: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/NamedCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/NamedCallbackItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/NamedCallbackItem.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.dependency.plugins;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.dispatch.AttributeDispatchContext;
+
+/**
+ * Named callback item.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class NamedCallbackItem extends AttributeCallbackItem<Object>
+{
+   public NamedCallbackItem(Object name, AttributeDispatchContext owner, String attribute)
+   {
+      super(name, owner, attribute);
+   }
+
+   public NamedCallbackItem(Object name, ControllerState whenRequired, ControllerState dependentState, AttributeDispatchContext context, String attribute)
+   {
+      super(name, whenRequired, dependentState, context, attribute);
+   }
+}

Added: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/SingleCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/SingleCallbackItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/SingleCallbackItem.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,91 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.dependency.plugins;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Single callback item.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SingleCallbackItem extends AbstractCallbackItem<Object>
+{
+   protected InvokeDispatchContext owner;
+   protected String method;
+   protected String signature;
+
+   public SingleCallbackItem(Object name, InvokeDispatchContext owner, String method)
+   {
+      this(name, owner, method, null);
+   }
+
+   public SingleCallbackItem(Object name, InvokeDispatchContext owner, String method, String signature)
+   {
+      this(name, null, null, owner, method, signature);
+   }
+
+   public SingleCallbackItem(Object name, ControllerState whenRequired, ControllerState dependentState, InvokeDispatchContext owner, String method)
+   {
+      this(name, whenRequired, dependentState, owner, method, null);
+   }
+
+   public SingleCallbackItem(Object name, ControllerState whenRequired, ControllerState dependentState, InvokeDispatchContext owner, String method, String signature)
+   {
+      super(name, whenRequired, dependentState);
+      init(owner, method, signature);
+   }
+
+   protected void init(InvokeDispatchContext owner, String method, String signature)
+   {
+      if (owner == null)
+         throw new IllegalArgumentException("Null owner!");
+      if (method == null)
+         throw new IllegalArgumentException("Null method!");
+
+      this.owner = owner;
+      this.method = method;
+      this.signature = signature;
+   }
+
+   protected void additionCallback(ControllerContext context) throws Throwable
+   {
+      Object target = context.getTarget();
+      if (target != null)
+      {
+         if (signature == null)
+            signature = target.getClass().getName();
+         owner.invoke(method, new Object[]{target}, new String[]{signature});
+      }
+   }
+
+   protected void toString(JBossStringBuilder buffer)
+   {
+      super.toString(buffer);
+      buffer.append(" owner=").append(owner);
+      buffer.append(" method=").append(method);
+      buffer.append(" signature=").append(signature);
+   }
+}

Copied: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/CallbackItem.java (from rev 62388, projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/InstallItem.java)
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/CallbackItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/CallbackItem.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,72 @@
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.dependency.spi;
+
+/**
+ * Callback information.
+ *
+ * @param <T> expected name type - Class, String, ...
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface CallbackItem<T>
+{
+   /**
+    * Get the object name i depend on
+    *
+    * @return the name
+    */
+   T getIDependOn();
+
+   /**
+    * Get when the dependency is required
+    *
+    * @return the state when required
+    */
+   ControllerState getWhenRequired();
+
+   /**
+    * Get the dependent's state
+    *
+    * @return the state of the required of the dependent
+    */
+   ControllerState getDependentState();
+
+   /**
+    * Execute callback when item added to controller.
+    *
+    * @param controller the controller
+    * @throws Throwable for any error
+    */
+   void ownerCallback(Controller controller) throws Throwable;
+
+   /**
+    * Execute callback with current new installed context.
+    *
+    * @param controller the controller
+    * @param context the new context
+    * @throws Throwable for any error
+    */
+   void additionCallback(Controller controller, ControllerContext context) throws Throwable;
+}

Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/Cardinality.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/Cardinality.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/Cardinality.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -23,16 +23,19 @@
 
 import java.io.Serializable;
 
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
 /**
  * Cardinality def.
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public class Cardinality implements Serializable
+public class Cardinality extends JBossObject implements Serializable
 {
-   private static final long serialVersionUID = 1L;
+   private static final long serialVersionUID = 2L;
   
-   private static final int INFINITY = -1;
+   public static final int INFINITY = -1;
 
    public static Cardinality ZERO_TO_ONE = new Cardinality("0..1", 0, 1);
    public static Cardinality ZERO_TO_MANY = new Cardinality("0..n", 0, INFINITY);
@@ -59,6 +62,17 @@
    }
 
    /**
+    * Is number in cardinality's range.
+    *
+    * @param number number to check
+    * @return left <= number <= right
+    */
+   public boolean isInRange(int number)
+   {
+      return (number < 0 || number < left || left == INFINITY) == false && (number <= right || right == INFINITY);
+   }
+
+   /**
     * Get the cardinality by type.
     *
     * @param type the commont type
@@ -73,10 +87,61 @@
             return c;
          }
       }
-      throw new IllegalArgumentException("Illegal Cardinality value: " + type);
+      return fromString(type);
    }
 
    /**
+    * Get limit from string.
+    *
+    * @param limit from string
+    * @return limit as int from string
+    */
+   protected static int getLimitFromString(String limit)
+   {
+      try
+      {
+         return Integer.parseInt(limit);
+      }
+      catch (NumberFormatException e)
+      {
+         return INFINITY;
+      }
+   }
+
+   /**
+    * Get limit as string.
+    *
+    * @param limit right limit
+    * @return limit as string
+    */
+   protected static String getLimitFromInt(int limit)
+   {
+      return limit == INFINITY ? "n" : String.valueOf(limit);
+   }
+
+   /**
+    * Parse cardinality from string - #1..#2.
+    *
+    * @param string cardinality string
+    * @return cardinality
+    */
+   public static Cardinality fromString(String string)
+   {
+      if (string == null)
+         throw new IllegalArgumentException("Null string.");
+
+      if (string.contains(".."))
+      {
+         String[] args = string.split("\\.\\.");
+         if (args == null || args.length != 2)
+            throw new IllegalArgumentException("Illegal cardinality format: " + string);
+         return createCardinality(getLimitFromString(args[0]), getLimitFromString(args[1]));
+      }
+      else
+         return createUnlimitedCardinality(Integer.valueOf(string));
+   }
+
+   /**
     * Create cardinality which starts at #start and has no limit.
     *
     * @param start the left number of cardinality interval
@@ -109,9 +174,32 @@
     */
    public static Cardinality createCardinality(int left, int right)
    {
-      return new Cardinality(left + ".." + right, left, right);
+      return new Cardinality(getLimitFromInt(left) + ".." + getLimitFromInt(right), left, right);
    }
 
+   protected int getHashCode()
+   {
+      return type.hashCode();
+   }
+
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      buffer.append("type=").append(type);
+   }
+
+   protected void toString(JBossStringBuilder buffer)
+   {
+      buffer.append("type=").append(type);
+   }
+
+   public boolean equals(Object obj)
+   {
+      if (obj instanceof Cardinality == false)
+         return false;
+      Cardinality card = (Cardinality)obj;
+      return left == card.left && right == card.right; 
+   }
+
    public String getType()
    {
       return type;
@@ -126,4 +214,14 @@
    {
       return right;
    }
+
+   public boolean isLeftInfinity()
+   {
+      return left <= INFINITY;
+   }
+
+   public boolean isRightInfinity()
+   {
+      return right <= INFINITY;
+   }
 }

Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/DependencyInfo.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/DependencyInfo.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/DependencyInfo.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -92,4 +92,46 @@
     * @return our unresolved dependencies
     */
    Set<DependencyItem> getUnresolvedDependencies();
+
+   /**
+    * Add a callback reference
+    *
+    * @param callbackItem the callback to add
+    */
+   void addInstallItem(CallbackItem callbackItem);
+
+   /**
+    * Remove a callback reference
+    *
+    * @param callbackItem the callback to remove
+    */
+   void removeInstallItem(CallbackItem callbackItem);
+
+   /**
+    * Return install callbacks.
+    *
+    * @return our install callbacks
+    */
+   Set<CallbackItem> getInstallItems();
+
+   /**
+    * Add a callback reference
+    *
+    * @param callbackItem the callback to add
+    */
+   void addUninstallItem(CallbackItem callbackItem);
+
+   /**
+    * Remove a callback reference
+    *
+    * @param callbackItem the callback to remove
+    */
+   void removeUninstallItem(CallbackItem callbackItem);
+
+   /**
+    * Return uninstall callbacks.
+    *
+    * @return our uninstall callbacks
+    */
+   Set<CallbackItem> getUninstallItems();
 }
\ No newline at end of file

Deleted: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/InstallItem.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/InstallItem.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/InstallItem.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -1,39 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, 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.dependency.spi;
-
-/**
- * Information about a install dependency.
- *
- * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
- */
-public interface InstallItem
-{
-   /**
-    * Get the cardinality.
-    *
-    * @return cardinality
-    */
-   Cardinality getCardinality();
-
-   //todo
-}

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-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractBeanMetaData.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -31,6 +31,7 @@
 
 import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.CallbackMetaData;
 import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
 import org.jboss.beans.metadata.spi.ConstructorMetaData;
 import org.jboss.beans.metadata.spi.DemandMetaData;
@@ -114,6 +115,12 @@
    /** The uninstall operations List<InstallMetaData> */
    protected List<InstallMetaData> uninstalls;
 
+   /** The install callback List<InstallMetaData> */
+   protected List<CallbackMetaData> installCallbacks;
+
+   /** The uninstall callback List<InstallMetaData> */
+   protected List<CallbackMetaData> uninstallCallbacks;
+
    /** The uninstall operations List<LifecycleCallbackMetaData> */
    protected List<LifecycleCallbackMetaData> lifecycleCallbacks;
 
@@ -479,6 +486,28 @@
       flushJBossObjectCache();
    }
 
+   public List<CallbackMetaData> getInstallCallbacks()
+   {
+      return installCallbacks;
+   }
+
+   public void setInstallCallbacks(List<CallbackMetaData> installCallbacks)
+   {
+      this.installCallbacks = installCallbacks;
+      flushJBossObjectCache();
+   }
+
+   public List<CallbackMetaData> getUninstallCallbacks()
+   {
+      return uninstallCallbacks;
+   }
+
+   public void setUninstallCallbacks(List<CallbackMetaData> uninstallCallbacks)
+   {
+      this.uninstallCallbacks = uninstallCallbacks;
+      flushJBossObjectCache();
+   }
+
    public void initialVisit(MetaDataVisitor visitor)
    {
       KernelControllerContext ctx = visitor.getControllerContext();
@@ -523,6 +552,10 @@
          children.addAll(installs);
       if (uninstalls != null)
          children.addAll(uninstalls);
+      if (installCallbacks != null)
+         children.addAll(installCallbacks);
+      if (uninstallCallbacks != null)
+         children.addAll(uninstallCallbacks);
       if (lifecycleCallbacks != null)
          children.addAll(lifecycleCallbacks);
    }
@@ -605,6 +638,16 @@
          buffer.append(" uninstalls=");
          JBossObject.list(buffer, uninstalls);
       }
+      if (installCallbacks != null)
+      {
+         buffer.append(" installCallbacks=");
+         JBossObject.list(buffer, installCallbacks);
+      }
+      if (uninstallCallbacks != null)
+      {
+         buffer.append(" uninstallCallbacks=");
+         JBossObject.list(buffer, uninstallCallbacks);
+      }
       if (lifecycleCallbacks != null)
       {
          buffer.append(" lifecycleCallbacks=");

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractCallbackMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractCallbackMetaData.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractCallbackMetaData.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,262 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.beans.metadata.plugins;
+
+import java.io.Serializable;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.beans.metadata.spi.CallbackMetaData;
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.dependency.plugins.NamedCallbackItem;
+import org.jboss.dependency.plugins.SingleCallbackItem;
+import org.jboss.dependency.spi.CallbackItem;
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.plugins.config.Configurator;
+import org.jboss.kernel.plugins.dependency.CallbackDependencyItem;
+import org.jboss.kernel.plugins.dependency.CollectionCallbackItemFactory;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Metadata for callback.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class AbstractCallbackMetaData extends AbstractLifecycleMetaData
+   implements CallbackMetaData, Serializable
+{
+   private static final long serialVersionUID = 1L;
+
+   /** The cardinality */
+   protected Cardinality cardinality;
+
+   /** The property name */
+   protected String property;
+
+   /** The required state of the dependency */
+   protected ControllerState whenRequired = ControllerState.CONFIGURED;
+
+   /** The required state of the dependency */
+   protected ControllerState dependentState = ControllerState.INSTALLED;
+
+   /** The signature */
+   protected String signature;
+
+   public AbstractCallbackMetaData()
+   {
+      setState(ControllerState.CONFIGURED);
+   }
+
+   public String getProperty()
+   {
+      return property;
+   }
+
+   /**
+    * Set the property.
+    *
+    * @param property property name
+    */
+   public void setProperty(String property)
+   {
+      this.property = property;
+      flushJBossObjectCache();
+   }
+
+   public Cardinality getCardinality()
+   {
+      return cardinality;
+   }
+
+   /**
+    * Set the cardinality.
+    *
+    * @param cardinality the cardinality
+    */
+   public void setCardinality(Cardinality cardinality)
+   {
+      this.cardinality = cardinality;
+      flushJBossObjectCache();
+   }
+
+   public ControllerState getWhenRequiredState()
+   {
+      return whenRequired;
+   }
+
+   /**
+    * Set when required state.
+    *
+    * @param whenRequired when is this call back required (default Configured)
+    */
+   public void setWhenRequired(ControllerState whenRequired)
+   {
+      this.whenRequired = whenRequired;
+      flushJBossObjectCache();
+   }
+
+   public String getSignature()
+   {
+      return signature;
+   }
+
+   /**
+    * Set the signature.
+    *
+    * @param signature method / property parameter signature
+    */
+   public void setSignature(String signature)
+   {
+      this.signature = signature;
+      flushJBossObjectCache();
+   }
+
+   /**
+    * Set the required state of the dependency
+    *
+    * @param dependentState the required state or null if it must be in the registry
+    */
+   public void setDependentState(ControllerState dependentState)
+   {
+      this.dependentState = dependentState;
+      flushJBossObjectCache();
+   }
+
+   public ControllerState getDependentState()
+   {
+      return dependentState;
+   }
+
+   /**
+    * Add install / uninstrall callback.
+    * 
+    * @param visitor the meta data visitor
+    * @param callback the callback item
+    */
+   protected abstract void addCallback(MetaDataVisitor visitor, CallbackItem callback);
+
+   @SuppressWarnings("unchecked")
+   protected CallbackItem createCollectionCallback(TypeInfo info, KernelControllerContext context, String attribute)
+   {
+      if (info instanceof ClassInfo && ((ClassInfo)info).getActualTypeArguments() != null)
+      {
+         ClassInfo ci = (ClassInfo)info;
+         TypeInfo[] typeInfos = ci.getActualTypeArguments();
+         if (typeInfos.length != 1)
+            throw new IllegalArgumentException("Illegal size of actual type arguments: " + info);
+         Class clazz = typeInfos[0].getType();
+         return CollectionCallbackItemFactory.createCollectionCallbackItem(info.getType(), clazz, whenRequired, dependentState, context, attribute);
+      }
+      else
+         throw new IllegalArgumentException("Unable to determine collection element class type: " + this);
+   }
+
+   public void describeVisit(MetaDataVisitor vistor)
+   {
+      try
+      {
+         KernelControllerContext context = vistor.getControllerContext();
+         CallbackItem callback;
+         if (property != null)
+         {
+            ClassLoader cl = Configurator.getClassLoader(context.getBeanMetaData());
+            PropertyInfo pi = Configurator.resolveProperty(log.isTraceEnabled(), context.getBeanInfo(), cl, property, signature);
+
+            TypeInfo info;
+            if (pi.getSetter() != null)
+               info = pi.getSetter().getParameterTypes()[0];
+            else
+               throw new IllegalArgumentException("No setter for property: " + pi);
+
+            if (info.isCollection())
+               callback = createCollectionCallback(info, context, property);
+            else
+               callback = new NamedCallbackItem(info.getType(), whenRequired, dependentState, context, property);
+         }
+         else if (methodName != null)
+         {
+            MethodInfo mi = Configurator.findMethodInfo(getClassInfo(context), methodName, new String[]{signature});
+            // signature matches one parameter
+            TypeInfo info = mi.getParameterTypes()[0];
+            if (info.isCollection())
+            {
+               callback = createCollectionCallback(info, context, methodName);
+            }
+            else
+            {
+               Class clazz = info.getType();
+               callback = new SingleCallbackItem(clazz, whenRequired, dependentState, context, methodName, clazz.getName());   
+            }
+         }
+         else
+            throw new IllegalArgumentException("Illegal usage - not property or method:" + this);
+         addCallback(vistor, callback);
+
+         // demand name is Class in this case
+         if (cardinality != null)
+         {
+/*
+            Controller controller = vistor.getControllerContext().getController();
+            List<ControllerState> states = controller.getStates();
+            int whenIndex = states.indexOf(whenRequired);
+            if (whenIndex < 0 || whenIndex + 1 == states.size())
+               throw new IllegalArgumentException("Illegal whenRequired state - check cardinality dependency: " + whenRequired);
+            ControllerState dependencyWhenRequired = states.get(whenIndex + 1);
+*/
+            vistor.addDependency(new CallbackDependencyItem(context.getName(), (Class)callback.getIDependOn(), whenRequired, dependentState, cardinality));
+         }
+      }
+      catch (Throwable t)
+      {
+         throw new Error(t);
+      }
+      super.describeVisit(vistor);
+   }
+
+   public void toString(JBossStringBuilder buffer)
+   {
+      super.toString(buffer);
+      if (property != null)
+         buffer.append(" property=").append(property);
+      if (cardinality != null)
+         buffer.append(" cardinality=").append(cardinality);
+      if (signature != null)
+         buffer.append(" signature=").append(signature);
+      if (ControllerState.INSTALLED.equals(dependentState) == false)
+         buffer.append(" dependentState=" + dependentState);
+      if (ControllerState.CONFIGURED.equals(whenRequired) == false)
+         buffer.append(" whenRequiredState=" + dependentState);
+   }
+
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      if (property != null)
+         buffer.append("property=").append(property);
+      if (methodName != null)
+         buffer.append("method=").append(methodName);
+   }
+
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyValueMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyValueMetaData.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractDependencyValueMetaData.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -28,6 +28,7 @@
 import org.jboss.dependency.spi.ControllerState;
 import org.jboss.dependency.spi.DependencyItem;
 import org.jboss.dependency.spi.dispatch.AttributeDispatchContext;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.reflect.spi.TypeInfo;
 import org.jboss.util.JBossStringBuilder;
 
@@ -42,7 +43,7 @@
    private static final long serialVersionUID = 2L;
 
    /** The context */
-   protected transient ControllerContext context;
+   protected transient KernelControllerContext context;
    
    /** The property name */
    protected String property;
@@ -134,6 +135,11 @@
       return dependentState;
    }
 
+   protected boolean isLookupValid(ControllerContext lookup)
+   {
+      return (lookup != null);
+   }
+
    public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable
    {
       ControllerState state = dependentState;
@@ -141,8 +147,13 @@
          state = ControllerState.INSTALLED;
       Controller controller = context.getController();
       ControllerContext lookup = controller.getContext(value, state);
+
+      if (isLookupValid(lookup) == false)
+         throw new Error("Should not be here - dependency failed - " + this);
+
       if (lookup == null)
-         throw new Error("Should not be here - dependency failed! " + this);
+         return null;
+
       Object result = lookup.getTarget();
       if (property != null && lookup instanceof AttributeDispatchContext)
       {
@@ -152,20 +163,29 @@
       return info != null ? info.convertValue(result) : result;
    }
 
+   protected boolean addDependencyItem()
+   {
+      return true;
+   }
+
    public void initialVisit(MetaDataVisitor visitor)
    {
       context = visitor.getControllerContext();
-      Object name = context.getName();
-      Object iDependOn = getUnderlyingValue();
-      ControllerState whenRequired = whenRequiredState;
-      if (whenRequired == null)
+      // used for sub class optional handling
+      if (addDependencyItem())
       {
-         whenRequired = visitor.getContextState();
-      }
+         Object name = context.getName();
+         Object iDependOn = getUnderlyingValue();
 
-      DependencyItem item = new AbstractDependencyItem(name, iDependOn, whenRequired, dependentState);
-      visitor.addDependency(item);
+         ControllerState whenRequired = whenRequiredState;
+         if (whenRequired == null)
+         {
+            whenRequired = visitor.getContextState();
+         }
 
+         DependencyItem item = new AbstractDependencyItem(name, iDependOn, whenRequired, dependentState);
+         visitor.addDependency(item);
+      }
       super.initialVisit(visitor);
    }
       

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractInjectionValueMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractInjectionValueMetaData.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractInjectionValueMetaData.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -23,8 +23,10 @@
 
 import org.jboss.beans.metadata.spi.MetaDataVisitor;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
+import org.jboss.dependency.plugins.NamedCallbackItem;
 import org.jboss.dependency.spi.Controller;
 import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
 import org.jboss.dependency.spi.DependencyItem;
 import org.jboss.kernel.plugins.dependency.ClassContextDependencyItem;
 import org.jboss.reflect.spi.TypeInfo;
@@ -37,10 +39,12 @@
  */
 public class AbstractInjectionValueMetaData extends AbstractDependencyValueMetaData
 {
-   private static final long serialVersionUID = 1L;
+   private static final long serialVersionUID = 2L;
 
    protected InjectionType injectionType = InjectionType.BY_CLASS;
 
+   protected InjectionOption injectionOption = InjectionOption.STRICT;
+
    /**
     * Simplyifies things with InjectionType.BY_NAME
     */
@@ -84,6 +88,16 @@
       this.injectionType = injectionType;
    }
 
+   public InjectionOption getInjectionOption()
+   {
+      return injectionOption;
+   }
+
+   public void setInjectionOption(InjectionOption injectionOption)
+   {
+      this.injectionOption = injectionOption;
+   }
+
    public AbstractPropertyMetaData getPropertyMetaData()
    {
       return propertyMetaData;
@@ -94,15 +108,42 @@
       this.propertyMetaData = propertyMetaData;
    }
 
+   protected void addInstallItem(Object name)
+   {
+      if (propertyMetaData == null)
+         throw new IllegalArgumentException("Illegal usage of option Callback - injection not used with property = " + this);
+      context.getDependencyInfo().addInstallItem(new NamedCallbackItem(name, whenRequiredState, dependentState, context, propertyMetaData.getName()));
+   }
+
+   protected boolean isLookupValid(ControllerContext lookup)
+   {
+      boolean lookupExists = super.isLookupValid(lookup);
+      boolean isCallback = InjectionOption.CALLBACK.equals(injectionOption);
+      if (lookupExists == false && isCallback)
+      {
+         addInstallItem(value);
+      }
+      return lookupExists || isCallback;
+   }
+
    public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable
    {
+      // by class type
       if (value == null)
       {
          Controller controller = context.getController();
          ControllerContext lookup = controller.getInstalledContext(info.getType());
          if (lookup == null)
          {
-            throw new IllegalArgumentException("Possible multiple matching beans, see log for info.");
+            if (InjectionOption.STRICT.equals(injectionOption))
+            {
+               throw new IllegalArgumentException("Possible multiple matching beans, see log for info.");
+            }
+            else
+            {
+               addInstallItem(info.getType());
+               return null;
+            }
          }
          // TODO - add progression here, then fix BeanMetaData as well
          return lookup.getTarget();
@@ -110,8 +151,14 @@
       return super.getValue(info, cl);
    }
 
+   protected boolean addDependencyItem()
+   {
+      return InjectionOption.STRICT.equals(injectionOption);
+   }
+
    public void initialVisit(MetaDataVisitor visitor)
    {
+      // no bean specified
       if (getUnderlyingValue() == null)
       {
          // check for property
@@ -124,13 +171,13 @@
          if (InjectionType.BY_NAME.equals(injectionType))
          {
             if (propertyMetaData == null)
-            {
                throw new IllegalArgumentException("Illegal usage of type ByName - injection not used with property = " + this);
-            }
             setValue(propertyMetaData.getName());
          }
-
-         visitor.initialVisit(this);
+         else
+         {
+            visitor.initialVisit(this);
+         }
       }
       // check if was maybe set with by_name
       if (getUnderlyingValue() != null)
@@ -141,48 +188,61 @@
 
    public void describeVisit(MetaDataVisitor visitor)
    {
+      // no bean and not by_name
       if (getUnderlyingValue() == null)
       {
          if (InjectionType.BY_CLASS.equals(injectionType))
          {
             context = visitor.getControllerContext();
 
-            // we pop it so that parent node has the same semantics as this one
-            // meaning that his current peek is also his parent
-            // and all other nodes that cannot determine type follow the same
-            // contract - popping and pushing
-            // maybe the whole thing can be rewritten to LinkedList
-            // or simply using the fact that Stack is also a Vector?
-            MetaDataVisitorNode node = visitor.visitorNodeStack().pop();
-            try
+            // dependency item or install item
+            if (InjectionOption.STRICT.equals(injectionOption))
             {
-               if (node instanceof TypeProvider)
+               // add dependency item only for strict inject behaviour
+               // we pop it so that parent node has the same semantics as this one
+               // meaning that his current peek is also his parent
+               // and all other nodes that cannot determine type follow the same
+               // contract - popping and pushing
+               // maybe the whole thing can be rewritten to LinkedList
+               // or simply using the fact that Stack is also a Vector?
+               MetaDataVisitorNode node = visitor.visitorNodeStack().pop();
+               try
                {
-                  TypeProvider typeProvider = (TypeProvider) node;
-                  DependencyItem item = new ClassContextDependencyItem(
-                        context.getName(),
-                        typeProvider.getType(visitor, this),
-                        visitor.getContextState(),
-                        dependentState);
-                  visitor.addDependency(item);
+                  if (node instanceof TypeProvider)
+                  {
+                     TypeProvider typeProvider = (TypeProvider)node;
+                     Class injectionClass = typeProvider.getType(visitor, this);
+                     // set when required
+                     ControllerState whenRequired = whenRequiredState;
+                     if (whenRequired == null)
+                     {
+                        whenRequired = visitor.getContextState();
+                     }
+                     DependencyItem item = new ClassContextDependencyItem(
+                           context.getName(),
+                           injectionClass,
+                           whenRequired,
+                           dependentState);
+                     visitor.addDependency(item);
+                  }
+                  else
+                  {
+                     throw new Error(TypeProvider.ERROR_MSG);
+                  }
                }
-               else
+               catch (Error error)
                {
-                  throw new Error(TypeProvider.ERROR_MSG);
+                  throw error;
                }
+               catch (Throwable throwable)
+               {
+                  throw new Error(throwable);
+               }
+               finally
+               {
+                  visitor.visitorNodeStack().push(node);
+               }
             }
-            catch (Error error)
-            {
-               throw error;
-            }
-            catch (Throwable throwable)
-            {
-               throw new Error(throwable);
-            }
-            finally
-            {
-               visitor.visitorNodeStack().push(node);
-            }
          }
          else
          {

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractInstallMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractInstallMetaData.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractInstallMetaData.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -26,14 +26,14 @@
 import org.jboss.beans.metadata.spi.InstallMetaData;
 import org.jboss.beans.metadata.spi.MetaDataVisitor;
 import org.jboss.dependency.plugins.AbstractDependencyItem;
+import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.dependency.spi.ControllerState;
 import org.jboss.dependency.spi.DependencyItem;
-import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.kernel.spi.config.KernelConfigurator;
+import org.jboss.kernel.spi.dependency.KernelController;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.kernel.spi.config.KernelConfigurator;
+import org.jboss.reflect.spi.ClassInfo;
 import org.jboss.util.JBossStringBuilder;
-import org.jboss.reflect.spi.ClassInfo;
 
 /**
  * Metadata for installation.
@@ -126,7 +126,7 @@
    {
       if (bean != null)
          buffer.append("bean=").append(bean);
-      if (dependentState != ControllerState.INSTALLED);
+      if (ControllerState.INSTALLED.equals(dependentState) == false)
          buffer.append(" dependentState=" + dependentState);
       buffer.append(" ");
       super.toString(buffer);
@@ -135,9 +135,11 @@
    public void toShortString(JBossStringBuilder buffer)
    {
       if (bean != null)
-         buffer.append(bean);
+      {
+         buffer.append(bean).append(".");
+      }
       if (methodName != null)
-         buffer.append(".").append(methodName);
+         buffer.append(methodName);
    }
 
    /**

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractTypeMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractTypeMetaData.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/AbstractTypeMetaData.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -157,7 +157,7 @@
                if (target != null)
                {
                   BeanInfo beanInfo = configurator.getBeanInfo(target.getClass());
-                  PropertyInfo pi = Configurator.resolveProperty(log.isTraceEnabled(), beanInfo, propertyName);
+                  PropertyInfo pi = Configurator.resolveProperty(log.isTraceEnabled(), beanInfo, cl, propertyName, null);
                   if (pi.getGetter() != null)
                   {
                      result = ((AttributeDispatchContext)context).get(propertyName);

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InjectionOption.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InjectionOption.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InjectionOption.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,107 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.beans.metadata.plugins;
+
+import java.io.Serializable;
+
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Injection option:
+ *  * Strict - exactly one matching context (default)
+ *  * Callback - issue callback once context with matching is present
+ *
+ * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
+ */
+public class InjectionOption extends JBossObject
+      implements Serializable
+{
+   private static final long serialVersionUID = 1L;
+
+   /** Strict */
+   public static final InjectionOption STRICT = new InjectionOption("Strict");
+
+   /** Loose */
+   public static final InjectionOption CALLBACK = new InjectionOption("Callback");
+
+   /** The type string */
+   protected final String optionString;
+
+   /**
+    * Create a new state
+    *
+    * @param optionString the string representation
+    */
+   private InjectionOption(String optionString)
+   {
+      if (optionString == null)
+         throw new IllegalArgumentException("Null option string");
+      this.optionString = optionString;
+   }
+
+   /**
+    * Return injection type.
+    * Or exception if no matching type.
+    *
+    * @param optionString type
+    * @return InjectionType instance
+    */
+   public static InjectionOption getInstance(String optionString)
+   {
+      if (STRICT.getOptionString().equalsIgnoreCase(optionString))
+         return STRICT;
+      else if (CALLBACK.getOptionString().equalsIgnoreCase(optionString))
+         return CALLBACK;
+      else
+         throw new IllegalArgumentException("No such option: " + optionString);
+   }
+
+   /**
+    * Get the state string
+    *
+    * @return the state string
+    */
+   public String getOptionString()
+   {
+      return optionString;
+   }
+
+   public boolean equals(Object object)
+   {
+      if (object == null || object instanceof InjectionOption == false)
+         return false;
+      InjectionOption other = (InjectionOption) object;
+      return optionString.equals(other.getOptionString());
+   }
+
+   public void toString(JBossStringBuilder buffer)
+   {
+      buffer.append(optionString);
+   }
+
+   protected int getHashCode()
+   {
+      return optionString.hashCode();
+   }
+
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InjectionType.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InjectionType.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InjectionType.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -27,6 +27,10 @@
 import org.jboss.util.JBossStringBuilder;
 
 /**
+ * Injection type:
+ *  * ByClass - matching the class type of value (default)
+ *  * ByName - matching the property name
+ *
  * @author <a href="mailto:ales.justin at genera-lynx.com">Ales Justin</a>
  */
 public class InjectionType extends JBossObject
@@ -48,7 +52,7 @@
     *
     * @param typeString the string representation
     */
-   public InjectionType(String typeString)
+   private InjectionType(String typeString)
    {
       if (typeString == null)
          throw new IllegalArgumentException("Null type string");
@@ -56,6 +60,23 @@
    }
 
    /**
+    * Return injection type.
+    * Or exception if no matching type.
+    *
+    * @param typeString type
+    * @return InjectionType instance
+    */
+   public static InjectionType getInstance(String typeString)
+   {
+      if ("ByClass".equalsIgnoreCase(typeString))
+         return BY_CLASS;
+      else if ("ByName".equalsIgnoreCase(typeString))
+         return BY_NAME;
+      else
+         throw new IllegalArgumentException("No such type: " + typeString);
+   }
+
+   /**
     * Get the state string
     *
     * @return the state string

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InstallCallbackMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InstallCallbackMetaData.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/InstallCallbackMetaData.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.beans.metadata.plugins;
+
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.dependency.spi.CallbackItem;
+
+/**
+ * Metadata for install callback.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class InstallCallbackMetaData extends AbstractCallbackMetaData
+{
+   public InstallCallbackMetaData()
+   {
+      super();
+   }
+
+   protected void addCallback(MetaDataVisitor visitor, CallbackItem callback)
+   {
+      visitor.addInstallCallback(callback);
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/TypeProvider.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/TypeProvider.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/TypeProvider.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -29,9 +29,17 @@
  */
 public interface TypeProvider
 {
+   // error msg
+   static final String ERROR_MSG = "Node not of TypeProvider instance, cannot determine class type.";
 
-   static final String ERROR_MSG = "Node not of TypeProvider instance, cannot determine class type."; 
-
+   /**
+    * Get the injectee class type.
+    *
+    * @param visitor meda data visitor
+    * @param previous previous node in the stack
+    * @return class type for injection ByClass
+    * @throws Throwable if could not determine class
+    */
    Class getType(MetaDataVisitor visitor, MetaDataVisitorNode previous) throws Throwable;
 
 }

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/UninstallCallbackMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/UninstallCallbackMetaData.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/UninstallCallbackMetaData.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.beans.metadata.plugins;
+
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.dependency.spi.CallbackItem;
+
+/**
+ * Metadata for uninstall callback.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class UninstallCallbackMetaData extends AbstractCallbackMetaData
+{
+   public UninstallCallbackMetaData()
+   {
+      super();
+   }
+
+   protected void addCallback(MetaDataVisitor visitor, CallbackItem callback)
+   {
+      visitor.addUninstallCallback(callback);
+   }
+}

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-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/BeanMetaData.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -176,6 +176,20 @@
    List<InstallMetaData> getUninstalls();
    
    /**
+    * Get the installation oeprations.
+    *
+    * @return List<InstallMetaData>
+    */
+   List<CallbackMetaData> getInstallCallbacks();
+
+   /**
+    * Get the uninstallation operations.
+    *
+    * @return List<InstallMetaData>
+    */
+   List<CallbackMetaData> getUninstallCallbacks();
+
+   /**
     * Get the lifecycle callbacks.
     * 
     * @return List<LifecycleCallbackMetaData>

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/CallbackMetaData.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/CallbackMetaData.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/CallbackMetaData.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,68 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.beans.metadata.spi;
+
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * Metadata about a callback method.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface CallbackMetaData extends LifecycleMetaData
+{
+   /**
+    * Get the cardinality.
+    *
+    * @return cardinality
+    */
+   Cardinality getCardinality();
+
+   /**
+    * Get the property name.
+    *
+    * @return the property name.
+    */
+   String getProperty();
+
+   /**
+    * Get the required state of the dependency
+    *
+    * @return the required state
+    */
+   ControllerState getDependentState();
+
+   /**
+    * Get the when required state
+    *
+    * @return the required state
+    */
+   ControllerState getWhenRequiredState();
+
+   /**
+    * Get signature.
+    *
+    * @return method / property parameter signature
+    */
+   String getSignature();
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/MetaDataVisitor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/MetaDataVisitor.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/MetaDataVisitor.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -23,6 +23,7 @@
 
 import java.util.Stack;
 
+import org.jboss.dependency.spi.CallbackItem;
 import org.jboss.dependency.spi.ControllerState;
 import org.jboss.dependency.spi.DependencyItem;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
@@ -64,6 +65,20 @@
    void addDependency(DependencyItem dependency);
    
    /**
+    * Add an install callback
+    *
+    * @param callback the callback
+    */
+   void addInstallCallback(CallbackItem callback);
+
+   /**
+    * Add an uninstall callback
+    *
+    * @param callback the callback
+    */
+   void addUninstallCallback(CallbackItem callback);
+
+   /**
     * Visit the node
     * 
     * @param node the node

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/Inject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/Inject.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/Inject.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -21,10 +21,10 @@
 */
 package org.jboss.beans.metadata.spi.annotations;
 
-import java.lang.annotation.Target;
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
 
 /**
  * Beans when injected by class type are by default changed to configured
@@ -45,4 +45,6 @@
 
    InjectType type() default InjectType.BY_CLASS;
 
+   InjectOption option() default InjectOption.STRICT;
+
 }

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/InjectOption.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/InjectOption.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/InjectOption.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,46 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.beans.metadata.spi.annotations;
+
+/**
+ * Injection option - strict or optional / callback.
+ *
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public enum InjectOption
+{
+   STRICT("Strict"),
+   CALLBACK("Callback");
+
+   private String optionString;
+
+   InjectOption(String optionString)
+   {
+      this.optionString = optionString;
+   }
+
+   public String toString()
+   {
+      return optionString;
+   }
+
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/InjectType.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/InjectType.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/annotations/InjectType.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -22,6 +22,8 @@
 package org.jboss.beans.metadata.spi.annotations;
 
 /**
+ * Injection type - by class or by property name.
+ *
  * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
  */
 public enum InjectType

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -21,6 +21,7 @@
 */
 package org.jboss.kernel.plugins.dependency;
 
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -213,6 +214,28 @@
    }
 
    /**
+    * Get contexts by class.
+    * This method should be taken with read lock.
+    *
+    * @param clazz the class type
+    * @return contexts by class
+    */
+   protected Set<KernelControllerContext> getContexts(Class clazz)
+   {
+      ClassContext classContext = contextsByClass.get(clazz);
+      if (classContext != null)
+      {
+         if (log.isTraceEnabled())
+         {
+            log.trace("Marking class " + clazz + " as used.");
+         }
+         classContext.used = true;
+         return classContext.contexts;
+      }
+      return null;
+   }
+
+   /**
     * @return all instantiated contexts whose target is instance of this class clazz param
     */
    public Set<KernelControllerContext> getInstantiatedContexts(Class clazz)
@@ -220,17 +243,35 @@
       lockRead();
       try
       {
-         ClassContext classContext = contextsByClass.get(clazz);
-         if (classContext != null)
+         return Collections.unmodifiableSet(getContexts(clazz));
+      }
+      finally
+      {
+         unlockRead();
+      }
+   }
+
+   public Set<KernelControllerContext> getContexts(Class clazz, ControllerState state)
+   {
+      lockRead();
+      try
+      {
+         Set<KernelControllerContext> contexts = getContexts(clazz);
+         if (contexts != null && contexts.isEmpty() == false)
          {
-            if (log.isTraceEnabled())
+            Set<KernelControllerContext> kccs = new HashSet<KernelControllerContext>();
+            List<ControllerState> states = getStates();
+            int stateIndex = states.indexOf(state);
+            for(KernelControllerContext context : contexts)
             {
-               log.trace("Marking class " + clazz + " as used.");
+               int contextStateIndex = states.indexOf(context.getState());
+               if (contextStateIndex >= stateIndex)
+                  kccs.add(context);
             }
-            classContext.used = true;
-            return classContext.contexts;
+            return Collections.unmodifiableSet(kccs);
          }
-         return null;
+         else
+            return null;
       }
       finally
       {
@@ -238,19 +279,11 @@
       }
    }
 
-   /**
-    * add instantiated context into contextsByClass map
-    * look at all target's superclasses and interfaces
-    */
    public void addInstantiatedContext(KernelControllerContext context)
    {
       prepareToTraverse(context, true);
    }
 
-   /**
-    * remove instantiated context from contextsByClass map
-    * look at all target's superclasses and interfaces
-    */
    public void removeInstantiatedContext(KernelControllerContext context)
    {
       prepareToTraverse(context, false);

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-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -36,6 +36,7 @@
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
 import org.jboss.dependency.plugins.AbstractControllerContext;
 import org.jboss.dependency.plugins.AbstractDependencyInfo;
+import org.jboss.dependency.spi.CallbackItem;
 import org.jboss.dependency.spi.Controller;
 import org.jboss.dependency.spi.ControllerMode;
 import org.jboss.dependency.spi.ControllerState;
@@ -239,10 +240,11 @@
       DependencyInfo dependencyInfo = getDependencyInfo();
       if (dependencyInfo != null)
       {
-         Set dependencys = dependencyInfo.getIDependOn(ClassContextDependencyItem.class);
-         for(Iterator it = dependencys.iterator(); it.hasNext();)
+         // remove all dependency items that hold class ref
+         Set<DependencyItem> dependencys = dependencyInfo.getIDependOn(ClassContextDependencyItem.class);
+         dependencys.addAll(dependencyInfo.getIDependOn(CallbackDependencyItem.class));
+         for (DependencyItem di : dependencys)
          {
-            DependencyItem di = (DependencyItem) it.next();
             di.unresolved(getController());
          }
       }
@@ -346,6 +348,16 @@
          getDependencyInfo().addIDependOn(dependency);
       }
 
+      public void addInstallCallback(CallbackItem callback)
+      {
+         getDependencyInfo().addInstallItem(callback);
+      }
+
+      public void addUninstallCallback(CallbackItem callback)
+      {
+         getDependencyInfo().addUninstallItem(callback);
+      }
+
       public void setContextState(ControllerState contextState)
       {
          this.contextState = contextState;

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CallbackDependencyItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CallbackDependencyItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CallbackDependencyItem.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,74 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.plugins.dependency;
+
+import java.util.Set;
+
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * A Callback dependencyItem.
+ *
+ * @author <a href="ales.justin at gmail.com">Ales Justin</a>
+ */
+public class CallbackDependencyItem extends ClassDependencyItem
+{
+   private Cardinality cardinality;
+
+   public CallbackDependencyItem(Object name, Class demandClass, ControllerState whenRequired, ControllerState dependentState, Cardinality cardinality)
+   {
+      super(name, demandClass, whenRequired, dependentState);
+      if (cardinality == null)
+         throw new IllegalArgumentException("Null cardinality.");
+      this.cardinality = cardinality;
+   }
+
+   public boolean resolve(Controller controller)
+   {
+      if (controller instanceof KernelController == false)
+         throw new IllegalArgumentException("Controller not KernelController!");
+
+      KernelController kernelController = (KernelController)controller;
+      Set<KernelControllerContext> contexts = kernelController.getInstantiatedContexts(getDemandClass());
+      int size = contexts != null ? contexts.size() : 0;
+      if (cardinality.isInRange(size))
+      {
+         setIDependOn(getIDependOn());
+         if (contexts != null)
+         {
+            for (KernelControllerContext context : contexts)
+               addDependsOnMe(controller, context);
+         }
+         setResolved(true);
+      }
+      else
+      {
+         setResolved(false);
+      }
+      return isResolved();
+   }
+
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ClassContextDependencyItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ClassContextDependencyItem.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ClassContextDependencyItem.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -24,15 +24,13 @@
 import org.jboss.dependency.spi.Controller;
 import org.jboss.dependency.spi.ControllerContext;
 import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.plugins.AbstractDependencyItem;
-import org.jboss.util.JBossStringBuilder;
 
 /**
  * A Class context dependencyItem.
  *
  * @author <a href="ales.justin at gmail.com">Ales Justin</a>
  */
-public class ClassContextDependencyItem extends AbstractDependencyItem
+public class ClassContextDependencyItem extends ClassDependencyItem
 {
    public ClassContextDependencyItem(Object name, Class demandClass, ControllerState whenRequired, ControllerState dependentState)
    {
@@ -55,23 +53,6 @@
       return isResolved();
    }
 
-   public void unresolved(Controller controller)
-   {
-      setIDependOn(null);
-      super.unresolved(controller);
-   }
-
-   public void toString(JBossStringBuilder buffer)
-   {
-      super.toString(buffer);
-      buffer.append(" demandClass=").append(getIDependOn());
-   }
-
-   public void toShortString(JBossStringBuilder buffer)
-   {
-      buffer.append(getName()).append(" demands ").append(getIDependOn());
-   }
-
 }
 
 

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ClassDependencyItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ClassDependencyItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ClassDependencyItem.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.plugins.dependency;
+
+import org.jboss.dependency.plugins.AbstractDependencyItem;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * A class dependant dependencyItem.
+ *
+ * @author <a href="ales.justin at gmail.com">Ales Justin</a>
+ */
+public abstract class ClassDependencyItem extends AbstractDependencyItem
+{
+   public ClassDependencyItem(Object name, Class demandClass, ControllerState whenRequired, ControllerState dependentState)
+   {
+      super(name, demandClass, whenRequired, dependentState);
+   }
+
+   protected Class getDemandClass()
+   {
+      return (Class)getIDependOn();
+   }
+
+   public void unresolved(Controller controller)
+   {
+      setIDependOn(null);
+      super.unresolved(controller);
+   }
+
+   public void toString(JBossStringBuilder buffer)
+   {
+      super.toString(buffer);
+      buffer.append(" demandClass=").append(getIDependOn());
+   }
+
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      buffer.append(getName()).append(" demands ").append(getIDependOn());
+   }
+
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItem.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,86 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.plugins.dependency;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.jboss.dependency.plugins.AttributeCallbackItem;
+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.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * Collection callback item.
+ *
+ * @param <T> expected collection type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class CollectionCallbackItem<T extends Collection<Object>> extends AttributeCallbackItem<Class>
+{
+   public CollectionCallbackItem(Class name, InvokeDispatchContext owner, String attribute)
+   {
+      super(name, owner, attribute);
+   }
+
+   public CollectionCallbackItem(Class name, ControllerState whenRequired, ControllerState dependentState, InvokeDispatchContext context, String attribute)
+   {
+      super(name, whenRequired, dependentState, context, attribute);
+   }
+
+   /**
+    * Create new collection impl instance - HashSet, ArrayList, ...
+    *
+    * @return new collection impl instance
+    */
+   protected abstract T getCollectionParameterHolder();
+
+   public void ownerCallback(Controller controller) throws Throwable
+   {
+      if (controller instanceof KernelController)
+      {
+         KernelController kernelController = (KernelController)controller;
+         T holder = getCollectionParameterHolder();
+         Set<KernelControllerContext> contexts = kernelController.getContexts(getIDependOn(), dependentState);
+         if (contexts != null && contexts.isEmpty() == false)
+         {
+            for(ControllerContext context : contexts)
+            {
+               holder.add(context.getTarget());
+            }
+         }
+         execute(holder);
+      }
+      else
+      {
+         log.warn("Cannot execute Collection call back - controller not KernelController instance.");
+      }
+   }
+
+   public void additionCallback(Controller controller, ControllerContext context) throws Throwable
+   {
+      ownerCallback(controller);
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItemFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItemFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CollectionCallbackItemFactory.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,68 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.plugins.dependency;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+
+/**
+ * Collection callback item factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CollectionCallbackItemFactory
+{
+   public static CollectionCallbackItem createCollectionCallbackItem(
+         Class<? extends Collection> parameterClass,
+         Class name,
+         InvokeDispatchContext context,
+         String attribute)
+   {
+      return createCollectionCallbackItem(parameterClass, name, null, null, context, attribute);
+   }
+
+   public static CollectionCallbackItem createCollectionCallbackItem(
+         Class<? extends Collection> parameterClass,
+         Class name,
+         ControllerState whenRequired,
+         ControllerState dependentState,
+         InvokeDispatchContext context,
+         String attribute)
+   {
+      if (parameterClass == null)
+         throw new IllegalArgumentException("Null parameter class!");
+
+      if (parameterClass.isAssignableFrom(ArrayList.class))
+         return new ListCallbackItem(name, whenRequired, dependentState, context, attribute);
+      else if (parameterClass.isAssignableFrom(HashSet.class))
+         return new SetCallbackItem(name, whenRequired, dependentState, context, attribute);
+      else if (parameterClass.isAssignableFrom(LinkedList.class))
+         return new QueueCallbackItem(name, whenRequired, dependentState, context, attribute);
+      else
+         throw new IllegalArgumentException("No matching callback impl for parameter type: " + parameterClass);
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ListCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ListCallbackItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ListCallbackItem.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,51 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.plugins.dependency;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+
+/**
+ * List callback item.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ListCallbackItem extends CollectionCallbackItem<List<Object>>
+{
+   public ListCallbackItem(Class name, InvokeDispatchContext owner, String attribute)
+   {
+      super(name, owner, attribute);
+   }
+
+   public ListCallbackItem(Class name, ControllerState whenRequired, ControllerState dependentState, InvokeDispatchContext context, String attribute)
+   {
+      super(name, whenRequired, dependentState, context, attribute);
+   }
+
+   protected List<Object> getCollectionParameterHolder()
+   {
+      return new ArrayList<Object>();
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/QueueCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/QueueCallbackItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/QueueCallbackItem.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,51 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.plugins.dependency;
+
+import java.util.LinkedList;
+import java.util.Queue;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+
+/**
+ * Queue callback item.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class QueueCallbackItem extends CollectionCallbackItem<Queue<Object>>
+{
+   public QueueCallbackItem(Class name, InvokeDispatchContext owner, String attribute)
+   {
+      super(name, owner, attribute);
+   }
+
+   public QueueCallbackItem(Class name, ControllerState whenRequired, ControllerState dependentState, InvokeDispatchContext context, String attribute)
+   {
+      super(name, whenRequired, dependentState, context, attribute);
+   }
+
+   protected Queue<Object> getCollectionParameterHolder()
+   {
+      return new LinkedList<Object>();
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ScopedKernelController.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ScopedKernelController.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/ScopedKernelController.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -197,6 +197,34 @@
       }
    }
 
+   public Set<KernelControllerContext> getContexts(Class clazz, ControllerState state)
+   {
+      lockRead();
+      try
+      {
+         Set<KernelControllerContext> contexts = new HashSet<KernelControllerContext>();
+         Set<KernelControllerContext> currentContexts = super.getContexts(clazz, state);
+         if (currentContexts != null && currentContexts.size() > 0)
+         {
+            contexts.addAll(currentContexts);
+         }
+         if (isParentKernelController())
+         {
+            Set<KernelControllerContext> parentContexts = getParentKernelController().getContexts(clazz, state);
+            if (parentContexts != null && parentContexts.size() > 0)
+            {
+               contexts.addAll(parentContexts);
+            }
+         }
+         return contexts.size() > 0 ? contexts : null;
+      }
+      finally{
+         unlockRead();
+      }
+   }
+
+   
+
    // KernelRegistry plugin method
 
    public KernelRegistryEntry getEntry(Object name)

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SetCallbackItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SetCallbackItem.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/SetCallbackItem.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,51 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.plugins.dependency;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+
+/**
+ * Set callback item.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SetCallbackItem extends CollectionCallbackItem<Set<Object>>
+{
+   public SetCallbackItem(Class name, InvokeDispatchContext owner, String attribute)
+   {
+      super(name, owner, attribute);
+   }
+
+   public SetCallbackItem(Class name, ControllerState whenRequired, ControllerState dependentState, InvokeDispatchContext context, String attribute)
+   {
+      super(name, whenRequired, dependentState, context, attribute);
+   }
+
+   protected Set<Object> getCollectionParameterHolder()
+   {
+      return new HashSet<Object>();
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployer.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/AbstractKernelDeployer.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -79,6 +79,17 @@
    }
 
    /**
+    * Create a new kernel deployer with mode
+    *
+    * @param kernel the kernel
+    * @param mode the controller mode
+    */
+   public AbstractKernelDeployer(Kernel kernel, ControllerMode mode)
+   {
+      this(kernel, null, mode);
+   }
+
+   /**
     * Create a new kernel deployer
     * 
     * @param kernel the kernel

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/BasicKernelDeployer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/BasicKernelDeployer.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/BasicKernelDeployer.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -25,6 +25,7 @@
 import java.util.ListIterator;
 import java.util.concurrent.CopyOnWriteArrayList;
 
+import org.jboss.dependency.spi.ControllerMode;
 import org.jboss.kernel.Kernel;
 import org.jboss.kernel.spi.deployment.KernelDeployment;
 import org.jboss.logging.Logger;
@@ -53,9 +54,20 @@
     */
    public BasicKernelDeployer(Kernel kernel)
    {
-      super(kernel);
+      this(kernel, null);
    }
 
+   /**
+    * Create a new BasicKernelDeployer with mode.
+    *
+    * @param kernel the kernel
+    * @param mode the controller mode
+    */
+   public BasicKernelDeployer(Kernel kernel, ControllerMode mode)
+   {
+      super(kernel, mode);
+   }
+
    public void deploy(KernelDeployment deployment) throws Throwable
    {
       final boolean trace = log.isTraceEnabled();

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BasicXMLDeployer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BasicXMLDeployer.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BasicXMLDeployer.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -27,6 +27,7 @@
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.jboss.dependency.spi.ControllerMode;
 import org.jboss.kernel.Kernel;
 import org.jboss.kernel.plugins.deployment.BasicKernelDeployer;
 import org.jboss.kernel.spi.deployment.KernelDeployment;
@@ -63,9 +64,20 @@
     */
    public BasicXMLDeployer(Kernel kernel)
    {
-      super(kernel);
+      this(kernel, null);
    }
 
+   /**
+    * Create a new XML deployer with mode.
+    *
+    * @param kernel the kernel
+    * @param mode the controller mode
+    */
+   public BasicXMLDeployer(Kernel kernel, ControllerMode mode)
+   {
+      super(kernel, mode);
+   }
+
    public Collection getDeploymentNames()
    {
       return deploymentsByName.keySet();

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanInstallCallbackInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanInstallCallbackInterceptor.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanInstallCallbackInterceptor.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.plugins.deployment.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+import org.jboss.beans.metadata.spi.CallbackMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * BeanInstallInterceptor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanInstallCallbackInterceptor extends DefaultElementInterceptor
+{
+   /** The interceptor */
+   public static final BeanInstallCallbackInterceptor INTERCEPTOR = new BeanInstallCallbackInterceptor();
+
+   public void add(Object parent, Object child, QName name)
+   {
+      AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
+      AbstractCallbackMetaData callback = (AbstractCallbackMetaData) child;
+      List<CallbackMetaData> callbacks = bean.getInstallCallbacks();
+      if (callbacks == null)
+      {
+         callbacks = new ArrayList<CallbackMetaData>();
+         bean.setInstallCallbacks(callbacks);
+      }
+      callbacks.add(callback);
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -45,6 +45,7 @@
 import org.jboss.beans.metadata.plugins.AbstractSetMetaData;
 import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
 import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
+import org.jboss.beans.metadata.plugins.InjectionOption;
 import org.jboss.beans.metadata.plugins.InjectionType;
 import org.jboss.beans.metadata.plugins.StringValueMetaData;
 import org.jboss.beans.metadata.plugins.factory.GenericBeanFactoryMetaData;
@@ -1041,7 +1042,9 @@
                else if ("whenRequired".equals(localName))
                   injection.setWhenRequiredState(new ControllerState(attrs.getValue(i)));
                else if ("type".equals(localName))
-                  injection.setInjectionType(new InjectionType(attrs.getValue(i)));
+                  injection.setInjectionType(InjectionType.getInstance(attrs.getValue(i)));
+               else if ("option".equals(localName))
+                  injection.setInjectionOption(InjectionOption.getInstance(attrs.getValue(i)));
             }
          }
 
@@ -1213,6 +1216,7 @@
    
    /**
     * Configure a collection.
+    * @param qname collection qname
     */
    private static void configureCollection(QName qname)
    {

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding20.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding20.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBinding20.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -107,12 +107,21 @@
    /** The install binding */
    public static final QName installTypeQName = new QName(BEAN_DEPLOYER_NS, "installType");
 
+   /** The install binding */
+   public static final QName callbackTypeQName = new QName(BEAN_DEPLOYER_NS, "callbackType");
+
    /** The install element name */
    public static final QName installQName = new QName(BEAN_DEPLOYER_NS, "install");
 
-   /** The start element name */
+   /** The uninstall element name */
    public static final QName uninstallQName = new QName(BEAN_DEPLOYER_NS, "uninstall");
 
+   /** The install callback element name */
+   public static final QName installCallbackQName = new QName(BEAN_DEPLOYER_NS, "incallback");
+
+   /** The uninstall callback element name */
+   public static final QName uninstallCallbackQName = new QName(BEAN_DEPLOYER_NS, "uncallback");
+
    /** The property binding */
    public static final QName propertyTypeQName = new QName(BEAN_DEPLOYER_NS, "propertyType");
 
@@ -290,6 +299,10 @@
       TypeBinding installType = schemaBinding.getType(installTypeQName);
       BeanSchemaBindingHelper.initInstallHandlers(installType);
 
+      // callback binding
+      TypeBinding callbackType = schemaBinding.getType(callbackTypeQName);
+      BeanSchemaBindingHelper.initCallbackHandlers(callbackType);
+
       // property binding
       TypeBinding propertyType = schemaBinding.getType(propertyTypeQName);
       BeanSchemaBindingHelper.initPropertyHandlers(propertyType);

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBindingHelper.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBindingHelper.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanSchemaBindingHelper.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -102,6 +102,12 @@
       // bean has uninstalls
       beanType.pushInterceptor(BeanSchemaBinding20.uninstallQName, BeanUninstallInterceptor.INTERCEPTOR);
 
+      // bean has installs
+      beanType.pushInterceptor(BeanSchemaBinding20.installCallbackQName, BeanInstallCallbackInterceptor.INTERCEPTOR);
+
+      // bean has uninstalls
+      beanType.pushInterceptor(BeanSchemaBinding20.uninstallCallbackQName, BeanUninstallCallbackInterceptor.INTERCEPTOR);
+
       // bean has depends
       beanType.pushInterceptor(BeanSchemaBinding20.dependsQName, BeanDependsInterceptor.INTERCEPTOR);
 
@@ -145,6 +151,12 @@
       // bean factory has uninstalls
       beanFactoryType.pushInterceptor(BeanSchemaBinding20.uninstallQName, BeanUninstallInterceptor.INTERCEPTOR);
 
+      // bean has installs
+      beanFactoryType.pushInterceptor(BeanSchemaBinding20.installCallbackQName, BeanInstallCallbackInterceptor.INTERCEPTOR);
+
+      // bean has uninstalls
+      beanFactoryType.pushInterceptor(BeanSchemaBinding20.uninstallCallbackQName, BeanUninstallCallbackInterceptor.INTERCEPTOR);
+
       // bean factory has depends
       beanFactoryType.pushInterceptor(BeanSchemaBinding20.dependsQName, BeanDependsInterceptor.INTERCEPTOR);
 
@@ -257,6 +269,19 @@
    }
 
    /**
+    * Initialize the handlers for the callback type
+    *
+    * @param installType the install type
+    */
+   public static void initCallbackHandlers(TypeBinding installType)
+   {
+      installType.setHandler(CallbackHandler.HANDLER);
+
+      // install has annotations
+      installType.pushInterceptor(BeanSchemaBinding20.annotationQName, CallbackAnnotationsInterceptor.INTERCEPTOR);
+   }
+
+   /**
     * Initialize the handlers for the alias type
     * 
     * @param aliasType the alias type

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanUninstallCallbackInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanUninstallCallbackInterceptor.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/BeanUninstallCallbackInterceptor.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.plugins.deployment.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+import org.jboss.beans.metadata.spi.CallbackMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * BeanInstallInterceptor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanUninstallCallbackInterceptor extends DefaultElementInterceptor
+{
+   /** The interceptor */
+   public static final BeanUninstallCallbackInterceptor INTERCEPTOR = new BeanUninstallCallbackInterceptor();
+
+   public void add(Object parent, Object child, QName name)
+   {
+      AbstractBeanMetaData bean = (AbstractBeanMetaData) parent;
+      AbstractCallbackMetaData callback = (AbstractCallbackMetaData) child;
+      List<CallbackMetaData> callbacks = bean.getUninstallCallbacks();
+      if (callbacks == null)
+      {
+         callbacks = new ArrayList<CallbackMetaData>();
+         bean.setUninstallCallbacks(callbacks);
+      }
+      callbacks.add(callback);
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/CallbackAnnotationsInterceptor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/CallbackAnnotationsInterceptor.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/CallbackAnnotationsInterceptor.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,55 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.plugins.deployment.xml;
+
+import java.util.HashSet;
+import java.util.Set;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.AbstractAnnotationMetaData;
+import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+import org.jboss.beans.metadata.spi.AnnotationMetaData;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementInterceptor;
+
+/**
+ * CallbackAnnotationsInterceptor.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CallbackAnnotationsInterceptor extends DefaultElementInterceptor
+{
+   /** The interceptor */
+   public static final CallbackAnnotationsInterceptor INTERCEPTOR = new CallbackAnnotationsInterceptor();
+
+   public void add(Object parent, Object child, QName name)
+   {
+      AbstractCallbackMetaData callbackMetaData = (AbstractCallbackMetaData) parent;
+      AbstractAnnotationMetaData annotation = (AbstractAnnotationMetaData) child;
+      Set<AnnotationMetaData> annotations = callbackMetaData.getAnnotations();
+      if (annotations == null)
+      {
+         annotations = new HashSet<AnnotationMetaData>();
+         callbackMetaData.setAnnotations(annotations);
+      }
+      annotations.add(annotation);
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/CallbackHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/CallbackHandler.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/CallbackHandler.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,83 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.plugins.deployment.xml;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+import org.jboss.beans.metadata.plugins.InstallCallbackMetaData;
+import org.jboss.beans.metadata.plugins.UninstallCallbackMetaData;
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
+import org.xml.sax.Attributes;
+
+/**
+ * CallbackHandler.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CallbackHandler extends DefaultElementHandler
+{
+   /** The handler */
+   public static final CallbackHandler HANDLER = new CallbackHandler();
+
+   public Object startElement(Object parent, QName name, ElementBinding element)
+   {
+      QName qname = element.getQName();
+      boolean isInstall = qname.getLocalPart().startsWith("in");
+      return isInstall ? new InstallCallbackMetaData() : new UninstallCallbackMetaData();
+   }
+
+   public void attributes(Object o, QName elementName, ElementBinding element, Attributes attrs, NamespaceContext nsCtx)
+   {
+      AbstractCallbackMetaData callbackMetaData = (AbstractCallbackMetaData) o;
+      for (int i = 0; i < attrs.getLength(); ++i)
+      {
+         String localName = attrs.getLocalName(i);
+         if ("property".equals(localName))
+            callbackMetaData.setProperty(attrs.getValue(i));
+         else if ("method".equals(localName))
+            callbackMetaData.setMethodName(attrs.getValue(i));
+         else if ("state".equals(localName))
+            callbackMetaData.setDependentState(new ControllerState(attrs.getValue(i)));
+         else if ("whenRequired".equals(localName))
+            callbackMetaData.setWhenRequired(new ControllerState(attrs.getValue(i)));
+         else if ("signature".equals(localName))
+            callbackMetaData.setSignature(attrs.getValue(i));
+         else if ("cardinality".equals(localName))
+            callbackMetaData.setCardinality(Cardinality.toCardinality(attrs.getValue(i)));
+      }
+   }
+
+   public Object endElement(Object o, QName qName, ElementBinding element)
+   {
+      AbstractCallbackMetaData callbackMetaData = (AbstractCallbackMetaData) o;
+      if (callbackMetaData.getMethodName() == null && callbackMetaData.getProperty() == null)
+         throw new IllegalArgumentException("Install/uninstall callback should have method or property attribute.");
+      if (callbackMetaData.getMethodName() != null && callbackMetaData.getProperty() != null)
+         throw new IllegalArgumentException("Install/uninstall callback should have exactly one of method or property attribute.");
+      return callbackMetaData;
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/InjectionHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/InjectionHandler.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/deployment/xml/InjectionHandler.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -7,9 +7,10 @@
 import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
 
-import org.jboss.beans.metadata.plugins.InjectionType;
 import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
 import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
+import org.jboss.beans.metadata.plugins.InjectionOption;
+import org.jboss.beans.metadata.plugins.InjectionType;
 import org.jboss.dependency.spi.ControllerState;
 import org.jboss.xb.binding.sunday.unmarshalling.DefaultElementHandler;
 import org.jboss.xb.binding.sunday.unmarshalling.ElementBinding;
@@ -52,7 +53,9 @@
          else if ("whenRequired".equals(localName))
             injection.setWhenRequiredState(new ControllerState(attrs.getValue(i)));
          else if ("type".equals(localName))
-            injection.setInjectionType(new InjectionType(attrs.getValue(i)));
+            injection.setInjectionType(InjectionType.getInstance(attrs.getValue(i)));
+         else if ("option".equals(localName))
+            injection.setInjectionOption(InjectionOption.getInstance(attrs.getValue(i)));
       }
    }
 

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelController.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelController.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelController.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -25,6 +25,7 @@
 
 import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerState;
 import org.jboss.kernel.spi.KernelObject;
 
 /**
@@ -82,6 +83,15 @@
    Set<KernelControllerContext> getInstantiatedContexts(Class clazz);
 
    /**
+    * Get all contexts of a type which are at least in state.
+    *
+    * @param clazz the type
+    * @param state the required state
+    * @return the contexts
+    */
+   Set<KernelControllerContext> getContexts(Class clazz, ControllerState state);
+
+   /**
     * If zero or multiple instances match class clazz
     * a warning is issued, but no throwable is thrown
     *
@@ -91,7 +101,7 @@
    KernelControllerContext getContextByClass(Class clazz);
 
    /**
-    * add instantiated context into contextsByClass map
+    * Add instantiated context into contextsByClass map
     * look at all target's superclasses and interfaces
     * 
     * @param context the context
@@ -99,7 +109,7 @@
    void addInstantiatedContext(KernelControllerContext context);
 
    /**
-    * remove instantiated context from contextsByClass map
+    * Remove instantiated context from contextsByClass map
     * look at all target's superclasses and interfaces
     * 
     * @param context the context

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/ManualMicrocontainerTest.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/ManualMicrocontainerTest.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/ManualMicrocontainerTest.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,42 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.junit;
+
+import org.jboss.test.AbstractTestDelegate;
+
+/**
+ * Manual controller mode deployer.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ManualMicrocontainerTest extends MicrocontainerTest
+{
+   public ManualMicrocontainerTest(String name)
+   {
+      super(name);
+   }
+
+   public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+   {
+      return new ManualMicrocontainerTestDelegate(clazz);
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/ManualMicrocontainerTestDelegate.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/ManualMicrocontainerTestDelegate.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/ManualMicrocontainerTestDelegate.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,43 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.junit;
+
+import org.jboss.dependency.spi.ControllerMode;
+
+/**
+ * A Manual MicrocontainerTest.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ManualMicrocontainerTestDelegate extends ModeMicrocontainerTestDelegate
+{
+   public ManualMicrocontainerTestDelegate(Class clazz)
+         throws Exception
+   {
+      super(clazz);
+   }
+
+   protected ControllerMode getControllerMode()
+   {
+      return ControllerMode.MANUAL;
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/MicrocontainerTestDelegate.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -72,8 +72,8 @@
          kernel = bootstrap.getKernel();
          
          // Create the deployer
-         deployer = new BasicXMLDeployer(kernel);
-         
+         deployer = createDeployer();
+
          // Deploy
          deploy();
       }
@@ -95,6 +95,11 @@
       }
    }
 
+   protected BasicXMLDeployer createDeployer()
+   {
+      return new BasicXMLDeployer(kernel);
+   }
+
    public void tearDown() throws Exception
    {
       super.tearDown();
@@ -276,15 +281,25 @@
     */
    protected void deploy() throws Exception
    {
-      String testName = clazz.getName();
-      testName = testName.replace('.', '/') + ".xml";
-      URL url = clazz.getClassLoader().getResource(testName);
+      String testName = getTestName();
+      URL url = getTestResource(testName);
       if (url != null)
          deploy(url);
       else
          log.debug("No test specific deployment " + testName);
    }
 
+   protected String getTestName()
+   {
+      String testName = clazz.getName();
+      return testName.replace('.', '/') + ".xml";
+   }
+
+   protected URL getTestResource(String testName)
+   {
+      return clazz.getClassLoader().getResource(testName);
+   }
+
    /**
     * Undeploy all
     */

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/ModeMicrocontainerTestDelegate.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/ModeMicrocontainerTestDelegate.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/test/kernel/junit/ModeMicrocontainerTestDelegate.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,51 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.junit;
+
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+
+/**
+ * A Mode MicrocontainerTest.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class ModeMicrocontainerTestDelegate extends MicrocontainerTestDelegate
+{
+   public ModeMicrocontainerTestDelegate(Class clazz)
+         throws Exception
+   {
+      super(clazz);
+   }
+
+   /**
+    * Get the mode onf this deployer.
+    *
+    * @return deployer mode
+    */
+   protected abstract ControllerMode getControllerMode();
+
+   protected BasicXMLDeployer createDeployer()
+   {
+      return new BasicXMLDeployer(kernel, getControllerMode());
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_1_0.xsd
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_1_0.xsd	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_1_0.xsd	2007-04-21 21:20:20 UTC (rev 62474)
@@ -277,6 +277,11 @@
            <bean name="InjectedIntoMe" ...>
               <property name="transactionManager"><inject type="ByName"/></property>
            </bean>
+
+           e.g. Contextual injection - set optional injection; execute callback if currently no matching context exists
+           <bean name="InjectedIntoMe" ...>
+              <property name="transactionManager"><inject option="Callback"/></property>
+           </bean>
            ]]>
          </xsd:documentation>
       </xsd:annotation>
@@ -285,6 +290,7 @@
       <xsd:attribute name="state" type="controllerStateType" use="optional"/>
       <xsd:attribute name="whenRequired" type="controllerStateType" use="optional"/>
       <xsd:attribute name="type" type="injectionTypeType" use="optional" default="ByClass"/>
+      <xsd:attribute name="option" type="optionType" use="optional" default="Strict"/>
    </xsd:complexType>
 
    <xsd:complexType name="parameterType" mixed="true">
@@ -780,6 +786,22 @@
       </xsd:restriction>
    </xsd:simpleType>
 
+   <xsd:simpleType name="optionType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+            You can set the type of lookup option - Strict or Callback
+            Valid values include:
+            Strict (default)
+            Callback
+            ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:restriction base="xsd:string">
+         <xsd:whiteSpace value="collapse"/>
+      </xsd:restriction>
+   </xsd:simpleType>
+
    <!--
      WARN:
      Do not use this in the bean deployer, it won't work!

Modified: projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_2_0.xsd
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_2_0.xsd	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/resources/main/schema/bean-deployer_2_0.xsd	2007-04-21 21:20:20 UTC (rev 62474)
@@ -94,6 +94,8 @@
          <xsd:element name="supply" type="supplyType" minOccurs="0" maxOccurs="unbounded"/>
          <xsd:element name="install" type="installType" minOccurs="0" maxOccurs="unbounded"/>
          <xsd:element name="uninstall" type="installType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="incallback" type="callbackType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="uncallback" type="callbackType" minOccurs="0" maxOccurs="unbounded"/>
       </xsd:sequence>
       <xsd:attribute name="name" type="xsd:string" use="optional"/>
       <xsd:attribute name="class" type="xsd:token" use="optional"/>
@@ -162,6 +164,8 @@
          <xsd:element name="supply" type="supplyType" minOccurs="0" maxOccurs="unbounded"/>
          <xsd:element name="install" type="installType" minOccurs="0" maxOccurs="unbounded"/>
          <xsd:element name="uninstall" type="installType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="incallback" type="callbackType" minOccurs="0" maxOccurs="unbounded"/>
+         <xsd:element name="uncallback" type="callbackType" minOccurs="0" maxOccurs="unbounded"/>
       </xsd:sequence>
       <xsd:attribute name="name" type="xsd:string" use="optional"/>
       <xsd:attribute name="class" type="xsd:token" use="required"/>
@@ -283,6 +287,33 @@
       <xsd:attribute name="state" type="controllerStateType" use="optional"/>
    </xsd:complexType>
 
+   <xsd:complexType name="callbackType">
+      <xsd:annotation>
+         <xsd:documentation>
+           <![CDATA[
+           Callback item description.
+           Define you methods for callback invocation.
+
+           e.g.
+           <bean>
+              <callback method="addSomething" />
+              <callback property="items" cardinality="2..n" />
+              <callback property="info" signature="org.jboss.test.Info"/>
+           </bean>
+           ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:sequence>
+         <xsd:element name="annotation" type="annotationType" minOccurs="0" maxOccurs="unbounded"/>
+      </xsd:sequence>
+      <xsd:attribute name="method" type="xsd:token" use="optional"/>
+      <xsd:attribute name="property" type="xsd:token" use="optional"/>
+      <xsd:attribute name="cardinality" type="xsd:token" use="optional"/>
+      <xsd:attribute name="whenRequired" type="controllerStateType" use="optional"/>
+      <xsd:attribute name="state" type="controllerStateType" use="optional"/>
+      <xsd:attribute name="signature" type="xsd:token" use="optional"/>
+   </xsd:complexType>
+
    <xsd:complexType name="dependencyType">
       <xsd:annotation>
          <xsd:documentation>
@@ -338,6 +369,11 @@
            <bean name="InjectedIntoMe" ...>
               <property name="transactionManager"><inject type="ByName"/></property>
            </bean>
+
+           e.g. Contextual injection - set optional injection; execute callback if currently no matching context exists 
+           <bean name="InjectedIntoMe" ...>
+              <property name="transactionManager"><inject option="Callback"/></property>
+           </bean>
            ]]>
          </xsd:documentation>
       </xsd:annotation>
@@ -346,6 +382,7 @@
       <xsd:attribute name="state" type="controllerStateType" use="optional"/>
       <xsd:attribute name="whenRequired" type="controllerStateType" use="optional"/>
       <xsd:attribute name="type" type="injectionTypeType" use="optional" default="ByClass"/>
+      <xsd:attribute name="option" type="optionType" use="optional" default="Strict"/>
    </xsd:complexType>
 
    <xsd:complexType name="factoryType">
@@ -900,6 +937,22 @@
       </xsd:restriction>
    </xsd:simpleType>
 
+   <xsd:simpleType name="optionType">
+      <xsd:annotation>
+         <xsd:documentation>
+            <![CDATA[
+            You can set the type of lookup option - Strict or Callback
+            Valid values include:
+            Strict (default)
+            Callback
+            ]]>
+         </xsd:documentation>
+      </xsd:annotation>
+      <xsd:restriction base="xsd:string">
+         <xsd:whiteSpace value="collapse"/>
+      </xsd:restriction>
+   </xsd:simpleType>
+
    <!--
      WARN:
      Do not use this in the bean deployer, it won't work!

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithInstallCallback.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithInstallCallback.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithInstallCallback.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beanfactory xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <incallback method="Install1"/>
+</beanfactory>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithInstallCallbacks.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithInstallCallbacks.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithInstallCallbacks.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beanfactory xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <incallback method="Install1"/>
+   <incallback method="Install2"/>
+   <incallback method="Install3"/>
+</beanfactory>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithUninstallCallback.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithUninstallCallback.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithUninstallCallback.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beanfactory xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <uncallback method="Uninstall1"/>
+</beanfactory>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithUninstallCallbacks.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithUninstallCallbacks.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryWithUninstallCallbacks.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<beanfactory xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <uncallback method="Uninstall1"/>
+   <uncallback method="Uninstall2"/>
+   <uncallback method="Uninstall3"/>
+</beanfactory>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithInstallCallback.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithInstallCallback.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithInstallCallback.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <incallback method="Install1"/>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithInstallCallbacks.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithInstallCallbacks.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithInstallCallbacks.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <incallback method="Install1"/>
+   <incallback method="Install2"/>
+   <incallback method="Install3"/>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithUninstallCallback.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithUninstallCallback.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithUninstallCallback.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <uncallback method="Uninstall1"/>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithUninstallCallbacks.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithUninstallCallbacks.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/BeanWithUninstallCallbacks.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <uncallback method="Uninstall1"/>
+   <uncallback method="Uninstall2"/>
+   <uncallback method="Uninstall3"/>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallBadMethodProperty.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallBadMethodProperty.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallBadMethodProperty.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <incallback method="Dummy" property="someP" />
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithAnnotation.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithAnnotation.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithAnnotation.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <incallback method="Dummy">
+      <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation1</annotation>
+   </incallback>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithAnnotations.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithAnnotations.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithAnnotations.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <incallback method="Dummy">
+      <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation1</annotation>
+      <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation2</annotation>
+      <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation3</annotation>
+   </incallback>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithCardinality.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithCardinality.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithCardinality.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <incallback cardinality="1..n" method="Dummy"/>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithMethod.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithMethod.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithMethod.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <incallback method="someMethod"/>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithProperty.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithProperty.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithProperty.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <incallback property="someProperty"/>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithSignature.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithSignature.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithSignature.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <incallback signature="someSignature" method="Dummy"/>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithState.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithState.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackInstallWithState.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <incallback method="Dummy" state="Configured"/>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallBadMethodProperty.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallBadMethodProperty.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallBadMethodProperty.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <uncallback method="Dummy" property="someP" />
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithAnnotation.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithAnnotation.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithAnnotation.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <uncallback method="Dummy">
+      <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation1</annotation>
+   </uncallback>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithAnnotations.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithAnnotations.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithAnnotations.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <uncallback method="Dummy">
+      <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation1</annotation>
+      <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation2</annotation>
+      <annotation>@org.jboss.test.kernel.deployment.xml.support.Annotation3</annotation>
+   </uncallback>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithCardinality.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithCardinality.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithCardinality.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <uncallback cardinality="2..10" method="Dummy"/>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithMethod.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithMethod.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithMethod.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <uncallback method="someMethod"/>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithProperty.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithProperty.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithProperty.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <uncallback property="someProperty"/>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithSignature.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithSignature.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithSignature.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <uncallback signature="someSignature" method="Dummy"/>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithState.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithState.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/deployment/xml/test/CallbackUninstallWithState.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<bean xmlns="urn:jboss:bean-deployer:2.0" class="Dummy">
+   <uncallback method="Dummy" state="Configured"/>
+</bean>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/AdditionCallbackTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/AdditionCallbackTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/AdditionCallbackTestCase.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
+            xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="testObject" class="org.jboss.test.kernel.inject.support.CallbackTestObject">
+      <incallback method="addTesterInterface"/>
+      <uncallback method="removeTesterInterface"/>
+   </bean>
+
+   <bean name="tester1" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+   <bean name="tester2" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+   <bean name="tester3" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+</deployment>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
+            xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="testObject" class="org.jboss.test.kernel.inject.support.CallbackTestObject">
+      <incallback property="testerInterfaces" cardinality="2..n" whenRequired="Create"/>
+      <uncallback property="testerInterfaces"/>
+   </bean>
+
+   <bean name="tester1" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+   <bean name="tester2" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+   <bean name="tester3" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+</deployment>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CollectionCallbackTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CollectionCallbackTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/CollectionCallbackTestCase.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_2_0.xsd"
+            xmlns="urn:jboss:bean-deployer:2.0">
+
+   <bean name="testObject" class="org.jboss.test.kernel.inject.support.CallbackTestObject">
+      <incallback property="testerInterfaces"/>
+      <uncallback property="testerInterfaces"/>
+   </bean>
+
+   <bean name="tester1" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+   <bean name="tester2" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+   <bean name="tester3" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+</deployment>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/InjectionValueCallbackTestCase.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/InjectionValueCallbackTestCase.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/InjectionValueCallbackTestCase.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+            xmlns="urn:jboss:bean-deployer">
+
+   <bean name="testObject" class="org.jboss.test.kernel.inject.support.PropertyInjectTestObject">
+      <property name="testerInterface"><inject option="Callback"/></property>
+   </bean>
+
+   <bean name="tester" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+</deployment>

Added: projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/MultipleContextualInjection.xml
===================================================================
--- projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/MultipleContextualInjection.xml	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/resources/tests/org/jboss/test/kernel/inject/test/MultipleContextualInjection.xml	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+            xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+            xmlns="urn:jboss:bean-deployer">
+
+   <bean name="duplicateTester1" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+   <bean name="duplicateTester2" class="org.jboss.test.kernel.inject.support.DuplicateTester"/>
+
+   <bean name="testObject" class="org.jboss.test.kernel.inject.support.PropertyInjectTestObject">
+      <property name="testerInterface"><inject/></property>
+   </bean>
+
+
+</deployment>

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/AnnotatedLifecycleTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/AnnotatedLifecycleTestCase.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/AnnotatedLifecycleTestCase.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -22,15 +22,17 @@
 package org.jboss.test.kernel.deployment.test;
 
 import junit.framework.Test;
-
 import org.jboss.dependency.spi.ControllerState;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.test.kernel.deployment.support.AnnotatedLifecycleBean;
+import org.jboss.test.kernel.junit.ManualMicrocontainerTest;
 
 /**
+ * Test lifecycle annotations.
+ * 
  * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
  */
-public class AnnotatedLifecycleTestCase extends AbstractDeploymentTest
+public class AnnotatedLifecycleTestCase extends ManualMicrocontainerTest
 {
 
    private static final String BEAN_NAME = "LifecycleBean";
@@ -50,8 +52,10 @@
       AnnotatedLifecycleBean target;
 
       KernelControllerContext context = getControllerContext(BEAN_NAME, ControllerState.NOT_INSTALLED);
+      assertEquals(context.getState(), ControllerState.NOT_INSTALLED);
 
       change(context, ControllerState.CREATE);
+      assertEquals(context.getState(), ControllerState.CREATE);
       target = (AnnotatedLifecycleBean) context.getTarget();
       assertTrue(target.isCreate());
       assertFalse(target.isStart());
@@ -59,6 +63,7 @@
       assertFalse(target.isDestroy());
 
       change(context, ControllerState.START);
+      assertEquals(context.getState(), ControllerState.START);
       target = (AnnotatedLifecycleBean) context.getTarget();
       assertTrue(target.isCreate());
       assertTrue(target.isStart());
@@ -66,6 +71,7 @@
       assertFalse(target.isDestroy());
 
       change(context, ControllerState.CREATE);
+      assertEquals(context.getState(), ControllerState.CREATE);
       target = (AnnotatedLifecycleBean) context.getTarget();
       assertTrue(target.isCreate());
       assertFalse(target.isStart());
@@ -73,6 +79,7 @@
       assertFalse(target.isDestroy());
 
       change(context, ControllerState.CONFIGURED);
+      assertEquals(context.getState(), ControllerState.CONFIGURED);
       target = (AnnotatedLifecycleBean) context.getTarget();
       assertFalse(target.isCreate());
       assertFalse(target.isStart());

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/AbstractXMLTest.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/AbstractXMLTest.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/AbstractXMLTest.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -40,6 +40,7 @@
 import org.jboss.beans.metadata.plugins.ThisValueMetaData;
 import org.jboss.beans.metadata.plugins.factory.GenericBeanFactoryMetaData;
 import org.jboss.beans.metadata.spi.AnnotationMetaData;
+import org.jboss.beans.metadata.spi.CallbackMetaData;
 import org.jboss.beans.metadata.spi.DemandMetaData;
 import org.jboss.beans.metadata.spi.DependencyMetaData;
 import org.jboss.beans.metadata.spi.InstallMetaData;
@@ -252,6 +253,18 @@
       }
    }
    
+   protected void assertCallbacks(List expected, List callbacks)
+   {
+      assertNotNull(callbacks);
+      assertEquals(expected.size(), callbacks.size());
+      for (int i = 0; i < expected.size(); ++i)
+      {
+         CallbackMetaData callback = (CallbackMetaData) callbacks.get(i);
+         String method = (String) expected.get(i);
+         assertEquals(method, callback.getMethodName());
+      }
+   }
+
    protected void assertParameters(List expected, List parameters)
    {
       assertNotNull(parameters);

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryTestCase.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BeanFactoryTestCase.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -25,7 +25,6 @@
 import java.util.HashSet;
 
 import junit.framework.Test;
-
 import org.jboss.beans.metadata.plugins.factory.GenericBeanFactory;
 import org.jboss.beans.metadata.plugins.factory.GenericBeanFactoryMetaData;
 import org.jboss.dependency.spi.ControllerMode;
@@ -61,6 +60,8 @@
       assertNull(factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithClass() throws Exception
@@ -86,6 +87,8 @@
       assertNull(factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithMode() throws Exception
@@ -111,6 +114,8 @@
       assertNull(factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithClassLoader() throws Exception
@@ -136,6 +141,8 @@
       assertNull(factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithConstructor() throws Exception
@@ -161,6 +168,8 @@
       assertNull(factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithProperty() throws Exception
@@ -188,6 +197,8 @@
       assertNull(factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithProperties() throws Exception
@@ -216,6 +227,8 @@
       assertNull(factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithCreate() throws Exception
@@ -240,6 +253,8 @@
       assertNull(factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithStart() throws Exception
@@ -264,6 +279,8 @@
       assertNull(factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithDependency() throws Exception
@@ -291,6 +308,8 @@
       assertNull(factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithDependencies() throws Exception
@@ -320,6 +339,8 @@
       assertNull(factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithDemand() throws Exception
@@ -347,6 +368,8 @@
       assertNull(factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithDemands() throws Exception
@@ -376,6 +399,8 @@
       assertNull(factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithSupply() throws Exception
@@ -403,6 +428,8 @@
       assertSupplies(expected, factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithSupplies() throws Exception
@@ -432,6 +459,8 @@
       assertSupplies(expected, factory.getSupplies());
       assertNull(factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithInstall() throws Exception
@@ -459,6 +488,8 @@
       expected.add("Install1");
       assertInstalls(expected, factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithInstalls() throws Exception
@@ -488,6 +519,8 @@
       expected.add("Install3");
       assertInstalls(expected, factory.getInstalls());
       assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithUninstall() throws Exception
@@ -515,6 +548,8 @@
       ArrayList<String> expected = new ArrayList<String>();
       expected.add("Uninstall1");
       assertInstalls(expected, factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
    public void testBeanFactoryWithUninstalls() throws Exception
@@ -544,8 +579,130 @@
       expected.add("Uninstall2");
       expected.add("Uninstall3");
       assertInstalls(expected, factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
    }
 
+   public void testBeanFactoryWithInstallCallback() throws Exception
+   {
+      GenericBeanFactoryMetaData factory = unmarshalBeanFactory("BeanFactoryWithInstallCallback.xml");
+      assertNull(factory.getName());
+      assertEquals(GenericBeanFactory.class.getName(), factory.getBean());
+      assertEquals("Dummy", factory.getBeanClass());
+      assertNull(factory.getMode());
+      assertNull(factory.getAnnotations());
+      assertNull(factory.getClassLoader());
+      assertNotNull(factory.getConstructor());
+      assertNull(factory.getProperty("constructor"));
+      assertNotNull(factory.getProperties());
+      assertNull(factory.getProperty("properties"));
+      assertNull(factory.getCreate());
+      assertNull(factory.getProperty("create"));
+      assertNull(factory.getStart());
+      assertNull(factory.getProperty("start"));
+      assertNull(factory.getStop());
+      assertNull(factory.getDestroy());
+      assertNull(factory.getDemands());
+      assertNull(factory.getSupplies());
+      assertNull(factory.getInstalls());
+      assertNull(factory.getUninstalls());
+      ArrayList<String> expected = new ArrayList<String>();
+      expected.add("Install1");
+      assertCallbacks(expected, factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
+   }
+
+   public void testBeanFactoryWithInstallCallbacks() throws Exception
+   {
+      GenericBeanFactoryMetaData factory = unmarshalBeanFactory("BeanFactoryWithInstallCallbacks.xml");
+      assertNull(factory.getName());
+      assertEquals(GenericBeanFactory.class.getName(), factory.getBean());
+      assertEquals("Dummy", factory.getBeanClass());
+      assertNull(factory.getMode());
+      assertNull(factory.getAnnotations());
+      assertNull(factory.getClassLoader());
+      assertNotNull(factory.getConstructor());
+      assertNull(factory.getProperty("constructor"));
+      assertNotNull(factory.getProperties());
+      assertNull(factory.getProperty("properties"));
+      assertNull(factory.getCreate());
+      assertNull(factory.getProperty("create"));
+      assertNull(factory.getStart());
+      assertNull(factory.getProperty("start"));
+      assertNull(factory.getStop());
+      assertNull(factory.getDestroy());
+      assertNull(factory.getDemands());
+      assertNull(factory.getSupplies());
+      assertNull(factory.getInstalls());
+      assertNull(factory.getUninstalls());
+      ArrayList<String> expected = new ArrayList<String>();
+      expected.add("Install1");
+      expected.add("Install2");
+      expected.add("Install3");
+      assertCallbacks(expected, factory.getInstallCallbacks());
+      assertNull(factory.getUninstallCallbacks());
+   }
+
+   public void testBeanFactoryWithUninstallCallback() throws Exception
+   {
+      GenericBeanFactoryMetaData factory = unmarshalBeanFactory("BeanFactoryWithUninstallCallback.xml");
+      assertNull(factory.getName());
+      assertEquals(GenericBeanFactory.class.getName(), factory.getBean());
+      assertEquals("Dummy", factory.getBeanClass());
+      assertNull(factory.getMode());
+      assertNull(factory.getAnnotations());
+      assertNull(factory.getClassLoader());
+      assertNotNull(factory.getConstructor());
+      assertNull(factory.getProperty("constructor"));
+      assertNotNull(factory.getProperties());
+      assertNull(factory.getProperty("properties"));
+      assertNull(factory.getCreate());
+      assertNull(factory.getProperty("create"));
+      assertNull(factory.getStart());
+      assertNull(factory.getProperty("start"));
+      assertNull(factory.getStop());
+      assertNull(factory.getDestroy());
+      assertNull(factory.getDemands());
+      assertNull(factory.getSupplies());
+      assertNull(factory.getInstalls());
+      assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      ArrayList<String> expected = new ArrayList<String>();
+      expected.add("Uninstall1");
+      assertCallbacks(expected, factory.getUninstallCallbacks());
+   }
+
+   public void testBeanFactoryWithUninstallCallbacks() throws Exception
+   {
+      GenericBeanFactoryMetaData factory = unmarshalBeanFactory("BeanFactoryWithUninstallCallbacks.xml");
+      assertNull(factory.getName());
+      assertEquals(GenericBeanFactory.class.getName(), factory.getBean());
+      assertEquals("Dummy", factory.getBeanClass());
+      assertNull(factory.getMode());
+      assertNull(factory.getAnnotations());
+      assertNull(factory.getClassLoader());
+      assertNotNull(factory.getConstructor());
+      assertNull(factory.getProperty("constructor"));
+      assertNotNull(factory.getProperties());
+      assertNull(factory.getProperty("properties"));
+      assertNull(factory.getCreate());
+      assertNull(factory.getProperty("create"));
+      assertNull(factory.getStart());
+      assertNull(factory.getProperty("start"));
+      assertNull(factory.getStop());
+      assertNull(factory.getDestroy());
+      assertNull(factory.getDemands());
+      assertNull(factory.getSupplies());
+      assertNull(factory.getInstalls());
+      assertNull(factory.getUninstalls());
+      assertNull(factory.getInstallCallbacks());
+      ArrayList<String> expected = new ArrayList<String>();
+      expected.add("Uninstall1");
+      expected.add("Uninstall2");
+      expected.add("Uninstall3");
+      assertCallbacks(expected, factory.getUninstallCallbacks());
+   }
+
    public void testBeanFactoryBadNoClassOrConstructor() throws Exception
    {
       try

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BeanTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BeanTestCase.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/BeanTestCase.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -25,7 +25,6 @@
 import java.util.HashSet;
 
 import junit.framework.Test;
-
 import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
 import org.jboss.dependency.spi.ControllerMode;
 
@@ -55,6 +54,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithClass() throws Exception
@@ -75,6 +76,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithMode() throws Exception
@@ -95,6 +98,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithAnnotation() throws Exception
@@ -117,6 +122,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithAnnotations() throws Exception
@@ -141,6 +148,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithClassLoader() throws Exception
@@ -161,6 +170,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithConstructor() throws Exception
@@ -181,6 +192,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithProperty() throws Exception
@@ -203,6 +216,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithProperties() throws Exception
@@ -227,6 +242,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithCreate() throws Exception
@@ -247,6 +264,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithStart() throws Exception
@@ -267,6 +286,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithStop() throws Exception
@@ -287,6 +308,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithDestroy() throws Exception
@@ -307,6 +330,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithDependency() throws Exception
@@ -329,6 +354,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithDependencies() throws Exception
@@ -353,6 +380,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithDemand() throws Exception
@@ -375,6 +404,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithDemands() throws Exception
@@ -399,6 +430,8 @@
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithSupply() throws Exception
@@ -421,6 +454,8 @@
       assertSupplies(expected, bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithSupplies() throws Exception
@@ -445,6 +480,8 @@
       assertSupplies(expected, bean.getSupplies());
       assertNull(bean.getInstalls());
       assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
    }
 
    public void testBeanWithInstall() throws Exception
@@ -463,6 +500,8 @@
       assertNull(bean.getDestroy());
       assertNull(bean.getDemands());
       assertNull(bean.getSupplies());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
       ArrayList<String> expected = new ArrayList<String>();
       expected.add("Install1");
       assertInstalls(expected, bean.getInstalls());
@@ -485,6 +524,8 @@
       assertNull(bean.getDestroy());
       assertNull(bean.getDemands());
       assertNull(bean.getSupplies());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
       ArrayList<String> expected = new ArrayList<String>();
       expected.add("Install1");
       expected.add("Install2");
@@ -510,6 +551,8 @@
       assertNull(bean.getDemands());
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
       ArrayList<String> expected = new ArrayList<String>();
       expected.add("Uninstall1");
       assertInstalls(expected, bean.getUninstalls());
@@ -532,6 +575,8 @@
       assertNull(bean.getDemands());
       assertNull(bean.getSupplies());
       assertNull(bean.getInstalls());
+      assertNull(bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
       ArrayList<String> expected = new ArrayList<String>();
       expected.add("Uninstall1");
       expected.add("Uninstall2");
@@ -539,6 +584,106 @@
       assertInstalls(expected, bean.getUninstalls());
    }
 
+   public void testBeanWithInstallCallback() throws Exception
+   {
+      AbstractBeanMetaData bean = unmarshalBean("BeanWithInstallCallback.xml");
+      assertNull(bean.getName());
+      assertEquals("Dummy", bean.getBean());
+      assertNull(bean.getMode());
+      assertNull(bean.getAnnotations());
+      assertNull(bean.getClassLoader());
+      assertNull(bean.getConstructor());
+      assertNull(bean.getProperties());
+      assertNull(bean.getCreate());
+      assertNull(bean.getStart());
+      assertNull(bean.getStop());
+      assertNull(bean.getDestroy());
+      assertNull(bean.getDemands());
+      assertNull(bean.getSupplies());
+      assertNull(bean.getInstalls());
+      assertNull(bean.getUninstalls());
+      ArrayList<String> expected = new ArrayList<String>();
+      expected.add("Install1");
+      assertCallbacks(expected, bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
+   }
+
+   public void testBeanWithInstallCallbacks() throws Exception
+   {
+      AbstractBeanMetaData bean = unmarshalBean("BeanWithInstallCallbacks.xml");
+      assertNull(bean.getName());
+      assertEquals("Dummy", bean.getBean());
+      assertNull(bean.getMode());
+      assertNull(bean.getAnnotations());
+      assertNull(bean.getClassLoader());
+      assertNull(bean.getConstructor());
+      assertNull(bean.getProperties());
+      assertNull(bean.getCreate());
+      assertNull(bean.getStart());
+      assertNull(bean.getStop());
+      assertNull(bean.getDestroy());
+      assertNull(bean.getDemands());
+      assertNull(bean.getSupplies());
+      assertNull(bean.getInstalls());
+      assertNull(bean.getUninstalls());
+      ArrayList<String> expected = new ArrayList<String>();
+      expected.add("Install1");
+      expected.add("Install2");
+      expected.add("Install3");
+      assertCallbacks(expected, bean.getInstallCallbacks());
+      assertNull(bean.getUninstallCallbacks());
+   }
+
+   public void testBeanWithUninstallCallback() throws Exception
+   {
+      AbstractBeanMetaData bean = unmarshalBean("BeanWithUninstallCallback.xml");
+      assertNull(bean.getName());
+      assertEquals("Dummy", bean.getBean());
+      assertNull(bean.getMode());
+      assertNull(bean.getAnnotations());
+      assertNull(bean.getClassLoader());
+      assertNull(bean.getConstructor());
+      assertNull(bean.getProperties());
+      assertNull(bean.getCreate());
+      assertNull(bean.getStart());
+      assertNull(bean.getStop());
+      assertNull(bean.getDestroy());
+      assertNull(bean.getDemands());
+      assertNull(bean.getSupplies());
+      assertNull(bean.getInstalls());
+      assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      ArrayList<String> expected = new ArrayList<String>();
+      expected.add("Uninstall1");
+      assertCallbacks(expected, bean.getUninstallCallbacks());
+   }
+
+   public void testBeanWithUninstallCallbacks() throws Exception
+   {
+      AbstractBeanMetaData bean = unmarshalBean("BeanWithUninstallCallbacks.xml");
+      assertNull(bean.getName());
+      assertEquals("Dummy", bean.getBean());
+      assertNull(bean.getMode());
+      assertNull(bean.getAnnotations());
+      assertNull(bean.getClassLoader());
+      assertNull(bean.getConstructor());
+      assertNull(bean.getProperties());
+      assertNull(bean.getCreate());
+      assertNull(bean.getStart());
+      assertNull(bean.getStop());
+      assertNull(bean.getDestroy());
+      assertNull(bean.getDemands());
+      assertNull(bean.getSupplies());
+      assertNull(bean.getInstalls());
+      assertNull(bean.getUninstalls());
+      assertNull(bean.getInstallCallbacks());
+      ArrayList<String> expected = new ArrayList<String>();
+      expected.add("Uninstall1");
+      expected.add("Uninstall2");
+      expected.add("Uninstall3");
+      assertCallbacks(expected, bean.getUninstallCallbacks());
+   }
+
    public void testBeanBadNoClassOrConstructor() throws Exception
    {
       try

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/CallbackTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/CallbackTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/CallbackTestCase.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,254 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.deployment.xml.test;
+
+import java.util.HashSet;
+import java.util.List;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.spi.CallbackMetaData;
+import org.jboss.dependency.spi.Cardinality;
+import org.jboss.dependency.spi.ControllerState;
+
+/**
+ * CallbackTestCase.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class CallbackTestCase extends AbstractXMLTest
+{
+   public CallbackTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(CallbackTestCase.class);
+   }
+
+   protected CallbackMetaData getInstallCallback(String name) throws Exception
+   {
+      AbstractBeanMetaData bean = unmarshalBean(name);
+      List<CallbackMetaData> callbacks = bean.getInstallCallbacks();
+      assertNotNull(callbacks);
+      assertEquals(1, callbacks.size());
+      CallbackMetaData callback = callbacks.get(0);
+      assertNotNull(callback);
+      return callback;
+   }
+
+   protected CallbackMetaData getUninstallCallback(String name) throws Exception
+   {
+      AbstractBeanMetaData bean = unmarshalBean(name);
+      List<CallbackMetaData> callbacks = bean.getUninstallCallbacks();
+      assertNotNull(callbacks);
+      assertEquals(1, callbacks.size());
+      CallbackMetaData callback = callbacks.get(0);
+      assertNotNull(callback);
+      return callback;
+   }
+
+   public void testInstallWithProperty() throws Exception
+   {
+      CallbackMetaData install = getInstallCallback("CallbackInstallWithProperty.xml");
+      assertEquals("someProperty", install.getProperty());
+      assertEquals(ControllerState.INSTALLED, install.getDependentState());
+      assertNull(install.getAnnotations());
+      assertNull(install.getParameters());
+   }
+
+   public void testInstallWithMethod() throws Exception
+   {
+      CallbackMetaData install = getInstallCallback("CallbackInstallWithMethod.xml");
+      assertNull(install.getProperty());
+      assertEquals(ControllerState.INSTALLED, install.getDependentState());
+      assertEquals("someMethod", install.getMethodName());
+      assertNull(install.getAnnotations());
+      assertNull(install.getParameters());
+   }
+
+   public void testInstallWithState() throws Exception
+   {
+      CallbackMetaData install = getInstallCallback("CallbackInstallWithState.xml");
+      assertNull(install.getProperty());
+      assertEquals(ControllerState.CONFIGURED, install.getDependentState());
+      assertEquals("Dummy", install.getMethodName());
+      assertNull(install.getAnnotations());
+      assertNull(install.getParameters());
+   }
+
+   public void testInstallWithAnnotation() throws Exception
+   {
+      CallbackMetaData install = getInstallCallback("CallbackInstallWithAnnotation.xml");
+      assertNull(install.getProperty());
+      assertEquals(ControllerState.INSTALLED, install.getDependentState());
+      assertEquals("Dummy", install.getMethodName());
+      HashSet<String> expected = new HashSet<String>();
+      expected.add("org.jboss.test.kernel.deployment.xml.support.Annotation1");
+      assertAnnotations(expected, install.getAnnotations());
+      assertNull(install.getParameters());
+   }
+
+   public void testInstallWithAnnotations() throws Exception
+   {
+      CallbackMetaData install = getInstallCallback("CallbackInstallWithAnnotations.xml");
+      assertNull(install.getProperty());
+      assertEquals(ControllerState.INSTALLED, install.getDependentState());
+      assertEquals("Dummy", install.getMethodName());
+      HashSet<String> expected = new HashSet<String>();
+      expected.add("org.jboss.test.kernel.deployment.xml.support.Annotation1");
+      expected.add("org.jboss.test.kernel.deployment.xml.support.Annotation2");
+      expected.add("org.jboss.test.kernel.deployment.xml.support.Annotation3");
+      assertAnnotations(expected, install.getAnnotations());
+      assertNull(install.getParameters());
+   }
+
+   public void testInstallWithSignature() throws Exception
+   {
+      CallbackMetaData install = getInstallCallback("CallbackInstallWithSignature.xml");
+      assertNull(install.getProperty());
+      assertEquals(ControllerState.INSTALLED, install.getDependentState());
+      assertEquals("Dummy", install.getMethodName());
+      assertNull(install.getAnnotations());
+      assertNotNull(install.getSignature());
+      assertEquals("someSignature", install.getSignature());
+   }
+
+   public void testInstallWithCardinality() throws Exception
+   {
+      CallbackMetaData install = getInstallCallback("CallbackInstallWithCardinality.xml");
+      assertNull(install.getProperty());
+      assertEquals(ControllerState.INSTALLED, install.getDependentState());
+      assertEquals("Dummy", install.getMethodName());
+      assertNull(install.getAnnotations());
+      assertNotNull(install.getCardinality());
+      assertEquals(install.getCardinality(), Cardinality.ONE_TO_MANY);
+   }
+
+   public void testInstallBothMethodProperty() throws Exception
+   {
+      try
+      {
+         unmarshalBean("CallbackInstallBadMethodProperty.xml");
+         fail("Should not be here");
+      }
+      catch (Exception expected)
+      {
+         checkJBossXBException(IllegalArgumentException.class, expected);
+      }
+   }
+
+   // --- Uninstall
+
+   public void testUninstallWithProperty() throws Exception
+   {
+      CallbackMetaData install = getUninstallCallback("CallbackUninstallWithProperty.xml");
+      assertEquals("someProperty", install.getProperty());
+      assertEquals(ControllerState.INSTALLED, install.getDependentState());
+      assertNull(install.getAnnotations());
+      assertNull(install.getParameters());
+   }
+
+   public void testUninstallWithMethod() throws Exception
+   {
+      CallbackMetaData install = getUninstallCallback("CallbackUninstallWithMethod.xml");
+      assertNull(install.getProperty());
+      assertEquals(ControllerState.INSTALLED, install.getDependentState());
+      assertEquals("someMethod", install.getMethodName());
+      assertNull(install.getAnnotations());
+      assertNull(install.getParameters());
+   }
+
+   public void testUninstallWithState() throws Exception
+   {
+      CallbackMetaData install = getUninstallCallback("CallbackUninstallWithState.xml");
+      assertNull(install.getProperty());
+      assertEquals(ControllerState.CONFIGURED, install.getDependentState());
+      assertEquals("Dummy", install.getMethodName());
+      assertNull(install.getAnnotations());
+      assertNull(install.getParameters());
+   }
+
+   public void testUninstallWithAnnotation() throws Exception
+   {
+      CallbackMetaData install = getUninstallCallback("CallbackUninstallWithAnnotation.xml");
+      assertNull(install.getProperty());
+      assertEquals(ControllerState.INSTALLED, install.getDependentState());
+      assertEquals("Dummy", install.getMethodName());
+      HashSet<String> expected = new HashSet<String>();
+      expected.add("org.jboss.test.kernel.deployment.xml.support.Annotation1");
+      assertAnnotations(expected, install.getAnnotations());
+      assertNull(install.getParameters());
+   }
+
+   public void testUninstallWithAnnotations() throws Exception
+   {
+      CallbackMetaData install = getUninstallCallback("CallbackUninstallWithAnnotations.xml");
+      assertNull(install.getProperty());
+      assertEquals(ControllerState.INSTALLED, install.getDependentState());
+      assertEquals("Dummy", install.getMethodName());
+      HashSet<String> expected = new HashSet<String>();
+      expected.add("org.jboss.test.kernel.deployment.xml.support.Annotation1");
+      expected.add("org.jboss.test.kernel.deployment.xml.support.Annotation2");
+      expected.add("org.jboss.test.kernel.deployment.xml.support.Annotation3");
+      assertAnnotations(expected, install.getAnnotations());
+      assertNull(install.getParameters());
+   }
+
+   public void testUninstallWithSignature() throws Exception
+   {
+      CallbackMetaData install = getUninstallCallback("CallbackUninstallWithSignature.xml");
+      assertNull(install.getProperty());
+      assertEquals(ControllerState.INSTALLED, install.getDependentState());
+      assertEquals("Dummy", install.getMethodName());
+      assertNull(install.getAnnotations());
+      assertNotNull(install.getSignature());
+      assertEquals("someSignature", install.getSignature());
+   }
+
+   public void testUninstallWithCardinality() throws Exception
+   {
+      CallbackMetaData install = getUninstallCallback("CallbackUninstallWithCardinality.xml");
+      assertNull(install.getProperty());
+      assertEquals(ControllerState.INSTALLED, install.getDependentState());
+      assertEquals("Dummy", install.getMethodName());
+      assertNull(install.getAnnotations());
+      assertNotNull(install.getCardinality());
+      assertEquals(install.getCardinality(), Cardinality.fromString("2..10"));
+   }
+
+   public void testUninstallBothMethodProperty() throws Exception
+   {
+      try
+      {
+         unmarshalBean("CallbackUninstallBadMethodProperty.xml");
+         fail("Should not be here");
+      }
+      catch (Exception expected)
+      {
+         checkJBossXBException(IllegalArgumentException.class, expected);
+      }
+   }
+
+}

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/XMLTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/XMLTestSuite.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/xml/test/XMLTestSuite.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -67,6 +67,7 @@
       suite.addTest(BindingTestCase.suite());
       suite.addTest(PolicyTestCase.suite());
       suite.addTest(AliasTestCase.suite());
+      suite.addTest(CallbackTestCase.suite());
 
       return suite;
    }

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/CallbackTestObject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/CallbackTestObject.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/support/CallbackTestObject.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.inject.support;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class CallbackTestObject
+{
+   private Set<TesterInterface> testerInterfaces;
+
+   protected void init()
+   {
+      if (testerInterfaces == null)
+      {
+         testerInterfaces = new HashSet<TesterInterface>();
+      }
+   }
+
+   public void addTesterInterface(TesterInterface tester)
+   {
+      init();
+      testerInterfaces.add(tester);
+   }
+
+   public void removeTesterInterface(TesterInterface tester)
+   {
+      init();
+      testerInterfaces.remove(tester);
+      if (testerInterfaces.isEmpty())
+         testerInterfaces = null;
+   }
+
+   public Set<TesterInterface> getTesterInterfaces()
+   {
+      return testerInterfaces;
+   }
+
+   public void setTesterInterfaces(Set<TesterInterface> testerInterfaces)
+   {
+      this.testerInterfaces = testerInterfaces;
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/AdditionCallbackTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/AdditionCallbackTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/AdditionCallbackTestCase.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.inject.test;
+
+import junit.framework.Test;
+import org.jboss.test.kernel.inject.support.CallbackTestObject;
+
+/**
+ * Callback tests.
+ *
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class AdditionCallbackTestCase extends SimpleCallbackTestCase
+{
+   public AdditionCallbackTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(AdditionCallbackTestCase.class);
+   }
+
+   protected void afterInstall(CallbackTestObject testObject)
+   {
+      assertNull(testObject.getTesterInterfaces());
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CardinalityCallbackTestCase.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,81 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.inject.test;
+
+import junit.framework.Test;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.test.kernel.inject.support.CallbackTestObject;
+import org.jboss.test.kernel.junit.ManualMicrocontainerTest;
+
+/**
+ * Cardinality tests.
+ *
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class CardinalityCallbackTestCase extends ManualMicrocontainerTest
+{
+   public CardinalityCallbackTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(CardinalityCallbackTestCase.class);
+   }
+
+   public void testCallback() throws Throwable
+   {
+      KernelControllerContext context = getControllerContext("testObject", ControllerState.NOT_INSTALLED);
+      assertNull(context.getTarget());
+      assertEquals(context.getState(), ControllerState.NOT_INSTALLED);
+
+      change(context, ControllerState.CREATE);
+      CallbackTestObject injectee = (CallbackTestObject)context.getTarget();
+      assertNotNull(injectee);
+      assertNull(injectee.getTesterInterfaces());
+
+      KernelControllerContext tester1 = getControllerContext("tester1", ControllerState.NOT_INSTALLED);
+      assertNotNull(tester1);
+      change(tester1, ControllerState.INSTALLED);
+
+      assertNull(injectee.getTesterInterfaces());
+
+      KernelControllerContext tester2 = getControllerContext("tester2", ControllerState.NOT_INSTALLED);
+      assertNotNull(tester2);
+      change(tester2, ControllerState.INSTALLED);
+
+      change(context, ControllerState.INSTALLED);
+
+      assertNotNull(injectee.getTesterInterfaces());
+      assertEquals(2, injectee.getTesterInterfaces().size());
+
+      KernelControllerContext tester3 = getControllerContext("tester3", ControllerState.NOT_INSTALLED);
+      assertNotNull(tester3);
+      change(tester3, ControllerState.INSTALLED);
+
+      assertNotNull(injectee.getTesterInterfaces());
+      assertEquals(3, injectee.getTesterInterfaces().size());
+   }
+
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CollectionCallbackTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CollectionCallbackTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CollectionCallbackTestCase.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,48 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.inject.test;
+
+import junit.framework.Test;
+import org.jboss.test.kernel.inject.support.CallbackTestObject;
+
+/**
+ * Callback tests.
+ *
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class CollectionCallbackTestCase extends SimpleCallbackTestCase
+{
+   public CollectionCallbackTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(CollectionCallbackTestCase.class);
+   }
+
+   protected void afterInstall(CallbackTestObject testObject)
+   {
+      assertTrue(testObject.getTesterInterfaces().isEmpty());
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ConstructorContextualInjectionTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ConstructorContextualInjectionTestCase.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ConstructorContextualInjectionTestCase.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -21,15 +21,16 @@
 */
 package org.jboss.test.kernel.inject.test;
 
+import junit.framework.Test;
 import org.jboss.test.kernel.inject.support.ConstructorInjectTestObject;
 import org.jboss.test.kernel.inject.support.ConstructorValueBean;
 
-import junit.framework.Test;
-
 /**
+ * Constructor injection.
+ *
  * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
  */
-public class ConstructorContextualInjectionTestCase extends ContextualInjectionAdapter
+public class ConstructorContextualInjectionTestCase extends SingleContextualInjectionAdapter
 {
    public ConstructorContextualInjectionTestCase(String name)
    {

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionAdapter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionAdapter.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionAdapter.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -25,36 +25,41 @@
 import org.jboss.test.kernel.junit.MicrocontainerTest;
 
 /**
+ * Test unit deployment contextual injection helper class.
+ * 
  * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
  */
 public abstract class ContextualInjectionAdapter extends MicrocontainerTest
 {
-
    public ContextualInjectionAdapter(String name)
    {
       super(name);
    }
 
-   protected abstract String getResource();
-
-   protected abstract void checkInjection();
-
    protected void enableTrace()
    {
    }
 
-   public void testInjection() throws Throwable
+   protected void execute(TestUnit testUnit) throws Throwable
    {
       enableTrace();
-      KernelDeployment deployment = deploy(getResource());
+      KernelDeployment deployment = deploy(testUnit.getResource());
       try
       {
          validate();
-         checkInjection();
+         testUnit.executeTest();
       }
       finally
       {
          undeploy(deployment);
       }
    }
+
+   protected interface TestUnit
+   {
+      String getResource();
+
+      void executeTest() throws Throwable;
+   }
+
 }

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/ContextualInjectionTestSuite.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -21,8 +21,8 @@
 */
 package org.jboss.test.kernel.inject.test;
 
+import junit.framework.Test;
 import junit.framework.TestSuite;
-import junit.framework.Test;
 import junit.textui.TestRunner;
 
 /**
@@ -44,6 +44,11 @@
       suite.addTest(ConstructorContextualInjectionTestCase.suite());
       suite.addTest(LifecycleContextualInjectionTestCase.suite());
       suite.addTest(PropertyContextualInjectionTestCase.suite());
+      suite.addTest(MultipleContextualInjectionTestCase.suite());
+      suite.addTest(InjectionValueCallbackTestCase.suite());
+      suite.addTest(AdditionCallbackTestCase.suite());
+      suite.addTest(CollectionCallbackTestCase.suite());
+      suite.addTest(CardinalityCallbackTestCase.suite());
 
       return suite;
    }

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/InjectionValueCallbackTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/InjectionValueCallbackTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/InjectionValueCallbackTestCase.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,65 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.inject.test;
+
+import junit.framework.Test;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.test.kernel.inject.support.PropertyInjectTestObject;
+import org.jboss.test.kernel.junit.ManualMicrocontainerTest;
+
+/**
+ * Callback tests.
+ *
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class InjectionValueCallbackTestCase extends ManualMicrocontainerTest
+{
+   public InjectionValueCallbackTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(InjectionValueCallbackTestCase.class);
+   }
+
+   public void testInjectionValueMetaData() throws Throwable
+   {
+      KernelControllerContext context = getControllerContext("testObject", ControllerState.NOT_INSTALLED);
+      assertNull(context.getTarget());
+      assertEquals(context.getState(), ControllerState.NOT_INSTALLED);
+      
+      change(context, ControllerState.INSTALLED);
+      PropertyInjectTestObject injectee = (PropertyInjectTestObject)context.getTarget();
+      assertNotNull(injectee);
+      assertNull(injectee.getTesterInterface());
+
+      KernelControllerContext tester = getControllerContext("tester", ControllerState.NOT_INSTALLED);
+      assertNotNull(tester);
+      change(tester, ControllerState.INSTALLED);
+
+      assertNotNull(injectee.getTesterInterface());
+   }
+
+}

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/LifecycleContextualInjectionTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/LifecycleContextualInjectionTestCase.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/LifecycleContextualInjectionTestCase.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -25,9 +25,11 @@
 import org.jboss.test.kernel.inject.support.LifecycleInjectTestObject;
 
 /**
+ * Lifecycle method injection.
+ *
  * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
  */
-public class LifecycleContextualInjectionTestCase extends ContextualInjectionAdapter
+public class LifecycleContextualInjectionTestCase extends SingleContextualInjectionAdapter
 {
    public LifecycleContextualInjectionTestCase(String name)
    {

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/MultipleContextualInjectionTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/MultipleContextualInjectionTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/MultipleContextualInjectionTestCase.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,71 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.inject.test;
+
+import junit.framework.Test;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.test.kernel.inject.support.PropertyInjectTestObject;
+
+/**
+ * Multiple injection - should 'fail'.
+ * 
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public class MultipleContextualInjectionTestCase extends SingleContextualInjectionAdapter
+{
+   public MultipleContextualInjectionTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(MultipleContextualInjectionTestCase.class);
+   }
+
+   protected String getResource()
+   {
+      return "MultipleContextualInjection.xml";
+   }
+
+   protected void checkInjection()
+   {
+      PropertyInjectTestObject test = (PropertyInjectTestObject) getBean("testObject", ControllerState.DESCRIBED);
+      assertNull(test);
+   }
+
+   protected void validate() throws Exception
+   {
+      try
+      {
+         super.validate();
+         fail("Should not be here!");
+      }
+      catch (IllegalStateException e)
+      {
+         if (e.getMessage().startsWith("Incompletely"))
+            getLog().debug("Got expected Incomplete deployment exception: " + e);
+         else
+            throw e;
+      }
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/PropertyContextualInjectionTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/PropertyContextualInjectionTestCase.java	2007-04-21 13:28:50 UTC (rev 62473)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/PropertyContextualInjectionTestCase.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -25,9 +25,11 @@
 import org.jboss.test.kernel.inject.support.PropertyInjectTestObject;
 
 /**
+ * Property injection.
+ * 
  * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
  */
-public class PropertyContextualInjectionTestCase extends ContextualInjectionAdapter
+public class PropertyContextualInjectionTestCase extends SingleContextualInjectionAdapter
 {
    public PropertyContextualInjectionTestCase(String name)
    {

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/SimpleCallbackTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/SimpleCallbackTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/SimpleCallbackTestCase.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,88 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.inject.test;
+
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.test.kernel.inject.support.CallbackTestObject;
+import org.jboss.test.kernel.junit.ManualMicrocontainerTest;
+
+/**
+ * Callback tests.
+ *
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public abstract class SimpleCallbackTestCase extends ManualMicrocontainerTest
+{
+   public SimpleCallbackTestCase(String name)
+   {
+      super(name);
+   }
+
+   public void testCallback() throws Throwable
+   {
+      KernelControllerContext context = getControllerContext("testObject", ControllerState.NOT_INSTALLED);
+      assertNull(context.getTarget());
+      assertEquals(context.getState(), ControllerState.NOT_INSTALLED);
+
+      change(context, ControllerState.INSTALLED);
+      CallbackTestObject injectee = (CallbackTestObject)context.getTarget();
+      assertNotNull(injectee);
+      afterInstall(injectee);
+
+      // install
+
+      KernelControllerContext tester1 = getControllerContext("tester1", ControllerState.NOT_INSTALLED);
+      assertNotNull(tester1);
+      change(tester1, ControllerState.INSTALLED);
+      assertNotNull(injectee.getTesterInterfaces());
+      assertEquals(1, injectee.getTesterInterfaces().size());
+
+      KernelControllerContext tester2 = getControllerContext("tester2", ControllerState.NOT_INSTALLED);
+      assertNotNull(tester2);
+      change(tester2, ControllerState.INSTALLED);
+      assertNotNull(injectee.getTesterInterfaces());
+      assertEquals(2, injectee.getTesterInterfaces().size());
+
+      KernelControllerContext tester3 = getControllerContext("tester3", ControllerState.NOT_INSTALLED);
+      assertNotNull(tester3);
+      change(tester3, ControllerState.INSTALLED);
+      assertNotNull(injectee.getTesterInterfaces());
+      assertEquals(3, injectee.getTesterInterfaces().size());
+
+      //uninstall
+
+      change(tester3, ControllerState.NOT_INSTALLED);
+      assertNotNull(injectee.getTesterInterfaces());
+      assertEquals(2, injectee.getTesterInterfaces().size());
+
+      change(tester2, ControllerState.NOT_INSTALLED);
+      assertNotNull(injectee.getTesterInterfaces());
+      assertEquals(1, injectee.getTesterInterfaces().size());
+
+      change(tester1, ControllerState.NOT_INSTALLED);
+      afterInstall(injectee);
+   }
+
+   protected abstract void afterInstall(CallbackTestObject testObject);
+
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/SingleContextualInjectionAdapter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/SingleContextualInjectionAdapter.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/SingleContextualInjectionAdapter.java	2007-04-21 21:20:20 UTC (rev 62474)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.kernel.inject.test;
+
+/**
+ * Single contextual injection unit test.
+ *
+ * @author <a href="mailto:ales.justin at gmail.com">Ales Justin</a>
+ */
+public abstract class SingleContextualInjectionAdapter extends ContextualInjectionAdapter
+{
+   public SingleContextualInjectionAdapter(String name)
+   {
+      super(name);
+   }
+
+   protected abstract String getResource();
+
+   protected abstract void checkInjection();
+
+   public void testInjection() throws Throwable
+   {
+      execute(new SingleTestUnit());
+   }
+
+   private class SingleTestUnit implements TestUnit
+   {
+      public String getResource()
+      {
+         return SingleContextualInjectionAdapter.this.getResource();
+      }
+
+      public void executeTest() throws Throwable
+      {
+         checkInjection();
+      }
+   }
+}




More information about the jboss-cvs-commits mailing list