[jboss-cvs] JBossAS SVN: r71891 - in projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment: support/container/plugin and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 10 06:02:34 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-04-10 06:02:34 -0400 (Thu, 10 Apr 2008)
New Revision: 71891

Added:
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/GenericComponentFactory.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/GenericComponentInstance.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentBeanMetaDataFactory.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentFactory.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentInstance.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentNameBuilder.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentVisitor.java
Removed:
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentBeanMetaDataFactory.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentFactory.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentNameBuilder.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/GenericComponentFactory.java
Modified:
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/BeanContextFactory.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerUsageMDTestCase.java
   projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerUsageTestCase.java
Log:
Update the current component factory notion

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/BeanContextFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/BeanContextFactory.java	2008-04-10 09:35:33 UTC (rev 71890)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/BeanContextFactory.java	2008-04-10 10:02:34 UTC (rev 71891)
@@ -49,12 +49,15 @@
 import org.jboss.kernel.spi.dependency.KernelControllerContext;
 import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
 import org.jboss.logging.Logger;
+import org.jboss.test.kernel.deployment.support.container.spi.ComponentBeanMetaDataFactory;
+import org.jboss.test.kernel.deployment.support.container.spi.ComponentNameBuilder;
+import org.jboss.test.kernel.deployment.support.container.spi.ComponentVisitor;
 
 /**
  * @author Scott.Stark at jboss.org
  * @version $Revision:$
  */
-public class BeanContextFactory<T> implements BeanMetaDataFactory, KernelControllerContextAware
+public class BeanContextFactory<T> implements ComponentBeanMetaDataFactory, KernelControllerContextAware
 {
    private static final Logger log = Logger.getLogger(BeanContextFactory.class);
    private String beanClass;
@@ -124,23 +127,26 @@
    /**
     * Create the beans that make up the bean component
     */
-   public List<BeanMetaData> getBeans()
+   public List<BeanMetaData> getBeans(String baseName, long compID,
+         ComponentNameBuilder nameBuilder, ComponentVisitor visitor)
    {
       ArrayList<BeanMetaData> beans = new ArrayList<BeanMetaData>();
       try
       {         
          // Create the BeanContext factory
-         String contextName = "ContextFactory";
+         String contextName = nameBuilder.buildName(baseName, "ContextFactory", compID);
          BeanMetaDataBuilder contextBuilder = BeanMetaDataBuilder.createBuilder(contextName, BaseContext.class.getName());
          contextBuilder.setAccessMode(BeanAccessMode.ALL);
          // The BaseContext ctor
          contextBuilder.addConstructorParameter(BeanContainer.class.getName(), container);
          // BaseContext properties
          // BaseContext.instance
-         String beanName = "BeanInstance";
+         String beanName = nameBuilder.buildName(baseName, "BeanInstance", compID);
          ValueMetaData beanInstance = contextBuilder.createInject(beanName);
          contextBuilder.addPropertyMetaData("instance", beanInstance);
-
+         // Call the visitor to augment the metadata
+         if(visitor != null)
+            visitor.visit(contextBuilder, baseName, "ContextFactory", compID);
          BeanMetaData beanContext = contextBuilder.getBeanMetaData();
          beans.add(beanContext);
    
@@ -158,11 +164,15 @@
          int count = interceptorNames != null ? interceptorNames.size() : 0;
          for(int n = 0; n < count; n ++)
          {
-            String name = "Interceptor:"+n;
+            String iCompName = "Interceptor:"+n;
+            String iname = nameBuilder.buildName(baseName, iCompName, compID);
             String iclass = interceptorNames.get(n);
-            BeanMetaDataBuilder ibuilder = BeanMetaDataBuilder.createBuilder(name, iclass);
+            BeanMetaDataBuilder ibuilder = BeanMetaDataBuilder.createBuilder(iname, iclass);
             ibuilder.addInstall("addInterceptor", contextName);
             ibuilder.addUninstall("removeInterceptor", contextName);
+            // Call the visitor to augment the metadata
+            if(visitor != null)
+               visitor.visit(contextBuilder, baseName, iCompName, compID);
             Set<TestInjectionMetaData> injectMDs = interceptorInjectionMD.get(iclass);
             if(injectMDs != null)
                addDependencyInjection(beanClass, injectMDs, beanBuilder);
@@ -207,24 +217,4 @@
          }
       }
    }
-   private class PropertyMap extends HashMap<String, ValueMetaData> implements MetaDataVisitorNode
-   {
-      /** The serialVersionUID */
-      private static final long serialVersionUID = -4295725682462294630L;
-
-      public void initialVisit(MetaDataVisitor visitor)
-      {
-         visitor.initialVisit(this);
-      }
-
-      public void describeVisit(MetaDataVisitor vistor)
-      {
-         vistor.describeVisit(this);
-      }
-
-      public Iterator<? extends MetaDataVisitorNode> getChildren()
-      {
-         return values().iterator();
-      }
-   }
 }

Deleted: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentBeanMetaDataFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentBeanMetaDataFactory.java	2008-04-10 09:35:33 UTC (rev 71890)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentBeanMetaDataFactory.java	2008-04-10 10:02:34 UTC (rev 71891)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.kernel.deployment.support.container.plugin;
-
-import java.util.List;
-
-import org.jboss.beans.metadata.spi.BeanMetaData;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public interface ComponentBeanMetaDataFactory
-{
-   public List<BeanMetaData> getBeans(String baseName, long compID, ComponentNameBuilder nameBuilder);
-}

Deleted: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentFactory.java	2008-04-10 09:35:33 UTC (rev 71890)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentFactory.java	2008-04-10 10:02:34 UTC (rev 71891)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.kernel.deployment.support.container.plugin;
-
-import java.util.List;
-
-import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
-
-/**
- * A factory for creating a collection of related mc beans based on a
- * template of BeanMetaData[] from a BeanMetaDataFactory.
- * 
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public interface ComponentFactory
-{
-   /**
-    * the factory which defines template BeanMetaData[] for the components
-    * @return the BeanMetaDataFactory defining the component beans
-    */
-   public BeanMetaDataFactory getFactory();
-
-   /**
-    * Install a collection of mc beans based on the factory metadata.
-    * 
-    * @param baseName - the base bean name used in conjuction wth the factory.getBeans()
-    *    BeanMetaData instances getName() to build the unique bean name:
-    *    baseName + bmd.getName() + "#" + compID;
-    * @return the list of mc bean names installed.
-    * @throws Throwable - on failure to install the component beans
-    */
-   public List<String> createComponents(String baseName)
-      throws Throwable;
-
-   /**
-    * Extract the unique component id from a component bean name.
-    * @param name - a name previously returned from createComponents.
-    * @return the component id portion of the name
-    * @throws NumberFormatException - if name is not a valild bean component
-    *    name with a component id.
-    */
-   public long getComponentID(String name) throws NumberFormatException;
-
-   /**
-    * Uninstall the component beans for the given base name, component id
-    * @param baseName - the baseName previously passed to createComponents
-    * @throws Exception - on failure to uninstall the component beans
-    */
-   public void destroyComponents(String baseName, long compID)
-      throws Exception;
-}

Deleted: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentNameBuilder.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentNameBuilder.java	2008-04-10 09:35:33 UTC (rev 71890)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentNameBuilder.java	2008-04-10 10:02:34 UTC (rev 71891)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.kernel.deployment.support.container.plugin;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public interface ComponentNameBuilder
-{
-   public String buildName(String baseName, String compName, long compID);
-   public long getCompID(String name) throws NumberFormatException;
-}

Copied: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/GenericComponentFactory.java (from rev 71868, projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/GenericComponentFactory.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/GenericComponentFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/GenericComponentFactory.java	2008-04-10 10:02:34 UTC (rev 71891)
@@ -0,0 +1,289 @@
+package org.jboss.test.kernel.deployment.support.container.plugin;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.jboss.beans.info.spi.BeanAccessMode;
+import org.jboss.beans.metadata.api.model.AutowireType;
+import org.jboss.beans.metadata.spi.AnnotationMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.CallbackMetaData;
+import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
+import org.jboss.beans.metadata.spi.ConstructorMetaData;
+import org.jboss.beans.metadata.spi.DemandMetaData;
+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.MetaDataVisitor;
+import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.dependency.spi.ErrorHandlingMode;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.test.kernel.deployment.support.container.spi.ComponentBeanMetaDataFactory;
+import org.jboss.test.kernel.deployment.support.container.spi.ComponentFactory;
+import org.jboss.test.kernel.deployment.support.container.spi.ComponentInstance;
+import org.jboss.test.kernel.deployment.support.container.spi.ComponentNameBuilder;
+import org.jboss.test.kernel.deployment.support.container.spi.ComponentVisitor;
+import org.jboss.util.JBossStringBuilder;
+
+public class GenericComponentFactory<T>
+   implements ComponentFactory<T>, ComponentNameBuilder, KernelControllerContextAware
+{
+   private ComponentBeanMetaDataFactory componentsFactory;
+   private AtomicLong compID = new AtomicLong(0);
+   private KernelControllerContext factoryContext;
+   private ComponentVisitor visitor;
+
+   public GenericComponentFactory(ComponentBeanMetaDataFactory factory, ComponentVisitor visitor)
+   {
+      this.componentsFactory = factory;
+      this.visitor = visitor;
+   }
+
+   public void setKernelControllerContext(KernelControllerContext context)
+         throws Exception
+   {
+      factoryContext = context;
+   }
+   public void unsetKernelControllerContext(KernelControllerContext context)
+         throws Exception
+   {
+      factoryContext = null;
+   }
+
+   public ComponentInstance<T> createComponents(String baseName)
+      throws Throwable
+   {
+      ArrayList<String> compNames = new ArrayList<String>();
+      long nextID = compID.incrementAndGet();
+      KernelController controller = (KernelController) factoryContext.getController();
+      List<BeanMetaData> compBeans = componentsFactory.getBeans(baseName, nextID, this, visitor);
+      T t = null;
+      for(BeanMetaData bmd : compBeans)
+      {
+         String beanName = buildName(baseName, bmd.getName(), nextID);
+         BeanMetaDataName nbmd = new BeanMetaDataName(beanName, bmd);
+         KernelControllerContext kcc = controller.install(nbmd);
+         if(t == null)
+            t = (T) kcc.getTarget();
+         compNames.add(beanName);
+      }
+      GenericComponentInstance<T> instance = new GenericComponentInstance<T>(t, compNames, nextID);
+      return instance;
+   }
+
+   public void destroyComponents(ComponentInstance<T> instance) throws Exception
+   {
+      KernelController controller = (KernelController) factoryContext.getController();
+      List<String> compBeans = instance.getComponentNames();
+      for(String beanName : compBeans)
+      {
+         controller.uninstall(beanName);
+      }
+   }
+
+   /**
+    * Parses a name for the #compID suffix
+    */
+   public long getComponentID(String name) throws NumberFormatException
+   {
+      int poundSign = name.indexOf('#');
+      if(poundSign < 0)
+         throw new NumberFormatException(name+" has no #compID suffix");
+      long id = Long.parseLong(name.substring(poundSign+1));
+      return id;
+   }
+
+   public String buildName(String baseName, String compName, long compID)
+   {
+      String beanName = baseName + "@" + compName + "#" + compID;
+      return beanName;
+   }
+
+   public ComponentBeanMetaDataFactory getFactory()
+   {
+      return componentsFactory;
+   }
+
+   public void validate()
+   {
+      KernelController controller = (KernelController) factoryContext.getController();
+      Set<ControllerContext> notInstalled = controller.getNotInstalled();
+      if(notInstalled.size() != 0)
+         throw new IllegalStateException(notInstalled.toString());
+   }
+
+   static class BeanMetaDataName implements BeanMetaData
+   {
+      BeanMetaData bmd;
+      String name;
+      BeanMetaDataName(String name, BeanMetaData bmd)
+      {
+         this.name = name;
+         this.bmd = bmd;
+      }
+      public Object clone()
+      {
+         return bmd.clone();
+      }
+      public void describeVisit(MetaDataVisitor vistor)
+      {
+         bmd.describeVisit(vistor);
+      }
+      public BeanAccessMode getAccessMode()
+      {
+         return bmd.getAccessMode();
+      }
+      public Set<Object> getAliases()
+      {
+         return bmd.getAliases();
+      }
+      public Set<AnnotationMetaData> getAnnotations()
+      {
+         return bmd.getAnnotations();
+      }
+      public AutowireType getAutowireType()
+      {
+         return bmd.getAutowireType();
+      }
+      public String getBean()
+      {
+         return bmd.getBean();
+      }
+      public Iterator<? extends MetaDataVisitorNode> getChildren()
+      {
+         return bmd.getChildren();
+      }
+      public ClassLoaderMetaData getClassLoader()
+      {
+         return bmd.getClassLoader();
+      }
+      public ConstructorMetaData getConstructor()
+      {
+         return bmd.getConstructor();
+      }
+      public LifecycleMetaData getCreate()
+      {
+         return bmd.getCreate();
+      }
+      public Set<DemandMetaData> getDemands()
+      {
+         return bmd.getDemands();
+      }
+      public Set<DependencyMetaData> getDepends()
+      {
+         return bmd.getDepends();
+      }
+      public String getDescription()
+      {
+         return bmd.getDescription();
+      }
+      public LifecycleMetaData getDestroy()
+      {
+         return bmd.getDestroy();
+      }
+      public ErrorHandlingMode getErrorHandlingMode()
+      {
+         return bmd.getErrorHandlingMode();
+      }
+      public List<CallbackMetaData> getInstallCallbacks()
+      {
+         return bmd.getInstallCallbacks();
+      }
+      public List<InstallMetaData> getInstalls()
+      {
+         return bmd.getInstalls();
+      }
+      public ControllerMode getMode()
+      {
+         return bmd.getMode();
+      }
+      public String getName()
+      {
+         return name;
+      }
+      public String getParent()
+      {
+         return bmd.getParent();
+      }
+      public Set<PropertyMetaData> getProperties()
+      {
+         return bmd.getProperties();
+      }
+      public LifecycleMetaData getStart()
+      {
+         return bmd.getStart();
+      }
+      public LifecycleMetaData getStop()
+      {
+         return bmd.getStop();
+      }
+      public Set<SupplyMetaData> getSupplies()
+      {
+         return bmd.getSupplies();
+      }
+      public Object getUnderlyingValue()
+      {
+         return bmd.getUnderlyingValue();
+      }
+      public List<CallbackMetaData> getUninstallCallbacks()
+      {
+         return bmd.getUninstallCallbacks();
+      }
+      public List<InstallMetaData> getUninstalls()
+      {
+         return bmd.getUninstalls();
+      }
+      public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable
+      {
+         return bmd.getValue(info, cl);
+      }
+      public void initialVisit(MetaDataVisitor vistor)
+      {
+         bmd.initialVisit(vistor);
+      }
+      public boolean isAbstract()
+      {
+         return bmd.isAbstract();
+      }
+      public boolean isAutowireCandidate()
+      {
+         return bmd.isAutowireCandidate();
+      }
+      public void setAnnotations(Set<AnnotationMetaData> annotations)
+      {
+         bmd.setAnnotations(annotations);
+      }
+      public void setClassLoader(ClassLoaderMetaData classLoader)
+      {
+         bmd.setClassLoader(classLoader);
+      }
+      public void setMode(ControllerMode mode)
+      {
+         bmd.setMode(mode);
+      }
+      public void setName(String name)
+      {
+         bmd.setName(name);
+      }
+      public String toShortString()
+      {
+         return bmd.toShortString();
+      }
+      public void toShortString(JBossStringBuilder arg0)
+      {
+         bmd.toShortString(arg0);
+      }
+      
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/GenericComponentInstance.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/GenericComponentInstance.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/GenericComponentInstance.java	2008-04-10 10:02:34 UTC (rev 71891)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.kernel.deployment.support.container.plugin;
+
+import java.util.List;
+
+import org.jboss.test.kernel.deployment.support.container.spi.ComponentInstance;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class GenericComponentInstance<T> implements ComponentInstance<T>
+{
+   private T instance;
+   private List<String> names;
+   private long compID;
+
+   public GenericComponentInstance(T instance, List<String> names, long compID)
+   {
+      this.instance = instance;
+      this.names = names;
+      this.compID = compID;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.test.kernel.deployment.support.container.spi.ComponentInstance#getComponentID()
+    */
+   public long getComponentID()
+   {
+      return compID;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.test.kernel.deployment.support.container.spi.ComponentInstance#getComponentNames()
+    */
+   public List<String> getComponentNames()
+   {
+      return names;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.test.kernel.deployment.support.container.spi.ComponentInstance#getContext()
+    */
+   public T getContext()
+   {
+      return instance;
+   }
+
+   /* (non-Javadoc)
+    * @see org.jboss.test.kernel.deployment.support.container.spi.ComponentInstance#getContextName()
+    */
+   public String getContextName()
+   {
+      return names.get(0);
+   }
+
+}

Copied: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentBeanMetaDataFactory.java (from rev 71868, projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentBeanMetaDataFactory.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentBeanMetaDataFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentBeanMetaDataFactory.java	2008-04-10 10:02:34 UTC (rev 71891)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.kernel.deployment.support.container.spi;
+
+import java.util.List;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+
+/**
+ * Factory for the BeanMetaData describing component instances.
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface ComponentBeanMetaDataFactory
+{
+   /**
+    * Create the beans that will be created together as a component.
+    * 
+    * @param baseName - base name used to derive unique bean name
+    * @param compID - component id used to derive unique bean name
+    * @param nameBuilder - transformer used to derive unique bean name from baseName/compID
+    * @param visitor - optional visitor that may augment BeanMetaData
+    * @return list of beans describing the component
+    */
+   public List<BeanMetaData> getBeans(String baseName, long compID,
+         ComponentNameBuilder nameBuilder, ComponentVisitor visitor);
+}

Copied: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentFactory.java (from rev 71868, projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentFactory.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentFactory.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentFactory.java	2008-04-10 10:02:34 UTC (rev 71891)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.kernel.deployment.support.container.spi;
+
+import java.util.List;
+
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+
+/**
+ * A factory for creating a collection of related mc beans based on a
+ * template of BeanMetaData[] from a BeanMetaDataFactory.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface ComponentFactory<T>
+{
+   /**
+    * the factory which defines template BeanMetaData[] for the components
+    * @return the BeanMetaDataFactory defining the component beans
+    */
+   public ComponentBeanMetaDataFactory getFactory();
+
+   /**
+    * Install a collection of mc beans based on the factory metadata.
+    * 
+    * @param baseName - the base bean name used in conjuction wth the factory.getBeans()
+    *    BeanMetaData instances getName() to build the unique bean name:
+    *    baseName + bmd.getName() + "#" + compID;
+    * @return the component context instance information.
+    * @throws Throwable - on failure to install the component beans
+    */
+   public ComponentInstance<T> createComponents(String baseName)
+      throws Throwable;
+
+   /**
+    * Extract the unique component id from a component bean name.
+    * @param name - a name previously returned from createComponents.
+    * @return the component id portion of the name
+    * @throws NumberFormatException - if name is not a valild bean component
+    *    name with a component id.
+    */
+   public long getComponentID(String name) throws NumberFormatException;
+
+   /**
+    * Uninstall the component beans for the given instance
+    * @param instance - the ComponentInstance previously returned from createComponents
+    * @throws Exception - on failure to uninstall the component beans
+    */
+   public void destroyComponents(ComponentInstance<T> instance)
+      throws Exception;
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentInstance.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentInstance.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentInstance.java	2008-04-10 10:02:34 UTC (rev 71891)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.kernel.deployment.support.container.spi;
+
+import java.util.List;
+
+/**
+ * The component context instance. This is the bean that acts as the container
+ * for the component bean instances.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface ComponentInstance<T>
+{
+   /**
+    * Get the name of the bean for the component context instance
+    * @return
+    */
+   public String getContextName();
+   /**
+    * Get the component bean names
+    * @return
+    */
+   public List<String> getComponentNames();
+   /**
+    * Get the id associated with this component
+    * @return
+    */
+   public long getComponentID();
+   /**
+    * Get the component context instance
+    * @return
+    */
+   public T getContext();
+
+}

Copied: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentNameBuilder.java (from rev 71868, projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/plugin/ComponentNameBuilder.java)
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentNameBuilder.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentNameBuilder.java	2008-04-10 10:02:34 UTC (rev 71891)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.kernel.deployment.support.container.spi;
+
+/**
+ * Abstraction for building/parsing component names
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface ComponentNameBuilder
+{
+   /**
+    * Create a globally unique mc bean name
+    * @param baseName - base name used to derive unique bean name
+    * @param compName - the component name used to derive unique bean name
+    * @param compID - component id used to derive unique bean name
+    * @return the unique mc bean name
+    */
+   public String buildName(String baseName, String compName, long compID);
+   /**
+    * Parse a mc bean name for the component id
+    * @param name - the mc bean name
+    * @return the component id
+    * @throws NumberFormatException
+    */
+   public long getComponentID(String name) throws NumberFormatException;
+}

Added: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentVisitor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentVisitor.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/ComponentVisitor.java	2008-04-10 10:02:34 UTC (rev 71891)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.kernel.deployment.support.container.spi;
+
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+
+/**
+ * A component bean factory visitor plugin that allows for extension of the
+ * bean metadata produced by the factory.
+ * 
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface ComponentVisitor
+{
+   /**
+    * Visit callback to allow for augmentation of a components bean metadata.
+    * @param builder - the bean metadata build facade to augment the metadata
+    * @param baseName - the bean base name
+    * @param componentName - the bean component name
+    * @param compID - the bean component id
+    */
+   void visit(BeanMetaDataBuilder builder, String baseName,
+         String componentName, long compID);
+
+}

Deleted: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/GenericComponentFactory.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/GenericComponentFactory.java	2008-04-10 09:35:33 UTC (rev 71890)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/support/container/spi/GenericComponentFactory.java	2008-04-10 10:02:34 UTC (rev 71891)
@@ -1,275 +0,0 @@
-package org.jboss.test.kernel.deployment.support.container.spi;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.jboss.beans.info.spi.BeanAccessMode;
-import org.jboss.beans.metadata.api.model.AutowireType;
-import org.jboss.beans.metadata.spi.AnnotationMetaData;
-import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
-import org.jboss.beans.metadata.spi.CallbackMetaData;
-import org.jboss.beans.metadata.spi.ClassLoaderMetaData;
-import org.jboss.beans.metadata.spi.ConstructorMetaData;
-import org.jboss.beans.metadata.spi.DemandMetaData;
-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.MetaDataVisitor;
-import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
-import org.jboss.beans.metadata.spi.PropertyMetaData;
-import org.jboss.beans.metadata.spi.SupplyMetaData;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerMode;
-import org.jboss.dependency.spi.ErrorHandlingMode;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
-import org.jboss.reflect.spi.TypeInfo;
-import org.jboss.test.kernel.deployment.support.container.plugin.ComponentFactory;
-import org.jboss.util.JBossStringBuilder;
-
-public class GenericComponentFactory
-   implements ComponentFactory, KernelControllerContextAware
-{
-   private BeanMetaDataFactory componentsFactory;
-   private AtomicLong compID = new AtomicLong(0);
-   private KernelControllerContext factoryContext;
-
-   public GenericComponentFactory(BeanMetaDataFactory factory)
-   {
-      this.componentsFactory = factory;
-   }
-
-   public void setKernelControllerContext(KernelControllerContext context)
-         throws Exception
-   {
-      factoryContext = context;
-   }
-   public void unsetKernelControllerContext(KernelControllerContext context)
-         throws Exception
-   {
-      factoryContext = null;
-   }
-
-   public List<String> createComponents(String baseName)
-      throws Throwable
-   {
-      ArrayList<String> compNames = new ArrayList<String>();
-      long nextID = compID.incrementAndGet();
-      KernelController controller = (KernelController) factoryContext.getController();
-      List<BeanMetaData> compBeans = componentsFactory.getBeans();
-      for(BeanMetaData bmd : compBeans)
-      {
-         String beanName = buildComponentName(baseName, bmd.getName(), nextID);
-         BeanMetaDataName nbmd = new BeanMetaDataName(beanName, bmd);
-         controller.install(nbmd);
-         compNames.add(beanName);
-      }
-      Set<ControllerContext> notInstalled = controller.getNotInstalled();
-      if(notInstalled.size() != 0)
-         throw new IllegalStateException(notInstalled.toString());
-     return compNames;
-   }
-
-   public void destroyComponents(String baseName, long compID) throws Exception
-   {
-      KernelController controller = (KernelController) factoryContext.getController();
-      List<BeanMetaData> compBeans = componentsFactory.getBeans();
-      for(BeanMetaData bmd : compBeans)
-      {
-         String beanName = buildComponentName(baseName, bmd.getName(), compID);
-         controller.uninstall(beanName);
-      }
-   }
-
-   /**
-    * Parses a name for the #compID suffix
-    */
-   public long getComponentID(String name) throws NumberFormatException
-   {
-      int poundSign = name.indexOf('#');
-      if(poundSign < 0)
-         throw new NumberFormatException(name+" has no #compID suffix");
-      long id = Long.parseLong(name.substring(poundSign+1));
-      return id;
-   }
-
-   public BeanMetaDataFactory getFactory()
-   {
-      return componentsFactory;
-   }
-
-   protected String buildComponentName(String baseName, String compName, long compID)
-   {
-      String beanName = baseName + "@" + compName + "#" + compID;
-      return beanName;
-   }
-
-   static class BeanMetaDataName implements BeanMetaData
-   {
-      BeanMetaData bmd;
-      String name;
-      BeanMetaDataName(String name, BeanMetaData bmd)
-      {
-         this.name = name;
-         this.bmd = bmd;
-      }
-      public Object clone()
-      {
-         return bmd.clone();
-      }
-      public void describeVisit(MetaDataVisitor vistor)
-      {
-         bmd.describeVisit(vistor);
-      }
-      public BeanAccessMode getAccessMode()
-      {
-         return bmd.getAccessMode();
-      }
-      public Set<Object> getAliases()
-      {
-         return bmd.getAliases();
-      }
-      public Set<AnnotationMetaData> getAnnotations()
-      {
-         return bmd.getAnnotations();
-      }
-      public AutowireType getAutowireType()
-      {
-         return bmd.getAutowireType();
-      }
-      public String getBean()
-      {
-         return bmd.getBean();
-      }
-      public Iterator<? extends MetaDataVisitorNode> getChildren()
-      {
-         return bmd.getChildren();
-      }
-      public ClassLoaderMetaData getClassLoader()
-      {
-         return bmd.getClassLoader();
-      }
-      public ConstructorMetaData getConstructor()
-      {
-         return bmd.getConstructor();
-      }
-      public LifecycleMetaData getCreate()
-      {
-         return bmd.getCreate();
-      }
-      public Set<DemandMetaData> getDemands()
-      {
-         return bmd.getDemands();
-      }
-      public Set<DependencyMetaData> getDepends()
-      {
-         return bmd.getDepends();
-      }
-      public String getDescription()
-      {
-         return bmd.getDescription();
-      }
-      public LifecycleMetaData getDestroy()
-      {
-         return bmd.getDestroy();
-      }
-      public ErrorHandlingMode getErrorHandlingMode()
-      {
-         return bmd.getErrorHandlingMode();
-      }
-      public List<CallbackMetaData> getInstallCallbacks()
-      {
-         return bmd.getInstallCallbacks();
-      }
-      public List<InstallMetaData> getInstalls()
-      {
-         return bmd.getInstalls();
-      }
-      public ControllerMode getMode()
-      {
-         return bmd.getMode();
-      }
-      public String getName()
-      {
-         return name;
-      }
-      public String getParent()
-      {
-         return bmd.getParent();
-      }
-      public Set<PropertyMetaData> getProperties()
-      {
-         return bmd.getProperties();
-      }
-      public LifecycleMetaData getStart()
-      {
-         return bmd.getStart();
-      }
-      public LifecycleMetaData getStop()
-      {
-         return bmd.getStop();
-      }
-      public Set<SupplyMetaData> getSupplies()
-      {
-         return bmd.getSupplies();
-      }
-      public Object getUnderlyingValue()
-      {
-         return bmd.getUnderlyingValue();
-      }
-      public List<CallbackMetaData> getUninstallCallbacks()
-      {
-         return bmd.getUninstallCallbacks();
-      }
-      public List<InstallMetaData> getUninstalls()
-      {
-         return bmd.getUninstalls();
-      }
-      public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable
-      {
-         return bmd.getValue(info, cl);
-      }
-      public void initialVisit(MetaDataVisitor vistor)
-      {
-         bmd.initialVisit(vistor);
-      }
-      public boolean isAbstract()
-      {
-         return bmd.isAbstract();
-      }
-      public boolean isAutowireCandidate()
-      {
-         return bmd.isAutowireCandidate();
-      }
-      public void setAnnotations(Set<AnnotationMetaData> annotations)
-      {
-         bmd.setAnnotations(annotations);
-      }
-      public void setClassLoader(ClassLoaderMetaData classLoader)
-      {
-         bmd.setClassLoader(classLoader);
-      }
-      public void setMode(ControllerMode mode)
-      {
-         bmd.setMode(mode);
-      }
-      public void setName(String name)
-      {
-         bmd.setName(name);
-      }
-      public String toShortString()
-      {
-         return bmd.toShortString();
-      }
-      public void toShortString(JBossStringBuilder arg0)
-      {
-         bmd.toShortString(arg0);
-      }
-      
-   }
-}

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerUsageMDTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerUsageMDTestCase.java	2008-04-10 09:35:33 UTC (rev 71890)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerUsageMDTestCase.java	2008-04-10 10:02:34 UTC (rev 71891)
@@ -36,7 +36,6 @@
 import org.jboss.beans.metadata.plugins.AbstractPropertyMetaData;
 import org.jboss.beans.metadata.plugins.AbstractValueFactoryMetaData;
 import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
-import org.jboss.beans.metadata.spi.BeanMetaData;
 import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
 import org.jboss.beans.metadata.spi.ParameterMetaData;
 import org.jboss.beans.metadata.spi.PropertyMetaData;
@@ -47,7 +46,8 @@
 import org.jboss.test.kernel.deployment.support.container.BeanContainer;
 import org.jboss.test.kernel.deployment.support.container.BeanContextFactory;
 import org.jboss.test.kernel.deployment.support.container.InstanceInterceptor;
-import org.jboss.test.kernel.deployment.support.container.spi.GenericComponentFactory;
+import org.jboss.test.kernel.deployment.support.container.plugin.GenericComponentFactory;
+import org.jboss.test.kernel.deployment.support.container.spi.ComponentVisitor;
 
 /**
  * Programatic version of the BeanContainerUsageTestCase tests
@@ -215,7 +215,8 @@
       BeanMetaDataFactory contextFactoryMD = installBeanInstance("ComponentBeanFactory", contextFactory);
       beanFactories.add(contextFactoryMD);
       */
-      GenericComponentFactory componentFactory = new GenericComponentFactory(contextFactory);
+      ComponentVisitor visitor = null;
+      GenericComponentFactory componentFactory = new GenericComponentFactory(contextFactory, visitor);
       BeanMetaDataFactory componentFactoryMD = installBeanInstance("ComponentBeanFactory", componentFactory);
       beanFactories.add(componentFactoryMD);
       deployment.setBeanFactories(beanFactories);

Modified: projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerUsageTestCase.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerUsageTestCase.java	2008-04-10 09:35:33 UTC (rev 71890)
+++ projects/microcontainer/trunk/kernel/src/tests/org/jboss/test/kernel/deployment/test/BeanContainerUsageTestCase.java	2008-04-10 10:02:34 UTC (rev 71891)
@@ -42,7 +42,8 @@
 import org.jboss.test.kernel.deployment.support.container.Bean2Type;
 import org.jboss.test.kernel.deployment.support.container.BeanContainer;
 import org.jboss.test.kernel.deployment.support.container.BeanPool;
-import org.jboss.test.kernel.deployment.support.container.plugin.ComponentFactory;
+import org.jboss.test.kernel.deployment.support.container.spi.ComponentFactory;
+import org.jboss.test.kernel.deployment.support.container.spi.ComponentInstance;
 
 /**
  * Bean Container Test Case.
@@ -113,23 +114,26 @@
       deployer.shutdown();
    }
 
-   /*
    public void testComponentBeanFactory()
       throws Throwable
    {
       bootstrap();
-      ComponentFactory factory = (ComponentFactory) getBean("ComponentBeanFactory");
+      ComponentFactory<BaseContext<Bean1Type, BeanContainer<Bean1Type>>> factory =
+         (ComponentFactory<BaseContext<Bean1Type, BeanContainer<Bean1Type>>>) getBean("ComponentBeanFactory");
       getLog().info("ComponentBeanFactory bean: "+factory);
-      assertNotNull(factory);
 
-      List<String> beanNames = factory.createComponents("ComponentBeanFactory");
+      ComponentInstance<BaseContext<Bean1Type, BeanContainer<Bean1Type>>> contextInstance =
+         factory.createComponents("ComponentBeanFactory");
+      List<String> beanNames = contextInstance.getComponentNames();
       getLog().info("createComponents(ComponentBeanFactory): "+beanNames);
+      long compID = contextInstance.getComponentID();
+      BaseContext<Bean1Type, BeanContainer<Bean1Type>> context = contextInstance.getContext();
+      String contextName = contextInstance.getContextName();
 
       Object interceptor = getBean("ComponentBeanFactory at Interceptor:0#1");
       assertNotNull(interceptor);
       deployer.shutdown();
    }
-   */
 
    /**
     * There is no xml version of ?




More information about the jboss-cvs-commits mailing list