[jboss-cvs] JBossAS SVN: r72020 - in projects/microcontainer/trunk/kernel/src: main/org/jboss/kernel/plugins/annotations and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Apr 11 09:24:44 EDT 2008


Author: alesj
Date: 2008-04-11 09:24:44 -0400 (Fri, 11 Apr 2008)
New Revision: 72020

Added:
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractMetaDataAnnotationAdapter.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AliasMetaDataAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BaseMetaDataAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanMetaDataAnnotationAdapter.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CommonAnnotationAdapter.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MetaDataAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/annotations/
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/annotations/AnnotationToBeanMetaDataFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/annotations/BeanMetaDataAnnotationAdapter.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/AliasesImpl.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/AllIoCAnnotations.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SimpleBeanMetaDataAnnotationAdapter.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/factory/
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/factory/AnnotationFactoryTestSuite.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/factory/AnnotationToBeanMetaDataFactoryTestCase.java
Modified:
   projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/NestedBeanHandler.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractBeanAnnotationAdapter.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AliasesAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BeanAnnotationAdapterFactory.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassFactoryAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorValueAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DependsAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ExternalInstallAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ExternalInstallationAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ExternalUninstallAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectFieldAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallFieldCallbackAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallMethodParameterAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/LifecycleParameterAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodInstallCallbackAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodUninstallCallbackAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyInstallCallbackAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyUninstallCallbackAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallFieldCallbackAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallMethodParameterAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ValueFactoryFieldAnnotationPlugin.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/AnonymousBeansTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CollectionAnnotationCallbackTestCase.java
Log:
NestedBeansHandler generated name fix.
Refactoring of MC IoC annotation handling - plain bean metadata usage vs. controller context usage.

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/NestedBeanHandler.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/NestedBeanHandler.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/plugins/NestedBeanHandler.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -44,7 +44,7 @@
    private static Logger log = Logger.getLogger(NestedBeanHandler.class);
 
    protected BeanMetaData root;
-   protected int counter = 1;
+   protected int counter;
 
    public NestedBeanHandler(BeanMetaData root)
    {
@@ -156,17 +156,19 @@
     */
    protected String generateName(MetaDataVisitorNode previous)
    {
+      ++counter;
       String name;
+
       if (previous instanceof PropertyMetaData)
       {
          PropertyMetaData pmd = (PropertyMetaData)previous;
-         name = root.getName() + "$" + pmd.getName();
+         name = root.getName() + "$" + pmd.getName() + "#" + counter;
       }
       else
       {
          name = root.getName() + "#" + counter;
-         counter++;
       }
+      
       return name;
    }
 

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -22,24 +22,15 @@
 package org.jboss.kernel.plugins.annotations;
 
 import java.lang.annotation.Annotation;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Target;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
-import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.MetaDataVisitor;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
-import org.jboss.beans.metadata.api.annotations.Cleanup;
-import org.jboss.beans.metadata.api.annotations.CleanupOnly;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.metadata.spi.MetaData;
 import org.jboss.reflect.spi.AnnotatedInfo;
-import org.jboss.util.JBossObject;
-import org.jboss.util.JBossStringBuilder;
 
 /**
  * Abstract annotation plugin.
@@ -48,78 +39,14 @@
  * @param <C> annotation type
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public abstract class AbstractAnnotationPlugin<T extends AnnotatedInfo, C extends Annotation> extends JBossObject implements AnnotationPlugin<T, C>
+public abstract class AbstractAnnotationPlugin<T extends AnnotatedInfo, C extends Annotation> extends BaseMetaDataAnnotationPlugin<T, C> implements AnnotationPlugin<T, C>
 {
-   private Class<C> annotation;
-   private Set<ElementType> types;
-   private boolean isCleanup;
-   private boolean isCleanupOnly;
-
    protected AbstractAnnotationPlugin(Class<C> annotation)
    {
-      if (annotation == null)
-         throw new IllegalArgumentException("Null annotation!");
-      this.annotation = annotation;
-      this.types = new HashSet<ElementType>();
-      Target target = annotation.getAnnotation(Target.class);
-      if (target != null)
-      {
-         List<ElementType> list = Arrays.asList(target.value());
-         for(ElementType type : list)
-         {
-            if (isElementTypeSupported(type))
-            {
-               types.add(type);
-            }
-         }
-      }
-      isCleanupOnly = annotation.isAnnotationPresent(CleanupOnly.class);
-      isCleanup = isCleanupOnly || annotation.isAnnotationPresent(Cleanup.class);
+      super(annotation);
    }
 
    /**
-    * Does attribute have value.
-    * Helper method.
-    *
-    * @param value the value
-    * @return true if atribute not null or non-empty
-    */
-   protected static boolean isAttributePresent(String value)
-   {
-      return ValueUtil.isAttributePresent(value);
-   }
-
-   /**
-    * Does attribute have value.
-    * Helper method.
-    *
-    * @param value the value
-    * @return true if atribute not void.class
-    */
-   protected static boolean isAttributePresent(Class<?> value)
-   {
-      return ValueUtil.isAttributePresent(value);
-   }
-
-   /**
-    * Is type supported by plugin.
-    *
-    * @param type the annotation element type
-    * @return true if element supported
-    */
-   protected abstract boolean isElementTypeSupported(ElementType type);
-
-   public Set<ElementType> getSupportedTypes()
-   {
-      return Collections.unmodifiableSet(types);
-   }
-
-   public Class<C> getAnnotation()
-   {
-      return annotation;
-   }
-
-   /**
     * Is meta data already present.
     *
     * @param info the info
@@ -133,19 +60,6 @@
    }
 
    /**
-    * Is meta data already present.
-    *
-    * @param info the info
-    * @param annotation the annotation
-    * @param beanMetaData the bean meta data
-    * @return true if meta data already present
-    */
-   protected boolean isMetaDataAlreadyPresent(T info, C annotation, BeanMetaData beanMetaData)
-   {
-      return false;
-   }
-
-   /**
     * Apply annotation since it's not present.
     *
     * @param info the info
@@ -157,31 +71,26 @@
     */
    protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(T info, MetaData retrieval, C annotation, KernelControllerContext context) throws Throwable
    {
-      return internalApplyAnnotation(info, annotation, context);
+      return internalApplyAnnotation(info, retrieval, annotation, context.getBeanMetaData());
    }
 
    /**
     * Apply annotation since it's not present.
     *
     * @param info the info
+    * @param retrieval the metadata
     * @param annotation the annotation
-    * @param context the context
+    * @param beanMetaData the bean metadata
     * @return list of added meta data visitor nodes
     * @throws Throwable for any error
     */
-   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(T info, C annotation, KernelControllerContext context) throws Throwable
+   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(T info, MetaData retrieval, C annotation, BeanMetaData beanMetaData) throws Throwable
    {
-      return internalApplyAnnotation(info, annotation, context.getBeanMetaData());
+      return internalApplyAnnotation(info, annotation, beanMetaData);
    }
 
    /**
-    * Apply annotation since it's not present.
-    *
-    * @param info the info
-    * @param annotation the annotation
-    * @param beanMetaData the bean meta data
-    * @return list of added meta data visitor nodes
-    * @throws Throwable for any error
+    * Covariant override. 
     */
    protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(T info, C annotation, BeanMetaData beanMetaData) throws Throwable
    {
@@ -193,7 +102,7 @@
    {
       boolean trace = log.isTraceEnabled();
       
-      if (isCleanupOnly == false)
+      if (isCleanupOnly() == false)
       {
          Class<C> annotationClass = getAnnotation();
          C annotation = retrieval.getAnnotation(annotationClass);
@@ -222,14 +131,14 @@
          }
       }
       else if (trace)
-         log.trace("Annotation " + annotation + " is @CleanupOnly, nothing to apply on install.");
+         log.trace("Annotation " + getAnnotation() + " is @CleanupOnly, nothing to apply on install.");
    }
 
    public void cleanAnnotation(T info, MetaData retrieval, MetaDataVisitor visitor) throws Throwable
    {
       boolean trace = log.isTraceEnabled();
 
-      if (isCleanup)
+      if (isCleanup())
       {
          Class<C> annotationClass = getAnnotation();
          C annotation = retrieval.getAnnotation(annotationClass);
@@ -246,7 +155,7 @@
          }
       }
       else if (trace)
-         log.trace("Annotation " + annotation + " is not a @Cleanup annotation.");
+         log.trace("Annotation " + getAnnotation() + " is not a @Cleanup annotation.");
    }
 
    /**
@@ -263,16 +172,17 @@
       // empty      
    }
 
-   protected void toString(JBossStringBuilder buffer)
+   /**
+    * Check if we require impl detail on BeanMetaData.
+    *
+    * @param beanMetaData the bean metadata
+    * @return abstract bean metadata instance
+    */
+   protected AbstractBeanMetaData checkIfNotAbstractBeanMetaDataSpecific(BeanMetaData beanMetaData)
    {
-      buffer.append("@annotation=").append(annotation);
-      buffer.append(" ,types=").append(types);
-      buffer.append(" ,cleanup=").append(isCleanup);
-      buffer.append(" ,cleanupOnly=").append(isCleanupOnly);
-   }
+      if (beanMetaData instanceof AbstractBeanMetaData == false)
+         throw new IllegalArgumentException("Can only handle AbstractBeanMetaData: " + beanMetaData);
 
-   public void toShortString(JBossStringBuilder buffer)
-   {
-      buffer.append("@annotation=").append(annotation);
+      return AbstractBeanMetaData.class.cast(beanMetaData);
    }
 }
\ No newline at end of file

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractBeanAnnotationAdapter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractBeanAnnotationAdapter.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractBeanAnnotationAdapter.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -21,129 +21,21 @@
 */
 package org.jboss.kernel.plugins.annotations;
 
-import java.lang.annotation.Annotation;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import java.util.HashSet;
-import java.util.Set;
-
 import org.jboss.beans.info.spi.BeanInfo;
-import org.jboss.beans.info.spi.PropertyInfo;
 import org.jboss.beans.metadata.spi.MetaDataVisitor;
 import org.jboss.kernel.Kernel;
-import org.jboss.kernel.plugins.config.Configurator;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
-import org.jboss.logging.Logger;
 import org.jboss.metadata.spi.MetaData;
-import org.jboss.metadata.spi.signature.ConstructorSignature;
-import org.jboss.metadata.spi.signature.FieldSignature;
-import org.jboss.metadata.spi.signature.MethodSignature;
-import org.jboss.metadata.spi.signature.Signature;
-import org.jboss.reflect.spi.ClassInfo;
-import org.jboss.reflect.spi.ConstructorInfo;
-import org.jboss.reflect.spi.FieldInfo;
-import org.jboss.reflect.spi.MethodInfo;
+import org.jboss.reflect.spi.AnnotatedInfo;
 
 /**
  * Abstract bean annotation handler.
  *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
- at SuppressWarnings("unchecked")
-public abstract class AbstractBeanAnnotationAdapter implements BeanAnnotationAdapter
+public class AbstractBeanAnnotationAdapter extends CommonAnnotationAdapter<AnnotationPlugin, MetaDataVisitor> implements BeanAnnotationAdapter
 {
-   protected Logger log = Logger.getLogger(AbstractBeanAnnotationAdapter.class);
-
-   protected Set<AnnotationPlugin> classAnnotationPlugins = new HashSet<AnnotationPlugin>();
-   protected Set<AnnotationPlugin> constructorAnnotationPlugins = new HashSet<AnnotationPlugin>();
-   protected Set<AnnotationPlugin> propertyAnnotationPlugins = new HashSet<AnnotationPlugin>();
-   protected Set<AnnotationPlugin> methodAnnotationPlugins = new HashSet<AnnotationPlugin>();
-   protected Set<AnnotationPlugin> fieldAnnotationPlugins = new HashSet<AnnotationPlugin>();
-
-   /**
-    * Add the annotation plugin.
-    * Breaks down the plugin usage into
-    * different ElementType support collections.
-    *
-    * @param plugin the annotation plugin
-    */
-   public void addAnnotationPlugin(AnnotationPlugin plugin)
-   {
-      if (plugin == null)
-         throw new IllegalArgumentException("Null plugin.");
-      
-      Class<? extends Annotation> annotation = plugin.getAnnotation();
-      if (annotation == null)
-         throw new IllegalArgumentException("Null annotation class: " + plugin);
-      
-      if (annotation.getAnnotation(Target.class) == null)
-         log.warn("Annotation " + annotation + " missing @Target annotation!");
-      if (annotation.getAnnotation(Retention.class) == null)
-         log.warn("Annotation " + annotation + " missing @Retention annotation!");
-
-      Set supported = plugin.getSupportedTypes();
-      if (supported == null || supported.isEmpty())
-         throw new IllegalArgumentException("Null or empty support types: " + plugin);
-
-      if (supported.contains(ElementType.TYPE))
-      {
-         classAnnotationPlugins.add(plugin);
-      }
-      if (supported.contains(ElementType.CONSTRUCTOR))
-      {
-         constructorAnnotationPlugins.add(plugin);
-      }
-      if (supported.contains(ElementType.METHOD))
-      {
-         if (plugin instanceof PropertyAware)
-            propertyAnnotationPlugins.add(plugin);
-         else
-            methodAnnotationPlugins.add(plugin);
-      }
-      if (supported.contains(ElementType.FIELD))
-      {
-         fieldAnnotationPlugins.add(plugin);
-      }
-   }
-
-   /**
-    * Remove the plugin.
-    * TODO - test it
-    *
-    * @param plugin the annotation plugin
-    */
-   public void removeAnnotationPlugin(AnnotationPlugin plugin)
-   {
-      if (plugin == null)
-         return;
-
-      Set supported = plugin.getSupportedTypes();
-      if (supported == null || supported.isEmpty())
-         throw new IllegalArgumentException("Null or empty support types: " + plugin);
-
-      if (supported.contains(ElementType.TYPE))
-      {
-         classAnnotationPlugins.remove(plugin);
-      }
-      if (supported.contains(ElementType.CONSTRUCTOR))
-      {
-         constructorAnnotationPlugins.remove(plugin);
-      }
-      if (supported.contains(ElementType.METHOD))
-      {
-         if (plugin instanceof PropertyAware)
-            propertyAnnotationPlugins.remove(plugin);
-         else
-            methodAnnotationPlugins.remove(plugin);
-      }
-      if (supported.contains(ElementType.FIELD))
-      {
-         fieldAnnotationPlugins.remove(plugin);
-      }
-   }
-
    public void applyAnnotations(MetaDataVisitor visitor) throws Throwable
    {
       handleAnnotations(visitor, true);
@@ -170,154 +62,25 @@
       Kernel kernel = context.getKernel();
       KernelMetaDataRepository repository = kernel.getMetaDataRepository();
       MetaData retrieval = repository.getMetaData(context);
-
-      boolean trace = log.isTraceEnabled();
       BeanInfo info = context.getBeanInfo();
-      Object name = context.getName();
-      if (trace)
-         log.trace(name + " apply annotations");
 
-      // class
-      ClassInfo classInfo = info.getClassInfo();
-      for(AnnotationPlugin plugin : classAnnotationPlugins)
-      {
-         if (isApplyPhase)
-            plugin.applyAnnotation(classInfo, retrieval, visitor);
-         else
-            plugin.cleanAnnotation(classInfo, retrieval, visitor);
-      }
+      handleAnnotations(info, retrieval, visitor, isApplyPhase);
+   }
 
-      // constructors
-      Set<ConstructorInfo> constructors = info.getConstructors();
-      if (constructors != null && constructors.isEmpty() == false)
-      {
-         for(ConstructorInfo ci : constructors)
-         {
-            Signature cis = new ConstructorSignature(Configurator.getParameterTypes(trace, ci.getParameterTypes()));
-            MetaData cmdr = retrieval.getComponentMetaData(cis);
-            if (cmdr != null)
-            {
-               for(AnnotationPlugin plugin : constructorAnnotationPlugins)
-               {
-                  if (isApplyPhase)
-                     plugin.applyAnnotation(ci, cmdr, visitor);
-                  else
-                     plugin.cleanAnnotation(ci, cmdr, visitor);
-               }
-            }
-            else if (trace)
-               log.trace("No annotations for " + ci);
-         }
-      }
-      else if (trace)
-         log.trace("No constructors");
+   @SuppressWarnings("unchecked")
+   protected void applyPlugin(AnnotationPlugin plugin, AnnotatedInfo info, MetaData retrieval, MetaDataVisitor handle) throws Throwable
+   {
+      plugin.applyAnnotation(info, retrieval, handle);
+   }
 
-      // properties
-      Set<MethodInfo> visitedMethods = new HashSet<MethodInfo>();
-      Set<PropertyInfo> properties = info.getProperties();
-      if (properties != null && properties.isEmpty() == false)
-      {
-         for(PropertyInfo pi : properties)
-         {
-            MethodInfo setter = pi.getSetter();
-            FieldInfo field = pi.getFieldInfo();
+   @SuppressWarnings("unchecked")
+   protected void cleanPlugin(AnnotationPlugin plugin, AnnotatedInfo info, MetaData retrieval, MetaDataVisitor handle) throws Throwable
+   {
+      plugin.cleanAnnotation(info, retrieval, handle);
+   }
 
-            if (setter != null)
-            {
-               visitedMethods.add(setter);
-               Signature sis = new MethodSignature(setter);
-               MetaData cmdr = retrieval.getComponentMetaData(sis);
-               if (cmdr != null)
-               {
-                  for(AnnotationPlugin plugin : propertyAnnotationPlugins)
-                  {
-                     if (isApplyPhase)
-                        plugin.applyAnnotation(pi, cmdr, visitor);
-                     else
-                        plugin.cleanAnnotation(pi, cmdr, visitor);
-                  }
-               }
-               else if (trace)
-                  log.trace("No annotations for property " + pi.getName());
-            }
-            else if (field != null)
-            {
-               Signature sis = new FieldSignature(field);
-               MetaData cmdr = retrieval.getComponentMetaData(sis);
-               if (cmdr != null)
-               {
-                  for(AnnotationPlugin plugin : fieldAnnotationPlugins)
-                  {
-                     if (isApplyPhase)
-                        plugin.applyAnnotation(field, cmdr, visitor);
-                     else
-                        plugin.cleanAnnotation(field, cmdr, visitor);
-                  }
-               }
-               else if (trace)
-                  log.trace("No annotations for field " + field.getName());
-            }
-         }
-      }
-      else if (trace)
-         log.trace("No properties");
-
-      // methods
-      Set<MethodInfo> methods = info.getMethods();
-      if (methods != null && methods.isEmpty() == false)
-      {
-         for(MethodInfo mi : methods)
-         {
-            if (visitedMethods.contains(mi) == false)
-            {
-               Signature mis = new MethodSignature(mi);
-               MetaData cmdr = retrieval.getComponentMetaData(mis);
-               if (cmdr != null)
-               {
-                  for(AnnotationPlugin plugin : methodAnnotationPlugins)
-                  {
-                     if (isApplyPhase)
-                        plugin.applyAnnotation(mi, cmdr, visitor);
-                     else
-                        plugin.cleanAnnotation(mi, cmdr, visitor);
-                  }
-               }
-               else if (trace)
-                  log.trace("No annotations for " + mi);
-            }
-         }
-      }
-      else if (trace)
-         log.trace("No methods");
-
-      // static methods
-      MethodInfo[] staticMethods = classInfo.getDeclaredMethods();
-      if (staticMethods != null && staticMethods.length != 0)
-      {
-         for(MethodInfo smi : staticMethods)
-         {
-            if (smi.isStatic() && smi.isPublic())
-            {
-               Signature mis = new MethodSignature(smi);
-               MetaData cmdr = retrieval.getComponentMetaData(mis);
-               if (cmdr != null)
-               {
-                  for(AnnotationPlugin plugin : methodAnnotationPlugins)
-                  {
-                     if (isApplyPhase)
-                        plugin.applyAnnotation(smi, cmdr, visitor);
-                     else
-                        plugin.cleanAnnotation(smi, cmdr, visitor);
-                  }
-               }
-               else if (trace)
-                  log.trace("No annotations for " + smi);
-            }
-         }
-      }
-      else if (trace)
-         log.trace("No static methods");
-
-      // fields - if accessible - are already handled with propertys
+   protected Object getName(MetaDataVisitor handle)
+   {
+      return handle.getControllerContext().getName();
    }
 }

Copied: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractMetaDataAnnotationAdapter.java (from rev 71877, projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractBeanAnnotationAdapter.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractMetaDataAnnotationAdapter.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractMetaDataAnnotationAdapter.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -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.kernel.plugins.annotations;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.reflect.spi.AnnotatedInfo;
+import org.jboss.kernel.spi.annotations.BeanMetaDataAnnotationAdapter;
+
+/**
+ * Abstract metadata annotation handler.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AbstractMetaDataAnnotationAdapter extends CommonAnnotationAdapter<MetaDataAnnotationPlugin, BeanMetaData> implements BeanMetaDataAnnotationAdapter
+{
+   public void applyAnnotations(BeanInfo beanInfo, MetaData metaData, BeanMetaData beanMetaData) throws Throwable
+   {
+      handleAnnotations(beanInfo, metaData, beanMetaData, true);
+   }
+
+   @SuppressWarnings("unchecked")
+   protected void applyPlugin(MetaDataAnnotationPlugin plugin, AnnotatedInfo info, MetaData retrieval, BeanMetaData handle) throws Throwable
+   {
+      plugin.applyAnnotation(info, retrieval, handle);
+   }
+
+   protected void cleanPlugin(MetaDataAnnotationPlugin plugin, AnnotatedInfo info, MetaData retrieval, BeanMetaData handle) throws Throwable
+   {
+      throw new UnsupportedOperationException("Cleanup is not supported on metadata annotation adapter.");
+   }
+
+   protected Object getName(BeanMetaData handle)
+   {
+      return handle.getName();
+   }
+}
\ No newline at end of file

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractParameterAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -34,7 +34,6 @@
 import org.jboss.beans.metadata.spi.ParameterMetaData;
 import org.jboss.beans.metadata.spi.ValueMetaData;
 import org.jboss.kernel.plugins.config.Configurator;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.metadata.spi.MetaData;
 import org.jboss.metadata.spi.signature.MethodParametersSignature;
 import org.jboss.metadata.spi.signature.Signature;
@@ -84,19 +83,6 @@
     *
     * @param info the info
     * @param annotation the annotation
-    * @param context the context
-    * @return list of added meta data visitor nodes
-    */
-   protected List<? extends MetaDataVisitorNode> handleParameterlessInfo(T info, C annotation, KernelControllerContext context)
-   {
-      return handleParameterlessInfo(info, annotation, context.getBeanMetaData());
-   }
-
-   /**
-    * Handle info which has zero parameters.
-    *
-    * @param info the info
-    * @param annotation the annotation
     * @param beanMetaData the bean metadata
     * @return list of added meta data visitor nodes
     */
@@ -107,19 +93,6 @@
     *
     * @param info the info
     * @param annotation the annotation
-    * @param context the context
-    * @return new ParameterizedMetaData instance
-    */
-   protected P createParametrizedMetaData(T info, C annotation, KernelControllerContext context)
-   {
-      return createParametrizedMetaData(info, annotation, context.getBeanMetaData());
-   }
-
-   /**
-    * Create new Parametrized metadata.
-    *
-    * @param info the info
-    * @param annotation the annotation
     * @param beanMetaData the bean metadata
     * @return new ParameterizedMetaData instance
     */
@@ -153,24 +126,13 @@
 
    /**
     * Set the ParameterizedMetaData instance.
-    *
     * @param parameterizedMetaData the parameterized metadata
-    * @param context the context
-    */
-   protected void setParameterizedMetaData(P parameterizedMetaData, KernelControllerContext context)
-   {
-      setParameterizedMetaData(parameterizedMetaData, context.getBeanMetaData());
-   }
-
-   /**
-    * Set the ParameterizedMetaData instance.
-    * @param parameterizedMetaData the parameterized metadata
     * @param beanMetaData the bean metadata
     */
    protected abstract void setParameterizedMetaData(P parameterizedMetaData, BeanMetaData beanMetaData);
 
    @SuppressWarnings("unchecked")
-   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(T info, MetaData retrieval, C annotation, KernelControllerContext context) throws Throwable
+   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(T info, MetaData retrieval, C annotation, BeanMetaData beanMetaData) throws Throwable
    {
       boolean trace = log.isTraceEnabled();
 
@@ -179,7 +141,7 @@
       {
          if (trace)
             log.trace("Info " + info + " has zero parameters.");
-         return handleParameterlessInfo(info, annotation, context);
+         return handleParameterlessInfo(info, annotation, beanMetaData);
       }
 
       TypeInfo[] typeInfos = new TypeInfo[parameters.length];
@@ -220,12 +182,11 @@
             throw new IllegalArgumentException("MetaData for parameter must exist: " + pi);
          }
       }
-      P parameterizedMetaData = createParametrizedMetaData(info, annotation, context);
-      setParameterizedMetaData(parameterizedMetaData, context);
+      P parameterizedMetaData = createParametrizedMetaData(info, annotation, beanMetaData);
+      setParameterizedMetaData(parameterizedMetaData, beanMetaData);
       parameterizedMetaData.setParameters(pmds);
       if (parameterizedMetaData instanceof MetaDataVisitorNode == false)
          throw new IllegalArgumentException("ParameterizedMetaData not MetaDataVisitor: " + parameterizedMetaData);
       return Collections.singletonList((MetaDataVisitorNode)parameterizedMetaData);
    }
-
 }

Copied: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AliasMetaDataAnnotationPlugin.java (from rev 71877, projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AliasesAnnotationPlugin.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AliasMetaDataAnnotationPlugin.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AliasMetaDataAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -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.kernel.plugins.annotations;
+
+import java.util.List;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Arrays;
+
+import org.jboss.beans.metadata.api.annotations.Aliases;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
+import org.jboss.reflect.spi.ClassInfo;
+
+/**
+ * Aliases annotation plugin.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AliasMetaDataAnnotationPlugin extends ClassAnnotationPlugin<Aliases>
+{
+   public static final AliasMetaDataAnnotationPlugin INSTANCE = new AliasMetaDataAnnotationPlugin();
+
+   protected AliasMetaDataAnnotationPlugin()
+   {
+      super(Aliases.class);
+   }
+
+   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, Aliases annotation, BeanMetaData beanMetaData) throws Throwable
+   {
+      String[] strings = annotation.value();
+      if (strings != null && strings.length > 0)
+      {
+         Set<Object> aliases = beanMetaData.getAliases();
+         if (aliases == null)
+         {
+            AbstractBeanMetaData abmd = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
+            aliases = new HashSet<Object>();
+            abmd.setAliases(aliases);
+         }
+         aliases.addAll(Arrays.asList(strings));
+      }
+      return null;
+   }
+}
\ No newline at end of file

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AliasesAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AliasesAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AliasesAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -41,12 +41,14 @@
  */
 public class AliasesAnnotationPlugin extends ClassAnnotationPlugin<Aliases>
 {
-   public AliasesAnnotationPlugin()
+   public static final AliasesAnnotationPlugin INSTANCE = new AliasesAnnotationPlugin();
+   
+   protected AliasesAnnotationPlugin()
    {
       super(Aliases.class);
    }
 
-   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, Aliases annotation, KernelControllerContext context) throws Throwable
+   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, MetaData retrieval, Aliases annotation, KernelControllerContext context) throws Throwable
    {
       BeanMetaData beanMetaData = context.getBeanMetaData();
       Set<Object> aliases = beanMetaData.getAliases();

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -22,37 +22,22 @@
 package org.jboss.kernel.plugins.annotations;
 
 import java.lang.annotation.Annotation;
-import java.lang.annotation.ElementType;
-import java.util.Set;
 
 import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.kernel.plugins.annotations.MetaDataAnnotationPlugin;
 import org.jboss.metadata.spi.MetaData;
 import org.jboss.reflect.spi.AnnotatedInfo;
 
 /**
- * Annotation plugin contract.
+ * Annotation plugin contract based on MeteDataVistor.
  *
  * @param <T> info type
  * @param <C> annotation type
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
-public interface AnnotationPlugin<T extends AnnotatedInfo, C extends Annotation>
+public interface AnnotationPlugin<T extends AnnotatedInfo, C extends Annotation> extends MetaDataAnnotationPlugin<T, C>
 {
    /**
-    * Get the annotation class we are handling.
-    *
-    * @return annotation class
-    */
-   Class<C> getAnnotation();
-
-   /**
-    * Get all supported types.
-    *
-    * @return set of supported types
-    */
-   Set<ElementType> getSupportedTypes();
-
-   /**
     * Apply the check for annotation.
     *
     * @param info the info

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BaseMetaDataAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BaseMetaDataAnnotationPlugin.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BaseMetaDataAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -0,0 +1,220 @@
+/*
+* 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.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.jboss.beans.metadata.api.annotations.Cleanup;
+import org.jboss.beans.metadata.api.annotations.CleanupOnly;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.reflect.spi.AnnotatedInfo;
+import org.jboss.util.JBossObject;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * Annotation plugin based on bean metadata.
+ *
+ * @param <T> info type
+ * @param <C> annotation type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class BaseMetaDataAnnotationPlugin<T extends AnnotatedInfo, C extends Annotation> extends JBossObject implements MetaDataAnnotationPlugin<T, C>
+{
+   private Class<C> annotation;
+   private Set<ElementType> types;
+   private boolean isCleanup;
+   private boolean isCleanupOnly;
+
+   protected BaseMetaDataAnnotationPlugin(Class<C> annotation)
+   {
+      if (annotation == null)
+         throw new IllegalArgumentException("Null annotation!");
+      this.annotation = annotation;
+
+      this.types = new HashSet<ElementType>();
+      Target target = annotation.getAnnotation(Target.class);
+      if (target != null)
+      {
+         List<ElementType> list = Arrays.asList(target.value());
+         for(ElementType type : list)
+         {
+            if (isElementTypeSupported(type))
+            {
+               types.add(type);
+            }
+         }
+      }
+      isCleanupOnly = annotation.isAnnotationPresent(CleanupOnly.class);
+      isCleanup = isCleanupOnly || annotation.isAnnotationPresent(Cleanup.class);
+   }
+
+   public final void applyAnnotation(T info, MetaData retrieval, BeanMetaData beanMetaData) throws Throwable
+   {
+      boolean trace = log.isTraceEnabled();
+
+      if (isCleanupOnly() == false)
+      {
+         Class<C> annotationClass = getAnnotation();
+         C annotation = retrieval.getAnnotation(annotationClass);
+         if (annotation == null)
+         {
+            if (trace)
+               log.trace("No annotation: " + annotationClass.getName());
+            return;
+         }
+         if (isMetaDataAlreadyPresent(info, annotation, beanMetaData))
+         {
+            if (trace)
+               log.trace("MetaDataAlreadyPresent, ignoring " + annotation);
+            return;
+         }
+         if (trace)
+            log.trace("Applying annotation: " + annotation);
+
+         internalApplyAnnotation(info, retrieval, annotation, beanMetaData);
+      }
+      else if (trace)
+         log.trace("Annotation " + getAnnotation() + " is @CleanupOnly, nothing to apply on install.");
+   }
+
+   /**
+    * Is meta data already present.
+    *
+    * @param info the info
+    * @param annotation the annotation
+    * @param beanMetaData the bean meta data
+    * @return true if meta data already present
+    */
+   protected boolean isMetaDataAlreadyPresent(T info, C annotation, BeanMetaData beanMetaData)
+   {
+      return false;
+   }
+
+   /**
+    * Apply annotation since it's not present.
+    *
+    * @param info the info
+    * @param retrieval the metadata
+    * @param annotation the annotation
+    * @param beanMetaData the bean meta data
+    * @return used to return covariant type
+    * @throws Throwable for any error
+    */
+   protected Object internalApplyAnnotation(T info, MetaData retrieval, C annotation, BeanMetaData beanMetaData) throws Throwable
+   {
+      return internalApplyAnnotation(info, annotation, beanMetaData);
+   }
+
+   /**
+    * Apply annotation since it's not present.
+    *
+    * @param info the info
+    * @param annotation the annotation
+    * @param beanMetaData the bean meta data
+    * @return used to return covariant type
+    * @throws Throwable for any error
+    */
+   protected abstract Object internalApplyAnnotation(T info, C annotation, BeanMetaData beanMetaData) throws Throwable;
+
+   /**
+    * Is annotation marked as cleanup.
+    *
+    * @return true if cleanup annotation
+    */
+   protected boolean isCleanup()
+   {
+      return isCleanup;
+   }
+
+   /**
+    * Is annotation marked as cleanup only.
+    *
+    * @return true if clean up only
+    */
+   protected boolean isCleanupOnly()
+   {
+      return isCleanupOnly;
+   }
+
+   /**
+    * Does attribute have value.
+    * Helper method.
+    *
+    * @param value the value
+    * @return true if atribute not null or non-empty
+    */
+   protected static boolean isAttributePresent(String value)
+   {
+      return ValueUtil.isAttributePresent(value);
+   }
+
+   /**
+    * Does attribute have value.
+    * Helper method.
+    *
+    * @param value the value
+    * @return true if atribute not void.class
+    */
+   protected static boolean isAttributePresent(Class<?> value)
+   {
+      return ValueUtil.isAttributePresent(value);
+   }
+
+   /**
+    * Is type supported by plugin.
+    *
+    * @param type the annotation element type
+    * @return true if element supported
+    */
+   protected abstract boolean isElementTypeSupported(ElementType type);
+
+   public Set<ElementType> getSupportedTypes()
+   {
+      return Collections.unmodifiableSet(types);
+   }
+
+   public Class<C> getAnnotation()
+   {
+      return annotation;
+   }
+
+   protected void toString(JBossStringBuilder buffer)
+   {
+      buffer.append("@annotation=").append(annotation);
+      buffer.append(" ,types=").append(types);
+      buffer.append(" ,cleanup=").append(isCleanup);
+      buffer.append(" ,cleanupOnly=").append(isCleanupOnly);
+   }
+
+   public void toShortString(JBossStringBuilder buffer)
+   {
+      buffer.append("@annotation=").append(annotation);
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -30,7 +30,9 @@
  */
 public class BasicBeanAnnotationAdapter extends AbstractBeanAnnotationAdapter
 {
-   public BasicBeanAnnotationAdapter()
+   public static BasicBeanAnnotationAdapter INSTANCE = new BasicBeanAnnotationAdapter();
+
+   private BasicBeanAnnotationAdapter()
    {
       // -- adapters
       @SuppressWarnings("unchecked")
@@ -49,13 +51,13 @@
       };
       // -- plugins
       // class
-      addAnnotationPlugin(new AliasesAnnotationPlugin());
-      addAnnotationPlugin(new DemandsAnnotationPlugin());
-      addAnnotationPlugin(new DependsAnnotationPlugin());
-      addAnnotationPlugin(new SupplysAnnotationPlugin());
+      addAnnotationPlugin(AliasesAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(DemandsAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(DependsAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(SupplysAnnotationPlugin.INSTANCE);
       addAnnotationPlugin(new ClassFactoryAnnotationPlugin(adapters));
-      addAnnotationPlugin(new ExternalInstallAnnotationPlugin());
-      addAnnotationPlugin(new ExternalUninstallAnnotationPlugin());
+      addAnnotationPlugin(ExternalInstallAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(ExternalUninstallAnnotationPlugin.INSTANCE);
 /*
       addAnnotationPlugin(new InjectConstructorValueAnnotationPlugin());
       addAnnotationPlugin(new StringValueConstructorValueAnnotationPlugin());
@@ -80,8 +82,8 @@
       addAnnotationPlugin(SetValueAnnotationPlugin.INSTANCE);
       addAnnotationPlugin(ArrayValueAnnotationPlugin.INSTANCE);
       addAnnotationPlugin(MapValueAnnotationPlugin.INSTANCE);
-      addAnnotationPlugin(new PropertyInstallCallbackAnnotationPlugin());
-      addAnnotationPlugin(new PropertyUninstallCallbackAnnotationPlugin());
+      addAnnotationPlugin(PropertyInstallCallbackAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(PropertyUninstallCallbackAnnotationPlugin.INSTANCE);
       // method
       addAnnotationPlugin(new FactoryMethodAnnotationPlugin(adapters));
       addAnnotationPlugin(new CreateLifecycleAnnotationPlugin(adapters));
@@ -93,9 +95,9 @@
       addAnnotationPlugin(new InstallMethodParameterAnnotationPlugin(adapters));
       addAnnotationPlugin(new UninstallMethodParameterAnnotationPlugin(adapters));
       // field
-      addAnnotationPlugin(new InjectFieldAnnotationPlugin());
-      addAnnotationPlugin(new ValueFactoryFieldAnnotationPlugin());
-      addAnnotationPlugin(new InstallFieldCallbackAnnotationPlugin());
-      addAnnotationPlugin(new UninstallFieldCallbackAnnotationPlugin());
+      addAnnotationPlugin(InjectFieldAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(ValueFactoryFieldAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(InstallFieldCallbackAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(UninstallFieldCallbackAnnotationPlugin.INSTANCE);
    }
 }

Copied: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanMetaDataAnnotationAdapter.java (from rev 71877, projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanAnnotationAdapter.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanMetaDataAnnotationAdapter.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BasicBeanMetaDataAnnotationAdapter.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -0,0 +1,93 @@
+/*
+* 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.annotations;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * Basic bean metadata annotation handler.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BasicBeanMetaDataAnnotationAdapter extends AbstractMetaDataAnnotationAdapter
+{
+   public static BasicBeanMetaDataAnnotationAdapter INSTANCE = new BasicBeanMetaDataAnnotationAdapter();
+
+   private BasicBeanMetaDataAnnotationAdapter()
+   {
+      // -- adapters
+      @SuppressWarnings("unchecked")
+      Annotation2ValueMetaDataAdapter<? extends Annotation>[] adapters = new Annotation2ValueMetaDataAdapter[]{
+         InjectAnnotationPlugin.INSTANCE,
+         StringValueAnnotationPlugin.INSTANCE,
+         ValueFactoryAnnotationPlugin.INSTANCE,
+         ThisValueAnnotationPlugin.INSTANCE,
+         NullValueAnnotationPlugin.INSTANCE,
+         JavaBeanValueAnnotationPlugin.INSTANCE,
+         CollectionValueAnnotationPlugin.INSTANCE,
+         ListValueAnnotationPlugin.INSTANCE,
+         SetValueAnnotationPlugin.INSTANCE,
+         ArrayValueAnnotationPlugin.INSTANCE,
+         MapValueAnnotationPlugin.INSTANCE,
+      };
+      // -- plugins
+      // class
+      addAnnotationPlugin(AliasMetaDataAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(DemandsAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(DependsAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(SupplysAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(new ClassFactoryAnnotationPlugin(adapters));
+      addAnnotationPlugin(ExternalInstallAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(ExternalUninstallAnnotationPlugin.INSTANCE);
+      // constructor
+      addAnnotationPlugin(new ConstructorParameterAnnotationPlugin(adapters));
+      // property
+      addAnnotationPlugin(InjectAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(StringValueAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(ValueFactoryAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(ThisValueAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(NullValueAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(JavaBeanValueAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(CollectionValueAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(ListValueAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(SetValueAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(ArrayValueAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(MapValueAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(PropertyInstallCallbackAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(PropertyUninstallCallbackAnnotationPlugin.INSTANCE);
+      // method
+      addAnnotationPlugin(new FactoryMethodAnnotationPlugin(adapters));
+      addAnnotationPlugin(new CreateLifecycleAnnotationPlugin(adapters));
+      addAnnotationPlugin(new StartLifecycleAnnotationPlugin(adapters));
+      addAnnotationPlugin(new StopLifecycleAnnotationPlugin(adapters));
+      addAnnotationPlugin(new DestroyLifecycleAnnotationPlugin(adapters));
+      addAnnotationPlugin(MethodInstallCallbackAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(MethodUninstallCallbackAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(new InstallMethodParameterAnnotationPlugin(adapters));
+      addAnnotationPlugin(new UninstallMethodParameterAnnotationPlugin(adapters));
+      // field
+      addAnnotationPlugin(InjectFieldAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(ValueFactoryFieldAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(InstallFieldCallbackAnnotationPlugin.INSTANCE);
+      addAnnotationPlugin(UninstallFieldCallbackAnnotationPlugin.INSTANCE);
+   }
+}
\ No newline at end of file

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BeanAnnotationAdapterFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BeanAnnotationAdapterFactory.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BeanAnnotationAdapterFactory.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -81,7 +81,7 @@
          catch (Throwable t)
          {
             log.warn("Exception while creating bean annotation adapter instance: " + t);
-            return new BasicBeanAnnotationAdapter();
+            return BasicBeanAnnotationAdapter.INSTANCE;
          }
       }
    }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -29,6 +29,7 @@
 
 import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
 import org.jboss.beans.metadata.plugins.AbstractCallbackMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.CallbackMetaData;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
 import org.jboss.dependency.spi.CallbackItem;
@@ -87,9 +88,9 @@
     */
    protected abstract Set<CallbackItem<?>> getCallbacks(DependencyInfo dependency);
 
-   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(T info, C annotation, KernelControllerContext context)
+   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(T info, C annotation, BeanMetaData bmd)
    {
-      AbstractBeanMetaData beanMetaData = (AbstractBeanMetaData)context.getBeanMetaData();
+      AbstractBeanMetaData beanMetaData = checkIfNotAbstractBeanMetaDataSpecific(bmd);
       List<CallbackMetaData> callbacks = getCallbacks(beanMetaData);
       AbstractCallbackMetaData callback = createCallback(info, annotation);
       callbacks.add(callback);

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassFactoryAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassFactoryAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ClassFactoryAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -27,15 +27,14 @@
 import java.util.Collections;
 import java.util.List;
 
+import org.jboss.beans.metadata.api.annotations.Factory;
+import org.jboss.beans.metadata.api.annotations.Value;
 import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
 import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
 import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
-import org.jboss.beans.metadata.api.annotations.Factory;
-import org.jboss.beans.metadata.api.annotations.Value;
 import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
 import org.jboss.beans.metadata.spi.ParameterMetaData;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.reflect.spi.ClassInfo;
 
 /**
@@ -60,9 +59,9 @@
       return beanMetaData.getConstructor() != null;
    }
 
-   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, Factory annotation, KernelControllerContext context) throws Throwable
+   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, Factory annotation, BeanMetaData beanMetaData) throws Throwable
    {
-      AbstractBeanMetaData bean = (AbstractBeanMetaData)context.getBeanMetaData();
+      AbstractBeanMetaData bean = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
       AbstractConstructorMetaData constructor = new AbstractConstructorMetaData();
       if (isAttributePresent(annotation.factoryClass()))
       {

Copied: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CommonAnnotationAdapter.java (from rev 71877, projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/AbstractBeanAnnotationAdapter.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CommonAnnotationAdapter.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CommonAnnotationAdapter.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -0,0 +1,340 @@
+/*
+* 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.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.kernel.plugins.config.Configurator;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.signature.ConstructorSignature;
+import org.jboss.metadata.spi.signature.FieldSignature;
+import org.jboss.metadata.spi.signature.MethodSignature;
+import org.jboss.metadata.spi.signature.Signature;
+import org.jboss.reflect.spi.AnnotatedInfo;
+import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.reflect.spi.ConstructorInfo;
+import org.jboss.reflect.spi.FieldInfo;
+import org.jboss.reflect.spi.MethodInfo;
+
+/**
+ * Common bean annotation handler.
+ *
+ * @param <T> exact annotation plugin type
+ * @param <U> exact handle type
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public abstract class CommonAnnotationAdapter<T extends MetaDataAnnotationPlugin, U>
+{
+   protected Logger log = Logger.getLogger(getClass());
+
+   protected Set<T> classAnnotationPlugins = new HashSet<T>();
+   protected Set<T> constructorAnnotationPlugins = new HashSet<T>();
+   protected Set<T> propertyAnnotationPlugins = new HashSet<T>();
+   protected Set<T> methodAnnotationPlugins = new HashSet<T>();
+   protected Set<T> fieldAnnotationPlugins = new HashSet<T>();
+
+   /**
+    * Add the annotation plugin.
+    * Breaks down the plugin usage into
+    * different ElementType support collections.
+    *
+    * @param plugin the annotation plugin
+    */
+   @SuppressWarnings("unchecked")
+   public void addAnnotationPlugin(T plugin)
+   {
+      if (plugin == null)
+         throw new IllegalArgumentException("Null plugin.");
+
+      Class<? extends Annotation> annotation = plugin.getAnnotation();
+      if (annotation == null)
+         throw new IllegalArgumentException("Null annotation class: " + plugin);
+
+      if (annotation.getAnnotation(Target.class) == null)
+         log.warn("Annotation " + annotation + " missing @Target annotation!");
+      if (annotation.getAnnotation(Retention.class) == null)
+         log.warn("Annotation " + annotation + " missing @Retention annotation!");
+
+      Set supported = plugin.getSupportedTypes();
+      if (supported == null || supported.isEmpty())
+         throw new IllegalArgumentException("Null or empty support types: " + plugin);
+
+      if (supported.contains(ElementType.TYPE))
+      {
+         classAnnotationPlugins.add(plugin);
+      }
+      if (supported.contains(ElementType.CONSTRUCTOR))
+      {
+         constructorAnnotationPlugins.add(plugin);
+      }
+      if (supported.contains(ElementType.METHOD))
+      {
+         if (plugin instanceof PropertyAware)
+            propertyAnnotationPlugins.add(plugin);
+         else
+            methodAnnotationPlugins.add(plugin);
+      }
+      if (supported.contains(ElementType.FIELD))
+      {
+         fieldAnnotationPlugins.add(plugin);
+      }
+   }
+
+   /**
+    * Remove the plugin.
+    *
+    * @param plugin the annotation plugin
+    */
+   public void removeAnnotationPlugin(T plugin)
+   {
+      if (plugin == null)
+         return;
+
+      Set supported = plugin.getSupportedTypes();
+      if (supported == null || supported.isEmpty())
+         throw new IllegalArgumentException("Null or empty support types: " + plugin);
+
+      if (supported.contains(ElementType.TYPE))
+      {
+         classAnnotationPlugins.remove(plugin);
+      }
+      if (supported.contains(ElementType.CONSTRUCTOR))
+      {
+         constructorAnnotationPlugins.remove(plugin);
+      }
+      if (supported.contains(ElementType.METHOD))
+      {
+         if (plugin instanceof PropertyAware)
+            propertyAnnotationPlugins.remove(plugin);
+         else
+            methodAnnotationPlugins.remove(plugin);
+      }
+      if (supported.contains(ElementType.FIELD))
+      {
+         fieldAnnotationPlugins.remove(plugin);
+      }
+   }
+
+   /**
+    * Apply plugin.
+    *
+    * @param plugin the plugin
+    * @param info the bean info
+    * @param retrieval the metadata
+    * @param handle the handle
+    * @throws Throwable for any error
+    */
+   protected abstract void applyPlugin(T plugin, AnnotatedInfo info, MetaData retrieval, U handle) throws Throwable;
+
+   /**
+    * Clean plugin.
+    *
+    * @param plugin the plugin
+    * @param info the bean info
+    * @param retrieval the metadata
+    * @param handle the handle
+    * @throws Throwable for any error
+    */
+   protected abstract void cleanPlugin(T plugin, AnnotatedInfo info, MetaData retrieval, U handle) throws Throwable;
+
+   /**
+    * Get the name from handle.
+    *
+    * @param handle the handle
+    * @return handle's name
+    */
+   protected abstract Object getName(U handle);
+
+   /**
+    * Handle apply or cleanup of annotations.
+    *
+    * @param info the bean info
+    * @param retrieval the metadata
+    * @param handle the handle to use in a plugin
+    * @param isApplyPhase is this apply phase
+    * @throws Throwable for any error
+    */
+   protected void handleAnnotations(BeanInfo info, MetaData retrieval, U handle, boolean isApplyPhase) throws Throwable
+   {
+      if (info == null)
+         throw new IllegalArgumentException("Null bean info.");
+      if (retrieval == null)
+         throw new IllegalArgumentException("Null metadata.");
+      if (handle == null)
+         throw new IllegalArgumentException("Null handle.");
+
+      boolean trace = log.isTraceEnabled();
+      if (trace)
+         log.trace(getName(handle) + " apply annotations");
+
+      // class
+      ClassInfo classInfo = info.getClassInfo();
+      for(T plugin : classAnnotationPlugins)
+      {
+         if (isApplyPhase)
+            applyPlugin(plugin, classInfo, retrieval, handle);
+         else
+            cleanPlugin(plugin, classInfo, retrieval, handle);
+      }
+
+      // constructors
+      Set<ConstructorInfo> constructors = info.getConstructors();
+      if (constructors != null && constructors.isEmpty() == false)
+      {
+         for(ConstructorInfo ci : constructors)
+         {
+            Signature cis = new ConstructorSignature(Configurator.getParameterTypes(trace, ci.getParameterTypes()));
+            MetaData cmdr = retrieval.getComponentMetaData(cis);
+            if (cmdr != null)
+            {
+               for(T plugin : constructorAnnotationPlugins)
+               {
+                  if (isApplyPhase)
+                     applyPlugin(plugin, ci, cmdr, handle);
+                  else
+                     cleanPlugin(plugin, ci, cmdr, handle);
+               }
+            }
+            else if (trace)
+               log.trace("No annotations for " + ci);
+         }
+      }
+      else if (trace)
+         log.trace("No constructors");
+
+      // properties
+      Set<MethodInfo> visitedMethods = new HashSet<MethodInfo>();
+      Set<PropertyInfo> properties = info.getProperties();
+      if (properties != null && properties.isEmpty() == false)
+      {
+         for(PropertyInfo pi : properties)
+         {
+            MethodInfo setter = pi.getSetter();
+            FieldInfo field = pi.getFieldInfo();
+
+            if (setter != null)
+            {
+               visitedMethods.add(setter);
+               Signature sis = new MethodSignature(setter);
+               MetaData cmdr = retrieval.getComponentMetaData(sis);
+               if (cmdr != null)
+               {
+                  for(T plugin : propertyAnnotationPlugins)
+                  {
+                     if (isApplyPhase)
+                        applyPlugin(plugin, pi, cmdr, handle);
+                     else
+                        cleanPlugin(plugin, pi, cmdr, handle);
+                  }
+               }
+               else if (trace)
+                  log.trace("No annotations for property " + pi.getName());
+            }
+            else if (field != null)
+            {
+               Signature sis = new FieldSignature(field);
+               MetaData cmdr = retrieval.getComponentMetaData(sis);
+               if (cmdr != null)
+               {
+                  for(T plugin : fieldAnnotationPlugins)
+                  {
+                     if (isApplyPhase)
+                        applyPlugin(plugin, field, cmdr, handle);
+                     else
+                        cleanPlugin(plugin, field, cmdr, handle);
+                  }
+               }
+               else if (trace)
+                  log.trace("No annotations for field " + field.getName());
+            }
+         }
+      }
+      else if (trace)
+         log.trace("No properties");
+
+      // methods
+      Set<MethodInfo> methods = info.getMethods();
+      if (methods != null && methods.isEmpty() == false)
+      {
+         for(MethodInfo mi : methods)
+         {
+            if (visitedMethods.contains(mi) == false)
+            {
+               Signature mis = new MethodSignature(mi);
+               MetaData cmdr = retrieval.getComponentMetaData(mis);
+               if (cmdr != null)
+               {
+                  for(T plugin : methodAnnotationPlugins)
+                  {
+                     if (isApplyPhase)
+                        applyPlugin(plugin, mi, cmdr, handle);
+                     else
+                        cleanPlugin(plugin, mi, cmdr, handle);
+                  }
+               }
+               else if (trace)
+                  log.trace("No annotations for " + mi);
+            }
+         }
+      }
+      else if (trace)
+         log.trace("No methods");
+
+      // static methods
+      MethodInfo[] staticMethods = classInfo.getDeclaredMethods();
+      if (staticMethods != null && staticMethods.length != 0)
+      {
+         for(MethodInfo smi : staticMethods)
+         {
+            if (smi.isStatic() && smi.isPublic())
+            {
+               Signature mis = new MethodSignature(smi);
+               MetaData cmdr = retrieval.getComponentMetaData(mis);
+               if (cmdr != null)
+               {
+                  for(T plugin : methodAnnotationPlugins)
+                  {
+                     if (isApplyPhase)
+                        applyPlugin(plugin, smi, cmdr, handle);
+                     else
+                        cleanPlugin(plugin, smi, cmdr, handle);
+                  }
+               }
+               else if (trace)
+                  log.trace("No annotations for " + smi);
+            }
+         }
+      }
+      else if (trace)
+         log.trace("No static methods");
+
+      // fields - if accessible - are already handled with propertys
+   }
+}
\ No newline at end of file

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorValueAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorValueAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ConstructorValueAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -31,6 +31,7 @@
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.reflect.spi.ClassInfo;
+import org.jboss.metadata.spi.MetaData;
 
 /**
  * Constructor value annotation plugin.
@@ -50,9 +51,10 @@
       return beanMetaData.getConstructor() != null;
    }
 
-   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, C annotation, KernelControllerContext context) throws Throwable
+   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, MetaData retrieval, C annotation, KernelControllerContext context) throws Throwable
    {
-      AbstractBeanMetaData beanMetaData = (AbstractBeanMetaData)context.getBeanMetaData();
+      BeanMetaData bmd = context.getBeanMetaData();
+      AbstractBeanMetaData beanMetaData = checkIfNotAbstractBeanMetaDataSpecific(bmd);
       AbstractConstructorMetaData constructor = new AbstractConstructorMetaData();
       constructor.setValue(createValueMetaData(annotation));
       beanMetaData.setConstructor(constructor);

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DemandsAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -26,15 +26,14 @@
 import java.util.List;
 import java.util.Set;
 
+import org.jboss.beans.metadata.api.annotations.Demand;
+import org.jboss.beans.metadata.api.annotations.Demands;
 import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
 import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
-import org.jboss.beans.metadata.api.annotations.Demand;
-import org.jboss.beans.metadata.api.annotations.Demands;
 import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.DemandMetaData;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
 import org.jboss.dependency.spi.ControllerState;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.reflect.spi.ClassInfo;
 
 /**
@@ -44,19 +43,21 @@
  */
 public class DemandsAnnotationPlugin extends ClassAnnotationPlugin<Demands>
 {
-   public DemandsAnnotationPlugin()
+   public static final DemandsAnnotationPlugin INSTANCE = new DemandsAnnotationPlugin();
+
+   protected DemandsAnnotationPlugin()
    {
       super(Demands.class);
    }
 
-   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, Demands annotation, KernelControllerContext context)
+   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, Demands annotation, BeanMetaData beanMetaData)
    {
-      BeanMetaData beanMetaData = context.getBeanMetaData();
       Set<DemandMetaData> demands = beanMetaData.getDemands();
       if (demands == null)
       {
+         AbstractBeanMetaData abmd = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
          demands = new HashSet<DemandMetaData>();
-         ((AbstractBeanMetaData)beanMetaData).setDemands(demands);
+         abmd.setDemands(demands);
       }
       List<MetaDataVisitorNode> nodes = new ArrayList<MetaDataVisitorNode>();
       for(Demand demand : annotation.value())

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DependsAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DependsAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/DependsAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -26,13 +26,12 @@
 import java.util.List;
 import java.util.Set;
 
+import org.jboss.beans.metadata.api.annotations.Depends;
 import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
 import org.jboss.beans.metadata.plugins.AbstractDependencyMetaData;
-import org.jboss.beans.metadata.api.annotations.Depends;
 import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.DependencyMetaData;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.reflect.spi.ClassInfo;
 
 /**
@@ -42,19 +41,21 @@
  */
 public class DependsAnnotationPlugin extends ClassAnnotationPlugin<Depends>
 {
-   public DependsAnnotationPlugin()
+   public static final DependsAnnotationPlugin INSTANCE = new DependsAnnotationPlugin();
+
+   protected DependsAnnotationPlugin()
    {
       super(Depends.class);
    }
 
-   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, Depends annotation, KernelControllerContext context)
+   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, Depends annotation, BeanMetaData beanMetaData)
    {
-      BeanMetaData beanMetaData = context.getBeanMetaData();
       Set<DependencyMetaData> dependencies = beanMetaData.getDepends();
       if (dependencies == null)
       {
+         AbstractBeanMetaData abmd = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
          dependencies = new HashSet<DependencyMetaData>();
-         ((AbstractBeanMetaData)beanMetaData).setDepends(dependencies);
+         abmd.setDepends(dependencies);
       }
       List<MetaDataVisitorNode> nodes = new ArrayList<MetaDataVisitorNode>();
       for(String depends : annotation.value())

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ExternalInstallAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ExternalInstallAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ExternalInstallAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -37,6 +37,8 @@
  */
 public class ExternalInstallAnnotationPlugin extends ExternalInstallationAnnotationPlugin<ExternalInstalls>
 {
+   public static final ExternalInstallAnnotationPlugin INSTANCE = new ExternalInstallAnnotationPlugin();
+
    protected ExternalInstallAnnotationPlugin()
    {
       super(ExternalInstalls.class);
@@ -47,8 +49,9 @@
       List<InstallMetaData> list = beanMetaData.getInstalls();
       if (list == null)
       {
+         AbstractBeanMetaData abmd = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
          list = new ArrayList<InstallMetaData>();
-         ((AbstractBeanMetaData)beanMetaData).setInstalls(list);
+         abmd.setInstalls(list);
       }
       return list;
    }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ExternalInstallationAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ExternalInstallationAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ExternalInstallationAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -25,17 +25,16 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.jboss.beans.metadata.plugins.AbstractInstallMetaData;
-import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
 import org.jboss.beans.metadata.api.annotations.ExternalInstall;
 import org.jboss.beans.metadata.api.annotations.Value;
+import org.jboss.beans.metadata.plugins.AbstractInstallMetaData;
+import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.InstallMetaData;
 import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
 import org.jboss.beans.metadata.spi.ParameterMetaData;
 import org.jboss.beans.metadata.spi.ValueMetaData;
 import org.jboss.dependency.spi.ControllerState;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.reflect.spi.ClassInfo;
 
 /**
@@ -114,9 +113,8 @@
       return installMetaData;
    }
 
-   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, C annotation, KernelControllerContext context) throws Throwable
+   protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(ClassInfo info, C annotation, BeanMetaData beanMetaData) throws Throwable
    {
-      BeanMetaData beanMetaData = context.getBeanMetaData();
       List<InstallMetaData> existing = getExistingInstallMetaData(beanMetaData);
       if (existing == null)
          throw new IllegalArgumentException("Must set empty Set to installs/uninstalls!");
@@ -203,5 +201,4 @@
 
       return false;
    }
-
 }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ExternalUninstallAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ExternalUninstallAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ExternalUninstallAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -37,6 +37,8 @@
  */
 public class ExternalUninstallAnnotationPlugin extends ExternalInstallationAnnotationPlugin<ExternalUninstalls>
 {
+   public static final ExternalUninstallAnnotationPlugin INSTANCE = new ExternalUninstallAnnotationPlugin();
+
    protected ExternalUninstallAnnotationPlugin()
    {
       super(ExternalUninstalls.class);
@@ -47,8 +49,9 @@
       List<InstallMetaData> list = beanMetaData.getUninstalls();
       if (list == null)
       {
+         AbstractBeanMetaData abmd = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
          list = new ArrayList<InstallMetaData>();
-         ((AbstractBeanMetaData)beanMetaData).setUninstalls(list);
+         abmd.setUninstalls(list);
       }
       return list;
    }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/FactoryMethodAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -80,8 +80,7 @@
 
    protected void setParameterizedMetaData(AbstractConstructorMetaData parameterizedMetaData, BeanMetaData beanMetaData)
    {
-      AbstractBeanMetaData abmd = (AbstractBeanMetaData)beanMetaData;
+      AbstractBeanMetaData abmd = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
       abmd.setConstructor(parameterizedMetaData);
    }
-
 }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectFieldAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectFieldAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InjectFieldAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -31,7 +31,9 @@
  */
 public class InjectFieldAnnotationPlugin extends FieldAnnotationPlugin<Inject>
 {
-   public InjectFieldAnnotationPlugin()
+   public static final InjectFieldAnnotationPlugin INSTANCE = new InjectFieldAnnotationPlugin();
+
+   protected InjectFieldAnnotationPlugin()
    {
       super(Inject.class);
    }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallFieldCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallFieldCallbackAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallFieldCallbackAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -44,6 +44,8 @@
  */
 public class InstallFieldCallbackAnnotationPlugin extends CallbackAnnotationPlugin<FieldInfo, Install>
 {
+   public static final InstallFieldCallbackAnnotationPlugin INSTANCE = new InstallFieldCallbackAnnotationPlugin();
+
    protected InstallFieldCallbackAnnotationPlugin()
    {
       super(Install.class);

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallMethodParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallMethodParameterAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallMethodParameterAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -63,7 +63,7 @@
 
    protected void setParameterizedMetaData(AbstractInstallMetaData parameterizedMetaData, BeanMetaData beanMetaData)
    {
-      AbstractBeanMetaData abmd = (AbstractBeanMetaData)beanMetaData;
+      AbstractBeanMetaData abmd = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
       List<InstallMetaData> installs = beanMetaData.getInstalls();
       if (installs == null)
       {

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/LifecycleParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/LifecycleParameterAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/LifecycleParameterAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -94,7 +94,7 @@
 
    protected List<? extends MetaDataVisitorNode> handleParameterlessInfo(MethodInfo info, C annotation, BeanMetaData beanMetaData)
    {
-      AbstractBeanMetaData abmd = (AbstractBeanMetaData)beanMetaData;
+      AbstractBeanMetaData abmd = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
       AbstractLifecycleMetaData lifecycle = createLifecycleMetaData(info.getName(), annotation);
       setLifecycleMetaData(abmd, lifecycle);
       return Collections.singletonList(lifecycle);
@@ -107,7 +107,7 @@
 
    protected void setParameterizedMetaData(AbstractLifecycleMetaData parameterizedMetaData, BeanMetaData beanMetaData)
    {
-      AbstractBeanMetaData abmd = (AbstractBeanMetaData)beanMetaData;
+      AbstractBeanMetaData abmd = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
       setLifecycleMetaData(abmd, parameterizedMetaData);
    }
 }

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MetaDataAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MetaDataAnnotationPlugin.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MetaDataAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -0,0 +1,62 @@
+/*
+* 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.annotations;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.util.Set;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.reflect.spi.AnnotatedInfo;
+
+/**
+ * Annotation plugin based on bean metadata.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface MetaDataAnnotationPlugin<T extends AnnotatedInfo, C extends Annotation>
+{
+   /**
+    * Get the annotation class we are handling.
+    *
+    * @return annotation class
+    */
+   Class<C> getAnnotation();
+
+   /**
+    * Get all supported types.
+    *
+    * @return set of supported types
+    */
+   Set<ElementType> getSupportedTypes();
+
+   /**
+    * Apply annotations to bean metadata.
+    *
+    * @param info the annotated info we are checking
+    * @param retrieval the metadata retrieval
+    * @param beanMetaData the bean metadata
+    * @throws Throwable for any error
+    */
+   void applyAnnotation(T info, MetaData retrieval, BeanMetaData beanMetaData) throws Throwable;
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodInstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodInstallCallbackAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodInstallCallbackAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -32,7 +32,9 @@
  */
 public class MethodInstallCallbackAnnotationPlugin extends InstallCallbackAnnotationPlugin<MethodInfo>
 {
-   public MethodInstallCallbackAnnotationPlugin()
+   public static final MethodInstallCallbackAnnotationPlugin INSTANCE = new MethodInstallCallbackAnnotationPlugin();
+
+   protected MethodInstallCallbackAnnotationPlugin()
    {
       super();
    }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodUninstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodUninstallCallbackAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/MethodUninstallCallbackAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -32,7 +32,9 @@
  */
 public class MethodUninstallCallbackAnnotationPlugin extends UninstallCallbackAnnotationPlugin<MethodInfo>
 {
-   public MethodUninstallCallbackAnnotationPlugin()
+   public static final MethodUninstallCallbackAnnotationPlugin INSTANCE = new MethodUninstallCallbackAnnotationPlugin();
+
+   protected MethodUninstallCallbackAnnotationPlugin()
    {
       super();
    }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyInstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyInstallCallbackAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyInstallCallbackAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -32,7 +32,9 @@
  */
 public class PropertyInstallCallbackAnnotationPlugin extends InstallCallbackAnnotationPlugin<PropertyInfo> implements PropertyAware
 {
-   public PropertyInstallCallbackAnnotationPlugin()
+   public static final PropertyInstallCallbackAnnotationPlugin INSTANCE = new PropertyInstallCallbackAnnotationPlugin();
+
+   protected PropertyInstallCallbackAnnotationPlugin()
    {
       super();
    }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyUninstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyUninstallCallbackAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/PropertyUninstallCallbackAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -32,7 +32,9 @@
  */
 public class PropertyUninstallCallbackAnnotationPlugin extends UninstallCallbackAnnotationPlugin<PropertyInfo> implements PropertyAware
 {
-   public PropertyUninstallCallbackAnnotationPlugin()
+   public static final PropertyUninstallCallbackAnnotationPlugin INSTANCE = new PropertyUninstallCallbackAnnotationPlugin();
+
+   protected PropertyUninstallCallbackAnnotationPlugin()
    {
       super();
    }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/SupplysAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -42,7 +42,9 @@
  */
 public class SupplysAnnotationPlugin extends ClassAnnotationPlugin<Supplys>
 {
-   public SupplysAnnotationPlugin()
+   public static final SupplysAnnotationPlugin INSTANCE = new SupplysAnnotationPlugin();
+
+   protected SupplysAnnotationPlugin()
    {
       super(Supplys.class);
    }
@@ -52,8 +54,9 @@
       Set<SupplyMetaData> supplies = beanMetaData.getSupplies();
       if (supplies == null)
       {
+         AbstractBeanMetaData abmd = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
          supplies = new HashSet<SupplyMetaData>();
-         ((AbstractBeanMetaData)beanMetaData).setSupplies(supplies);
+         abmd.setSupplies(supplies);
       }
       List<MetaDataVisitorNode> nodes = new ArrayList<MetaDataVisitorNode>();
       for(Supply supply : annotation.value())

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallFieldCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallFieldCallbackAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallFieldCallbackAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -44,6 +44,8 @@
  */
 public class UninstallFieldCallbackAnnotationPlugin extends CallbackAnnotationPlugin<FieldInfo, Uninstall>
 {
+   public static final UninstallFieldCallbackAnnotationPlugin INSTANCE = new UninstallFieldCallbackAnnotationPlugin();
+
    protected UninstallFieldCallbackAnnotationPlugin()
    {
       super(Uninstall.class);

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallMethodParameterAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallMethodParameterAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallMethodParameterAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -63,7 +63,7 @@
 
    protected void setParameterizedMetaData(AbstractInstallMetaData parameterizedMetaData, BeanMetaData beanMetaData)
    {
-      AbstractBeanMetaData abmd = (AbstractBeanMetaData)beanMetaData;
+      AbstractBeanMetaData abmd = checkIfNotAbstractBeanMetaDataSpecific(beanMetaData);
       List<InstallMetaData> uninstalls = beanMetaData.getUninstalls();
       if (uninstalls == null)
       {

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ValueFactoryFieldAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ValueFactoryFieldAnnotationPlugin.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/ValueFactoryFieldAnnotationPlugin.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -31,7 +31,9 @@
  */
 public class ValueFactoryFieldAnnotationPlugin extends FieldAnnotationPlugin<ValueFactory>
 {
-   public ValueFactoryFieldAnnotationPlugin()
+   public static final ValueFactoryFieldAnnotationPlugin INSTANCE = new ValueFactoryFieldAnnotationPlugin();
+
+   protected ValueFactoryFieldAnnotationPlugin()
    {
       super(ValueFactory.class);
    }

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/annotations/AnnotationToBeanMetaDataFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/annotations/AnnotationToBeanMetaDataFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/annotations/AnnotationToBeanMetaDataFactory.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -0,0 +1,252 @@
+/*
+* 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.spi.annotations;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.BeanAccessMode;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.config.plugins.property.PropertyConfiguration;
+import org.jboss.config.spi.Configuration;
+import org.jboss.kernel.plugins.annotations.BasicBeanMetaDataAnnotationAdapter;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.plugins.loader.reflection.AnnotatedElementMetaDataLoader;
+
+/**
+ * Annotation to bean metadata factory.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationToBeanMetaDataFactory
+{
+   /** The configuration */
+   private static Configuration configuration;
+
+   static
+   {
+      // get Configuration instance
+      configuration = AccessController.doPrivileged(new PrivilegedAction<Configuration>()
+      {
+         public Configuration run()
+         {
+            return new PropertyConfiguration();
+         }
+      });
+   }
+
+   /**
+    * Create bean metadata for class.
+    *
+    * @param beanClass the bean class
+    * @return bean metadata
+    * @throws Throwable for any error
+    */
+   public static BeanMetaData createBeanMetaData(Class<?> beanClass) throws Throwable
+   {
+      return fillBeanMetaData(beanClass, null);
+   }
+
+   /**
+    * Create bean metadata for class.
+    *
+    * @param beanClass the bean class
+    * @param mode the bean access mode
+    * @return bean metadata
+    * @throws Throwable for any error
+    */
+   public static BeanMetaData createBeanMetaData(Class<?> beanClass, BeanAccessMode mode) throws Throwable
+   {
+      return fillBeanMetaData(beanClass, mode, null);
+   }
+
+   /**
+    * Create bean metadata for class.
+    *
+    * @param beanClass the bean class
+    * @param metaData predefined metadata
+    * @return bean metadata
+    * @throws Throwable for any error
+    */
+   public static BeanMetaData createBeanMetaData(Class<?> beanClass, MetaData metaData) throws Throwable
+   {
+      return fillBeanMetaData(beanClass, metaData, null, null);
+   }
+
+   /**
+    * Create bean metadata for class.
+    *
+    * @param beanClass the bean class
+    * @param adapter bean metadata adapter
+    * @return bean metadata
+    * @throws Throwable for any error
+    */
+   public static BeanMetaData createBeanMetaData(Class<?> beanClass, BeanMetaDataAnnotationAdapter adapter) throws Throwable
+   {
+      return fillBeanMetaData(beanClass, null, adapter);
+   }
+
+   /**
+    * Create bean metadata for class.
+    *
+    * @param beanClass the bean class
+    * @param mode the bean access mode
+    * @param adapter bean metadata adapter
+    * @return bean metadata
+    * @throws Throwable for any error
+    */
+   public static BeanMetaData createBeanMetaData(Class<?> beanClass, BeanAccessMode mode, BeanMetaDataAnnotationAdapter adapter) throws Throwable
+   {
+      return fillBeanMetaData(beanClass, mode, null, null, adapter);
+   }
+
+   /**
+    * Create bean metadata for class.
+    *
+    * @param beanClass the bean class
+    * @param existingMetaData the existing bean metadata
+    * @return bean metadata
+    * @throws Throwable for any error
+    */
+   public static BeanMetaData fillBeanMetaData(Class<?> beanClass, BeanMetaData existingMetaData) throws Throwable
+   {
+      return fillBeanMetaData(beanClass, existingMetaData, null);
+   }
+
+   /**
+    * Create bean metadata for class.
+    *
+    * @param beanClass the bean class
+    * @param mode the bean access mode
+    * @param existingMetaData the existing bean metadata
+    * @return bean metadata
+    * @throws Throwable for any error
+    */
+   public static BeanMetaData fillBeanMetaData(Class<?> beanClass, BeanAccessMode mode, BeanMetaData existingMetaData) throws Throwable
+   {
+      return fillBeanMetaData(beanClass, mode, null, existingMetaData, null);
+   }
+
+   /**
+    * Create bean metadata for class.
+    *
+    * @param beanClass the bean class
+    * @param existingMetaData the existing bean metadata
+    * @param adapter bean metadata adapter
+    * @return bean metadata
+    * @throws Throwable for any error
+    */
+   public static BeanMetaData fillBeanMetaData(Class<?> beanClass, BeanMetaData existingMetaData, BeanMetaDataAnnotationAdapter adapter) throws Throwable
+   {
+      return fillBeanMetaData(beanClass, null, null, existingMetaData, adapter);
+   }
+
+   /**
+    * Create bean metadata for class.
+    *
+    * @param beanClass the bean class
+    * @param mode the bean access mode
+    * @param existingMetaData the existing bean metadata
+    * @param adapter bean metadata adapter
+    * @return bean metadata
+    * @throws Throwable for any error
+    */
+   public static BeanMetaData fillBeanMetaData(Class<?> beanClass, BeanAccessMode mode, BeanMetaData existingMetaData, BeanMetaDataAnnotationAdapter adapter) throws Throwable
+   {
+      return fillBeanMetaData(beanClass, mode, null, existingMetaData, adapter);
+   }
+
+   /**
+    * Create bean metadata for class.
+    *
+    * @param beanClass the bean class
+    * @param metaData predefined metadata
+    * @param existingMetaData the existing bean metadata
+    * @param adapter bean metadata adapter
+    * @return bean metadata
+    * @throws Throwable for any error
+    */
+   public static BeanMetaData fillBeanMetaData(Class<?> beanClass, MetaData metaData, BeanMetaData existingMetaData, BeanMetaDataAnnotationAdapter adapter) throws Throwable
+   {
+      return fillBeanMetaData(beanClass, null, metaData, existingMetaData, adapter);
+   }
+
+   /**
+    * Create bean metadata for class.
+    *
+    * @param beanClass the bean class
+    * @param mode the bean access mode
+    * @param metaData predefined metadata
+    * @param existingMetaData the existing bean metadata
+    * @param adapter bean metadata adapter
+    * @return bean metadata
+    * @throws Throwable for any error
+    */
+   public static BeanMetaData fillBeanMetaData(Class<?> beanClass, BeanAccessMode mode, MetaData metaData, BeanMetaData existingMetaData, BeanMetaDataAnnotationAdapter adapter) throws Throwable
+   {
+      if (beanClass == null)
+         throw new IllegalArgumentException("Null bean class");
+
+      if (mode == null)
+         mode = BeanAccessMode.STANDARD;
+
+      if (metaData == null)
+      {
+         MetaDataRetrieval retrieval = new AnnotatedElementMetaDataLoader(beanClass);
+         metaData = new MetaDataRetrievalToMetaDataBridge(retrieval);
+      }
+
+      if (existingMetaData == null)
+      {
+         AbstractBeanMetaData abmd = new AbstractBeanMetaData();
+         abmd.setBean(beanClass.getName());
+         abmd.setAccessMode(mode);
+         existingMetaData = abmd;
+      }
+      else
+      {
+         BeanAccessMode bam = existingMetaData.getAccessMode();
+         if (bam == null)
+         {
+            if (existingMetaData instanceof AbstractBeanMetaData == false)
+               throw new IllegalArgumentException("Can only apply BeanAccessMode to AbstractBeanMetaData: " + existingMetaData);
+
+            AbstractBeanMetaData abmd = AbstractBeanMetaData.class.cast(existingMetaData);
+            abmd.setAccessMode(mode);
+         }
+         else if (bam != mode)
+            throw new IllegalArgumentException("Different bean access modes: " + bam + " != " + mode);
+      }
+
+      if (adapter == null)
+         adapter = BasicBeanMetaDataAnnotationAdapter.INSTANCE;
+
+      BeanInfo beanInfo = configuration.getBeanInfo(beanClass, mode);
+      adapter.applyAnnotations(beanInfo, metaData, existingMetaData);
+
+      return existingMetaData;
+   }
+}

Copied: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/annotations/BeanMetaDataAnnotationAdapter.java (from rev 71877, projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/BeanAnnotationAdapter.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/annotations/BeanMetaDataAnnotationAdapter.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/annotations/BeanMetaDataAnnotationAdapter.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -0,0 +1,44 @@
+/*
+* 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.spi.annotations;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.metadata.spi.MetaData;
+
+/**
+ * Annotations adapter contract based on metadata.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface BeanMetaDataAnnotationAdapter
+{
+   /**
+    * Apply the annotations on bean metadata.
+    *
+    * @param beanInfo the bean info
+    * @param metaData the metadata
+    * @param beanMetaData the bean meta data
+    * @throws Throwable for any error
+    */
+   void applyAnnotations(BeanInfo beanInfo, MetaData metaData, BeanMetaData beanMetaData) throws Throwable;
+}
\ No newline at end of file

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/AliasesImpl.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/AliasesImpl.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/AliasesImpl.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -0,0 +1,54 @@
+/*
+* 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.annotations.support;
+
+import java.lang.annotation.Annotation;
+
+import org.jboss.beans.metadata.api.annotations.Aliases;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AliasesImpl implements Aliases
+{
+   private String[] aliases;
+
+   public AliasesImpl(String... aliases)
+   {
+      this.aliases = aliases;
+   }
+
+   public String[] value()
+   {
+      return aliases;
+   }
+
+   public boolean replace()
+   {
+      return true;
+   }
+
+   public Class<? extends Annotation> annotationType()
+   {
+      return Aliases.class;
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/AllIoCAnnotations.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/AllIoCAnnotations.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/AllIoCAnnotations.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -0,0 +1,85 @@
+/*
+* 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.annotations.support;
+
+import org.jboss.beans.metadata.api.annotations.Aliases;
+import org.jboss.beans.metadata.api.annotations.Create;
+import org.jboss.beans.metadata.api.annotations.Demand;
+import org.jboss.beans.metadata.api.annotations.Demands;
+import org.jboss.beans.metadata.api.annotations.Depends;
+import org.jboss.beans.metadata.api.annotations.Destroy;
+import org.jboss.beans.metadata.api.annotations.ExternalInstall;
+import org.jboss.beans.metadata.api.annotations.ExternalInstalls;
+import org.jboss.beans.metadata.api.annotations.ExternalUninstalls;
+import org.jboss.beans.metadata.api.annotations.Factory;
+import org.jboss.beans.metadata.api.annotations.Inject;
+import org.jboss.beans.metadata.api.annotations.Install;
+import org.jboss.beans.metadata.api.annotations.InstallMethod;
+import org.jboss.beans.metadata.api.annotations.Start;
+import org.jboss.beans.metadata.api.annotations.Stop;
+import org.jboss.beans.metadata.api.annotations.Supply;
+import org.jboss.beans.metadata.api.annotations.Supplys;
+import org.jboss.beans.metadata.api.annotations.Uninstall;
+import org.jboss.beans.metadata.api.annotations.UninstallMethod;
+
+/**
+ * All IoC annoattions.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+ at Aliases("alias")
+ at Demands({@Demand("demand")})
+ at Depends({"depend"})
+ at Supplys({@Supply("supply")})
+ at Factory(factoryClass = AnnotationTester.class, factoryMethod = "factoryMethod")
+ at ExternalInstalls({@ExternalInstall(bean = "bean", method = "method")})
+ at ExternalUninstalls({@ExternalInstall(bean = "bean", method = "method")})
+public class AllIoCAnnotations
+{
+   @Inject
+   private int time;
+
+   @Inject
+   public void setNumber(int number) {}
+
+   @Create
+   public void myCreate() {}
+
+   @Start
+   public void myStart() {}
+
+   @Stop
+   public void myStop() {}
+
+   @Destroy
+   public void myDestroy() {}
+
+   @Install
+   public void addSomething(AnnotationTester tester) {}
+
+   @Uninstall
+   public void removeSomething(AnnotationTester tester) {}
+
+   @InstallMethod
+   @UninstallMethod
+   public void invoke() {}
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SimpleBeanMetaDataAnnotationAdapter.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SimpleBeanMetaDataAnnotationAdapter.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/support/SimpleBeanMetaDataAnnotationAdapter.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -0,0 +1,39 @@
+/*
+* 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.annotations.support;
+
+import org.jboss.kernel.spi.annotations.BeanMetaDataAnnotationAdapter;
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.dependency.spi.ControllerMode;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class SimpleBeanMetaDataAnnotationAdapter implements BeanMetaDataAnnotationAdapter
+{
+   public void applyAnnotations(BeanInfo beanInfo, MetaData metaData, BeanMetaData beanMetaData) throws Throwable
+   {
+      beanMetaData.setMode(ControllerMode.ASYNCHRONOUS);
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/AnnotationsTestSuite.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -27,6 +27,7 @@
 import org.jboss.test.kernel.annotations.test.override.AnnotationsOverrideTestSuite;
 import org.jboss.test.kernel.annotations.test.inheritance.AnnotationsInheritanceTestSuite;
 import org.jboss.test.kernel.annotations.test.field.AnnotationFieldTestSuite;
+import org.jboss.test.kernel.annotations.test.factory.AnnotationFactoryTestSuite;
 
 /**
  * Annotations tests.
@@ -48,6 +49,7 @@
       suite.addTest(AnnotationsOverrideTestSuite.suite());
       suite.addTest(AnnotationsInheritanceTestSuite.suite());
       suite.addTest(AnnotationFieldTestSuite.suite());
+      suite.addTest(AnnotationFactoryTestSuite.suite());
 
       return suite;
    }

Copied: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/factory/AnnotationFactoryTestSuite.java (from rev 71877, projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/field/AnnotationFieldTestSuite.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/factory/AnnotationFactoryTestSuite.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/factory/AnnotationFactoryTestSuite.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -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.annotations.test.factory;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+/**
+ * Annotation factory tests.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationFactoryTestSuite extends TestSuite
+{
+   public static void main(String[] args)
+   {
+      TestRunner.run(suite());
+   }
+
+   public static Test suite()
+   {
+      TestSuite suite = new TestSuite("Annotation factory Tests");
+
+      suite.addTest(AnnotationToBeanMetaDataFactoryTestCase.suite());
+
+      return suite;
+   }
+}
\ No newline at end of file

Copied: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/factory/AnnotationToBeanMetaDataFactoryTestCase.java (from rev 71877, projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/field/SimpleFieldTestCase.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/factory/AnnotationToBeanMetaDataFactoryTestCase.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/annotations/test/factory/AnnotationToBeanMetaDataFactoryTestCase.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -0,0 +1,198 @@
+/*
+* 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.annotations.test.factory;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Test;
+import org.jboss.beans.info.spi.BeanAccessMode;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDependencyMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
+import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.CallbackMetaData;
+import org.jboss.beans.metadata.spi.ConstructorMetaData;
+import org.jboss.beans.metadata.spi.DemandMetaData;
+import org.jboss.beans.metadata.spi.DependencyMetaData;
+import org.jboss.beans.metadata.spi.InstallMetaData;
+import org.jboss.beans.metadata.spi.LifecycleMetaData;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.beans.metadata.spi.ParameterMetaData;
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.kernel.spi.annotations.AnnotationToBeanMetaDataFactory;
+import org.jboss.metadata.plugins.context.AbstractMetaDataContext;
+import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
+import org.jboss.metadata.spi.MetaData;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
+import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge;
+import org.jboss.metadata.spi.scope.CommonLevels;
+import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.test.BaseTestCase;
+import org.jboss.test.kernel.annotations.support.AliasesImpl;
+import org.jboss.test.kernel.annotations.support.AllIoCAnnotations;
+import org.jboss.test.kernel.annotations.support.AnnotationTester;
+import org.jboss.test.kernel.annotations.support.SimpleBeanMetaDataAnnotationAdapter;
+import org.jboss.test.kernel.annotations.support.ConstructorAnnotationTester;
+
+/**
+ * Simple field test.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AnnotationToBeanMetaDataFactoryTestCase extends BaseTestCase
+{
+   public AnnotationToBeanMetaDataFactoryTestCase(String name)
+   {
+      super(name);
+   }
+
+   public static Test suite()
+   {
+      return suite(AnnotationToBeanMetaDataFactoryTestCase.class);
+   }
+
+   protected void testInstalls(List<InstallMetaData> installs)
+   {
+      assertNotNull(installs);
+      assertEquals(2, installs.size());
+      for (InstallMetaData imd : installs)
+      {
+         Object bean = imd.getBean();
+         if (bean == null)
+         {
+            assertEquals("invoke", imd.getMethodName());
+         }
+         else
+         {
+            assertEquals("bean", bean);
+            assertEquals("method", imd.getMethodName());
+         }
+      }
+   }
+
+   protected void testLifecycle(LifecycleMetaData lifecycle, String method)
+   {
+      assertNotNull(lifecycle);
+      assertEquals(method, lifecycle.getMethodName());
+   }
+
+   protected void testBMD(BeanMetaData bmd) throws Throwable
+   {
+      assertNotNull(bmd);
+      assertEquals(Collections.singleton((Object)"alias"), bmd.getAliases());
+      assertEquals(Collections.singleton((SupplyMetaData)new AbstractSupplyMetaData("supply")), bmd.getSupplies());
+      assertEquals(Collections.singleton((DemandMetaData)new AbstractDemandMetaData("demand")), bmd.getDemands());
+      assertEquals(Collections.singleton((DependencyMetaData)new AbstractDependencyMetaData("depend")), bmd.getDepends());
+      ConstructorMetaData cmd = bmd.getConstructor();
+      assertNotNull(cmd);
+      assertEquals(AnnotationTester.class.getName(), cmd.getFactoryClass());
+      assertEquals("factoryMethod", cmd.getFactoryMethod());
+      testInstalls(bmd.getInstalls());
+      testInstalls(bmd.getUninstalls());
+
+      List<CallbackMetaData> callbacks = bmd.getInstallCallbacks();
+      assertNotNull(callbacks);
+      assertEquals(1, callbacks.size());
+      CallbackMetaData callback = callbacks.get(0);
+      assertTrue(callback.getMethodName().contains("Something"));
+      callbacks = bmd.getUninstallCallbacks();
+      assertNotNull(callbacks);
+      assertEquals(1, callbacks.size());
+      callback = callbacks.get(0);
+      assertTrue(callback.getMethodName().contains("Something"));
+
+      BeanAccessMode mode = bmd.getAccessMode();
+      if (mode == BeanAccessMode.ALL)
+      {
+         Set<PropertyMetaData> propertys = bmd.getProperties();
+         assertNotNull(propertys);
+         assertEquals(2, propertys.size());
+      }
+      else
+      {
+         Set<PropertyMetaData> propertys = bmd.getProperties();
+         assertNotNull(propertys);
+         assertEquals(1, propertys.size());
+         PropertyMetaData pmd = propertys.iterator().next();
+         assertEquals("number", pmd.getName());
+         assertInstanceOf(pmd.getValue(), AbstractDependencyValueMetaData.class);
+      }
+      testLifecycle(bmd.getCreate(), "myCreate");
+      testLifecycle(bmd.getStart(), "myStart");
+      testLifecycle(bmd.getStop(), "myStop");
+      testLifecycle(bmd.getDestroy(), "myDestroy");
+   }
+
+   public void testDefaultAnnotation2BMDFactory() throws Throwable
+   {
+      BeanMetaData bmd1 = AnnotationToBeanMetaDataFactory.createBeanMetaData(AllIoCAnnotations.class);
+      testBMD(bmd1);
+
+      bmd1 = AnnotationToBeanMetaDataFactory.createBeanMetaData(AllIoCAnnotations.class, BeanAccessMode.ALL);
+      testBMD(bmd1);
+
+      bmd1 = AnnotationToBeanMetaDataFactory.createBeanMetaData(ConstructorAnnotationTester.class);
+      ConstructorMetaData cmd = bmd1.getConstructor();
+      assertNotNull(cmd);
+      List<ParameterMetaData> parameters = cmd.getParameters();
+      assertNotNull(parameters);
+      assertEquals(1, parameters.size());
+   }
+
+   public void testProvidedMetaData() throws Throwable
+   {
+      MemoryMetaDataLoader memory = new MemoryMetaDataLoader(new ScopeKey(CommonLevels.INSTANCE, "foobar"));
+      memory.addAnnotation(new AliasesImpl("alias"));
+      MetaDataRetrieval retrieval = new AbstractMetaDataContext(null, memory);
+      MetaData metaData = new MetaDataRetrievalToMetaDataBridge(retrieval);
+
+      BeanMetaData bmd = AnnotationToBeanMetaDataFactory.createBeanMetaData(Object.class, metaData);
+      assertNotNull(bmd);
+      assertEquals(Collections.singleton((Object)"alias"), bmd.getAliases());
+   }
+
+   public void testCustomAdapter() throws Throwable
+   {
+      BeanMetaData bmd = AnnotationToBeanMetaDataFactory.createBeanMetaData(Object.class, new SimpleBeanMetaDataAnnotationAdapter());
+      assertEquals(ControllerMode.ASYNCHRONOUS, bmd.getMode());
+   }
+
+   public void testIllegalAccessMode() throws Throwable
+   {
+      AbstractBeanMetaData abmd = new AbstractBeanMetaData();
+      abmd.setAccessMode(BeanAccessMode.FIELDS);
+      try
+      {
+         AnnotationToBeanMetaDataFactory.fillBeanMetaData(Object.class, BeanAccessMode.ALL, abmd);
+         fail("Should not be here.");
+      }
+      catch (Throwable t)
+      {
+         assertInstanceOf(t, IllegalArgumentException.class);
+      }
+   }
+}
\ No newline at end of file

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/AnonymousBeansTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/AnonymousBeansTestCase.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/AnonymousBeansTestCase.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -114,7 +114,7 @@
       assertSame(const_param.getSimpleBean(), const_param_1);
 
       SimpleObjectWithBeans prop = assertBean("prop", SimpleObjectWithBeans.class);
-      SimpleBean prop_bean = assertBean("prop$simpleBean", SimpleBean.class);
+      SimpleBean prop_bean = assertBean("prop$simpleBean#1", SimpleBean.class);
       assertSame(prop.getSimpleBean(), prop_bean);
 
       SimpleObjectWithBeans list = assertBean("list", SimpleObjectWithBeans.class);
@@ -138,7 +138,7 @@
       assertSame(map.getMap().values().iterator().next(), map_bean_2);
 
       SimpleObjectWithBeans nested = assertBean("nested", SimpleObjectWithBeans.class);
-      SimpleObjectWithBeans nested_nested = assertBean("nested$nested", SimpleObjectWithBeans.class);
+      SimpleObjectWithBeans nested_nested = assertBean("nested$nested#2", SimpleObjectWithBeans.class);
       SimpleBean nested_1 = assertBean("nested#1", SimpleBean.class);
       assertSame(nested.getNested(), nested_nested);
       assertSame(nested_nested.getSimpleBean(), nested_1);

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CollectionAnnotationCallbackTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CollectionAnnotationCallbackTestCase.java	2008-04-11 13:11:10 UTC (rev 72019)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/inject/test/CollectionAnnotationCallbackTestCase.java	2008-04-11 13:24:44 UTC (rev 72020)
@@ -21,8 +21,11 @@
 */
 package org.jboss.test.kernel.inject.test;
 
+import java.util.Set;
+
 import junit.framework.Test;
 import org.jboss.test.kernel.inject.support.CallbackTestObject;
+import org.jboss.test.kernel.inject.support.TesterInterface;
 
 /**
  * Callback tests.
@@ -43,6 +46,8 @@
 
    protected void afterInstall(CallbackTestObject testObject)
    {
-      assertTrue(testObject.getTesterInterfaces().isEmpty());
+      Set<TesterInterface> interfaces = testObject.getTesterInterfaces();
+      assertNotNull(interfaces);
+      assertTrue(interfaces.isEmpty());
    }
 }




More information about the jboss-cvs-commits mailing list