[jboss-cvs] JBossAS SVN: r86002 - in projects/component-factory/trunk: src and 22 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 17 12:21:17 EDT 2009
Author: alesj
Date: 2009-03-17 12:21:17 -0400 (Tue, 17 Mar 2009)
New Revision: 86002
Added:
projects/component-factory/trunk/src/main/java/
projects/component-factory/trunk/src/main/java/org/
projects/component-factory/trunk/src/main/java/org/jboss/
projects/component-factory/trunk/src/main/java/org/jboss/component/
projects/component-factory/trunk/src/main/java/org/jboss/component/plugin/
projects/component-factory/trunk/src/main/java/org/jboss/component/plugin/GenericComponentFactory.java
projects/component-factory/trunk/src/main/java/org/jboss/component/plugin/GenericComponentInstance.java
projects/component-factory/trunk/src/main/java/org/jboss/component/spi/
projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentBeanMetaDataFactory.java
projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentFactory.java
projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentInstance.java
projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentNameBuilder.java
projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentVisitor.java
projects/component-factory/trunk/src/test/
projects/component-factory/trunk/src/test/java/
projects/component-factory/trunk/src/test/java/org/
projects/component-factory/trunk/src/test/java/org/jboss/
projects/component-factory/trunk/src/test/java/org/jboss/test/
projects/component-factory/trunk/src/test/java/org/jboss/test/component/
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BaseContext.java
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/Bean1Type.java
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/Bean2Type.java
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanContainer.java
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanContext.java
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanContextFactory.java
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanPool.java
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanUser.java
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/InstanceInterceptor.java
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/TestInjectionMetaData.java
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/TestInjectionTargetMetaData.java
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/TestPooledBeanFactory.java
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/plugin/
projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/spi/
projects/component-factory/trunk/src/test/java/org/jboss/test/component/test/
projects/component-factory/trunk/src/test/java/org/jboss/test/component/test/BeanContainerUsageMDTestCase.java
projects/component-factory/trunk/src/test/java/org/jboss/test/component/test/BeanContainerUsageTestCase.java
projects/component-factory/trunk/src/test/resources/
projects/component-factory/trunk/src/test/resources/org/
projects/component-factory/trunk/src/test/resources/org/jboss/
projects/component-factory/trunk/src/test/resources/org/jboss/test/
projects/component-factory/trunk/src/test/resources/org/jboss/test/component/
projects/component-factory/trunk/src/test/resources/org/jboss/test/component/test/
projects/component-factory/trunk/src/test/resources/org/jboss/test/component/test/BeanContainerUsageTestCase_testDependencyInjectionOfBean.xml
projects/component-factory/trunk/src/test/resources/org/jboss/test/component/test/BeanContainerUsageTestCase_testDependencyInjectionOfBeanWithMismatchedPoolSizes.xml
Removed:
projects/component-factory/trunk/src/test/org/
projects/component-factory/trunk/src/tests/
Modified:
projects/component-factory/trunk/pom.xml
Log:
Map mvn structure.
Modified: projects/component-factory/trunk/pom.xml
===================================================================
--- projects/component-factory/trunk/pom.xml 2009-03-17 16:17:33 UTC (rev 86001)
+++ projects/component-factory/trunk/pom.xml 2009-03-17 16:21:17 UTC (rev 86002)
@@ -126,6 +126,13 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.jboss.microcontainer</groupId>
+ <artifactId>jboss-kernel</artifactId>
+ <version>${version.org.jboss.microcontainer}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.jboss.man</groupId>
<artifactId>jboss-managed</artifactId>
<version>${version.org.jboss.managed}</version>
Added: projects/component-factory/trunk/src/main/java/org/jboss/component/plugin/GenericComponentFactory.java
===================================================================
--- projects/component-factory/trunk/src/main/java/org/jboss/component/plugin/GenericComponentFactory.java (rev 0)
+++ projects/component-factory/trunk/src/main/java/org/jboss/component/plugin/GenericComponentFactory.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,287 @@
+package org.jboss.component.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.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.RelatedClassMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.component.spi.ComponentBeanMetaDataFactory;
+import org.jboss.component.spi.ComponentFactory;
+import org.jboss.component.spi.ComponentInstance;
+import org.jboss.component.spi.ComponentNameBuilder;
+import org.jboss.component.spi.ComponentVisitor;
+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.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;
+ }
+
+ @SuppressWarnings("unchecked")
+ 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 = bmd.getName();
+ KernelControllerContext kcc = controller.install(bmd);
+ if(t == null)
+ t = (T) kcc.getTarget();
+ compNames.add(beanName);
+ }
+ return new GenericComponentInstance<T>(t, compNames, nextID);
+ }
+
+ 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.lastIndexOf('#');
+ if(poundSign < 0)
+ throw new NumberFormatException(name+" has no #compID suffix");
+ return Long.parseLong(name.substring(poundSign+1));
+ }
+
+ public String buildName(String baseName, String compName, long compID)
+ {
+ return baseName + "@" + compName + "#" + compID;
+ }
+
+ 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);
+ }
+ public Set<RelatedClassMetaData> getRelated()
+ {
+ return bmd.getRelated();
+ }
+ }
+}
Added: projects/component-factory/trunk/src/main/java/org/jboss/component/plugin/GenericComponentInstance.java
===================================================================
--- projects/component-factory/trunk/src/main/java/org/jboss/component/plugin/GenericComponentInstance.java (rev 0)
+++ projects/component-factory/trunk/src/main/java/org/jboss/component/plugin/GenericComponentInstance.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,65 @@
+/*
+ * 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.component.plugin;
+
+import java.util.List;
+
+import org.jboss.component.spi.ComponentInstance;
+
+/**
+ * @param <T> the instance type
+ * @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;
+ }
+
+ public long getComponentID()
+ {
+ return compID;
+ }
+
+ public List<String> getComponentNames()
+ {
+ return names;
+ }
+
+ public T getContext()
+ {
+ return instance;
+ }
+
+ public String getContextName()
+ {
+ return names.get(0);
+ }
+}
Added: projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentBeanMetaDataFactory.java
===================================================================
--- projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentBeanMetaDataFactory.java (rev 0)
+++ projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentBeanMetaDataFactory.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -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.component.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);
+}
Added: projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentFactory.java
===================================================================
--- projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentFactory.java (rev 0)
+++ projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentFactory.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,69 @@
+/*
+ * 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.component.spi;
+
+
+/**
+ * A factory for creating a collection of related mc beans based on a
+ * template of BeanMetaData[] from a BeanMetaDataFactory.
+ *
+ * @param <T> the instance type
+ * @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/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentInstance.java
===================================================================
--- projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentInstance.java (rev 0)
+++ projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentInstance.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,63 @@
+/*
+ * 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.component.spi;
+
+import java.util.List;
+
+/**
+ * The component context instance. This is the bean that acts as the container
+ * for the component bean instances.
+ *
+ * @param <T> the context type
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface ComponentInstance<T>
+{
+ /**
+ * Get the name of the bean for the component context instance.
+ *
+ * @return the context name
+ */
+ public String getContextName();
+
+ /**
+ * Get the component bean names.
+ *
+ * @return the component names
+ */
+ public List<String> getComponentNames();
+
+ /**
+ * Get the id associated with this component.
+ *
+ * @return the component id
+ */
+ public long getComponentID();
+
+ /**
+ * Get the component context instance.
+ *
+ * @return the context
+ */
+ public T getContext();
+}
Added: projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentNameBuilder.java
===================================================================
--- projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentNameBuilder.java (rev 0)
+++ projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentNameBuilder.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,50 @@
+/*
+ * 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.component.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 for any parsing error
+ */
+ public long getComponentID(String name) throws NumberFormatException;
+}
Added: projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentVisitor.java
===================================================================
--- projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentVisitor.java (rev 0)
+++ projects/component-factory/trunk/src/main/java/org/jboss/component/spi/ComponentVisitor.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,44 @@
+/*
+ * 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.component.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);
+}
Copied: projects/component-factory/trunk/src/test (from rev 85991, projects/component-factory/trunk/src/tests)
Added: projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BaseContext.java
===================================================================
--- projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BaseContext.java (rev 0)
+++ projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BaseContext.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,88 @@
+/*
+ * 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.component.support.container;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @param <B> the bean type
+ * @param <C> the container type
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class BaseContext <B, C extends BeanContainer<B>>
+ implements BeanContext<C>
+{
+ protected static Logger log = Logger.getLogger(BaseContext.class);
+ protected C container;
+ protected B bean;
+
+ protected List<Object> interceptorInstances = new ArrayList<Object>();
+
+ public BaseContext(C container)
+ {
+ this.container = container;
+ log.info("ctor, container: "+container);
+ }
+
+ public C getContainer()
+ {
+ return container;
+ }
+
+ public B getInstance()
+ {
+ return bean;
+ }
+ public void setInstance(B bean)
+ {
+ this.bean = bean;
+ log.info("setInstance, bean: "+bean);
+ }
+
+ public List<Object> getInterceptors()
+ {
+ return interceptorInstances;
+ }
+
+ public void initialiseInterceptorInstances()
+ {
+ }
+ public void addInterceptor(Object interceptor)
+ {
+ interceptorInstances.add(interceptor);
+ log.info("addInterceptor, "+interceptor);
+ }
+ public void removeInterceptor(Object interceptor)
+ {
+ interceptorInstances.remove(interceptor);
+ log.info("removeInterceptor, "+interceptor);
+ }
+ public void remove()
+ {
+ // TODO Auto-generated method stub
+
+ }
+}
Added: projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/Bean1Type.java
===================================================================
--- projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/Bean1Type.java (rev 0)
+++ projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/Bean1Type.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.component.support.container;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 71333 $
+ */
+public class Bean1Type
+{
+ private static Logger log = Logger.getLogger(Bean1Type.class);
+ private String prop1;
+
+ public Bean1Type()
+ {
+ log.debug("Bean1Type.ctor, this="+this);
+ }
+
+ public String getProp1()
+ {
+ return prop1;
+ }
+ public void setProp1(String prop1)
+ {
+ this.prop1 = prop1;
+ }
+}
Added: projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/Bean2Type.java
===================================================================
--- projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/Bean2Type.java (rev 0)
+++ projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/Bean2Type.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.component.support.container;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 71025 $
+ */
+public class Bean2Type
+{
+ private Bean1Type bean1;
+
+ public Bean1Type getBean1()
+ {
+ return bean1;
+ }
+
+ public void setBean1(Bean1Type bean1)
+ {
+ this.bean1 = bean1;
+ }
+}
Added: projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanContainer.java
===================================================================
--- projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanContainer.java (rev 0)
+++ projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanContainer.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.component.support.container;
+
+/**
+ * @param <T> the type
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 71195 $
+ */
+public class BeanContainer<T>
+{
+ private BeanPool<T> pool;
+
+
+ public BeanPool<T> getPool()
+ {
+ return pool;
+ }
+ public void setPool(BeanPool<T> pool)
+ {
+ this.pool = pool;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T getBean()
+ throws Throwable
+ {
+ T bean = pool.createBean();
+ return bean;
+ }
+ public void destroyBean(T bean)
+ throws Throwable
+ {
+ pool.destroyBean(bean);
+ }
+}
Added: projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanContext.java
===================================================================
--- projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanContext.java (rev 0)
+++ projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanContext.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,40 @@
+/*
+ * 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.component.support.container;
+
+/**
+ * @param <C> the container type
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public interface BeanContext<C extends BeanContainer<?>>
+{
+ Object getInstance();
+
+ C getContainer();
+
+ void initialiseInterceptorInstances();
+
+ void remove();
+
+ //EJBContext getEJBContext();
+}
Added: projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanContextFactory.java
===================================================================
--- projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanContextFactory.java (rev 0)
+++ projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanContextFactory.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,210 @@
+/*
+ * 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.component.support.container;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.beans.info.spi.BeanAccessMode;
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.component.spi.ComponentBeanMetaDataFactory;
+import org.jboss.component.spi.ComponentNameBuilder;
+import org.jboss.component.spi.ComponentVisitor;
+import org.jboss.kernel.spi.config.KernelConfigurator;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
+import org.jboss.logging.Logger;
+
+
+/**
+ * @param <T> the type
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class BeanContextFactory<T> implements ComponentBeanMetaDataFactory, KernelControllerContextAware
+{
+ private static final Logger log = Logger.getLogger(BeanContextFactory.class);
+ private String beanClass;
+ private org.jboss.test.component.support.container.BeanContainer<T> container;
+ private Set<org.jboss.test.component.support.container.TestInjectionMetaData> beanInjectionMD;
+ private KernelConfigurator configurator;
+ private Map<String, Set<org.jboss.test.component.support.container.TestInjectionMetaData>> interceptorInjectionMD =
+ new HashMap<String, Set<org.jboss.test.component.support.container.TestInjectionMetaData>>();
+ private List<String> interceptorNames;
+
+ public String getBeanClass()
+ {
+ return beanClass;
+ }
+ public void setBeanClass(String beanClass)
+ {
+ this.beanClass = beanClass;
+ }
+ public org.jboss.test.component.support.container.BeanContainer<T> getContainer()
+ {
+ return container;
+ }
+ public void setContainer(org.jboss.test.component.support.container.BeanContainer<T> container)
+ {
+ this.container = container;
+ }
+ public Set<TestInjectionMetaData> getBeanInjectionMD()
+ {
+ return beanInjectionMD;
+ }
+ public void setBeanInjectionMD(Set<TestInjectionMetaData> beanInjectionMD)
+ {
+ this.beanInjectionMD = beanInjectionMD;
+ }
+ public Map<String, Set<TestInjectionMetaData>> getInterceptorInjectionMD()
+ {
+ return interceptorInjectionMD;
+ }
+ public void setInterceptorInjectionMD(
+ Map<String, Set<TestInjectionMetaData>> interceptorInjectionMD)
+ {
+ this.interceptorInjectionMD = interceptorInjectionMD;
+ }
+ public List<String> getInterceptorNames()
+ {
+ return interceptorNames;
+ }
+ public void setInterceptorNames(List<String> interceptorNames)
+ {
+ this.interceptorNames = interceptorNames;
+ }
+
+ public void setKernelControllerContext(KernelControllerContext context)
+ throws Exception
+ {
+ if(context != null)
+ {
+ configurator = context.getKernel().getConfigurator();
+ }
+ }
+ public void unsetKernelControllerContext(KernelControllerContext context)
+ throws Exception
+ {
+ configurator = null;
+ }
+
+ /**
+ * Create the beans that make up the bean component
+ */
+ 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 = 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 = 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);
+
+ // Create the instance bean
+ BeanMetaDataBuilder beanBuilder = BeanMetaDataBuilder.createBuilder(beanName, beanClass);
+ beanBuilder.setAccessMode(BeanAccessMode.ALL);
+ // For every injection target get the associated property
+ if(beanInjectionMD != null)
+ {
+ addDependencyInjection(beanClass, beanInjectionMD, beanBuilder);
+ }
+ beans.add(beanBuilder.getBeanMetaData());
+
+ // Create the interceptors
+ int count = interceptorNames != null ? interceptorNames.size() : 0;
+ for(int n = 0; n < count; n ++)
+ {
+ String iCompName = "Interceptor:"+n;
+ String iname = nameBuilder.buildName(baseName, iCompName, compID);
+ String iclass = interceptorNames.get(n);
+ BeanMetaDataBuilder ibuilder = BeanMetaDataBuilder.createBuilder(iname, iclass);
+ ibuilder.addInstallWithThis("addInterceptor", contextName);
+ ibuilder.addUninstallWithThis("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);
+ BeanMetaData interceptor = ibuilder.getBeanMetaData();
+ beans.add(interceptor);
+ }
+ }
+ catch(Throwable t)
+ {
+ log.error("Failed to create component beans", t);
+ throw new RuntimeException(t);
+ }
+ log.info("getBeans returning: "+beans);
+ return beans;
+ }
+
+ private void addDependencyInjection(String clazzName,
+ Set<TestInjectionMetaData> injectMDs,
+ BeanMetaDataBuilder beanBuilder)
+ throws Throwable
+ {
+ ClassLoader loader = getClass().getClassLoader();
+ BeanInfo beanInfo = configurator.getBeanInfo(clazzName, loader);
+ for(TestInjectionMetaData injectMD : injectMDs)
+ {
+ if(injectMD.getInjectionTargets() != null)
+ {
+ for(TestInjectionTargetMetaData targetMD : injectMD.getInjectionTargets())
+ {
+ ValueMetaData injectValue = beanBuilder.createInject(injectMD.getResolvedJndiName());
+ String targetName = targetMD.getInjectionTargetName();
+ PropertyInfo pinfo = beanInfo.getProperty(targetName);
+ if(pinfo != null)
+ {
+ beanBuilder.addPropertyMetaData(targetName, injectValue);
+ }
+ else
+ {
+ log.warn("No property found for injection target:"+targetName+", on bean: "+beanClass);
+ }
+ }
+ }
+ }
+ }
+}
Added: projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanPool.java
===================================================================
--- projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanPool.java (rev 0)
+++ projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanPool.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,109 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.component.support.container;
+
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+import org.jboss.beans.metadata.spi.factory.BeanFactory;
+import org.jboss.logging.Logger;
+
+/**
+ *
+ * @param <T> the type
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 71916 $
+ */
+public class BeanPool<T>
+{
+ private Logger log;
+ /** The pooling policy */
+ private ArrayBlockingQueue<T> pool;
+ private boolean poolInitialized = false;
+ private BeanFactory factory;
+
+ public BeanPool()
+ {
+ this(3);
+ }
+ public BeanPool(int capacity)
+ {
+ pool = new ArrayBlockingQueue<T>(capacity);
+ }
+
+ public BeanFactory getFactory()
+ {
+ return factory;
+ }
+
+ public void setFactory(BeanFactory factory)
+ {
+ this.factory = factory;
+ }
+
+ public int size()
+ {
+ return pool.size();
+ }
+ public int remainingCapacity()
+ {
+ return pool.remainingCapacity();
+ }
+
+ @SuppressWarnings("unchecked")
+ public synchronized T createBean()
+ throws Throwable
+ {
+ if(poolInitialized == false)
+ {
+ T bean = (T) factory.createBean();
+ pool.put(bean);
+ log = Logger.getLogger("BeanPool<"+bean.getClass().getSimpleName()+">");
+ log.debug("createBean, initializing pool, remainingCapacity: "+pool.remainingCapacity());
+ int capacity = pool.remainingCapacity();
+ // Fill the pool
+ for(int n = 0; n < capacity; n ++)
+ {
+ bean = (T) factory.createBean();
+ pool.put(bean);
+ }
+ poolInitialized = true;
+ }
+ T bean = pool.poll(1, TimeUnit.SECONDS);
+ if(bean == null)
+ throw new IllegalStateException(this+" is emtpy");
+ log.debug("End createBean, size: "+pool.size()+", bean: "+bean);
+ return bean;
+ }
+ @SuppressWarnings("unchecked")
+ public void destroyBean(T bean)
+ throws Throwable
+ {
+ bean = (T) factory.createBean();
+ pool.put(bean);
+ }
+ public void releaseBean(T bean)
+ throws Throwable
+ {
+ pool.put(bean);
+ }
+}
Added: projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanUser.java
===================================================================
--- projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanUser.java (rev 0)
+++ projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/BeanUser.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.component.support.container;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 71025 $
+ */
+public class BeanUser
+{
+ private Bean1Type bean1;
+ private Bean2Type bean2;
+
+ public Bean1Type getBean1()
+ {
+ return bean1;
+ }
+ public void setBean1(Bean1Type bean1)
+ {
+ this.bean1 = bean1;
+ }
+ public Bean2Type getBean2()
+ {
+ return bean2;
+ }
+ public void setBean2(Bean2Type bean2)
+ {
+ this.bean2 = bean2;
+ }
+
+
+}
Added: projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/InstanceInterceptor.java
===================================================================
--- projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/InstanceInterceptor.java (rev 0)
+++ projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/InstanceInterceptor.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -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.component.support.container;
+
+import java.lang.reflect.Method;
+
+import org.jboss.logging.Logger;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class InstanceInterceptor
+{
+ private static Logger log = Logger.getLogger(InstanceInterceptor.class);
+ private BeanPool<BeanContext<?>> pool;
+
+ public InstanceInterceptor()
+ {
+ log.info("ctor");
+ }
+
+ public Object invoke(Object...args)
+ throws Throwable
+ {
+ BeanContext<?> ctx = pool.createBean();
+ Object bean = ctx.getInstance();
+
+ boolean discard = false;
+ Object value = null;
+
+ try
+ {
+ String name = (String) args[0];
+ Class<?>[] paramTypes = {};
+ Method m = bean.getClass().getMethod(name, paramTypes);
+ Object[] empty = {};
+ value = m.invoke(bean, empty);
+ return value;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ finally
+ {
+ if (discard)
+ pool.destroyBean(ctx);
+ else pool.releaseBean(ctx);
+ }
+ }
+}
Added: projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/TestInjectionMetaData.java
===================================================================
--- projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/TestInjectionMetaData.java (rev 0)
+++ projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/TestInjectionMetaData.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,160 @@
+/*
+ * 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.component.support.container;
+
+import java.util.Set;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class TestInjectionMetaData
+{
+ /** The mapped name */
+ private String mappedName;
+ private String resolvedJndiName;
+ private boolean ignoreDependency;
+
+ /** The injection targets */
+ private Set<TestInjectionTargetMetaData> injectionTargets;
+
+ /**
+ * Create a new ResourceInjectionMetaData.
+ */
+ public TestInjectionMetaData()
+ {
+ // For serialization
+ }
+
+ /**
+ * Get the jndiName.
+ *
+ * @return the jndiName.
+ */
+ public String getJndiName()
+ {
+ return getMappedName();
+ }
+
+ /**
+ * Set the jndiName.
+ *
+ * @param jndiName the jndiName.
+ * @throws IllegalArgumentException for a null jndiName
+ */
+ public void setJndiName(String jndiName)
+ {
+ setMappedName(jndiName);
+ }
+
+ /**
+ * Get the mappedName.
+ *
+ * @return the mappedName.
+ */
+ public String getMappedName()
+ {
+ return mappedName;
+ }
+
+ /**
+ * Set the mappedName.
+ *
+ * @param mappedName the mappedName.
+ * @throws IllegalArgumentException for a null mappedName
+ */
+ public void setMappedName(String mappedName)
+ {
+ if (mappedName == null)
+ throw new IllegalArgumentException("Null mappedName");
+ this.mappedName = mappedName;
+ }
+
+ /**
+ * An unmanaged runtime jndi name for the resource. Used by deployers to
+ * propagate resolved resource location.
+ *
+ * @return the resolved jndi name
+ */
+ public String getResolvedJndiName()
+ {
+ return resolvedJndiName;
+ }
+ public void setResolvedJndiName(String resolvedJndiName)
+ {
+ this.resolvedJndiName = resolvedJndiName;
+ }
+
+ /**
+ * Get the injectionTargets.
+ *
+ * @return the injectionTargets.
+ */
+ public Set<TestInjectionTargetMetaData> getInjectionTargets()
+ {
+ return injectionTargets;
+ }
+
+ /**
+ * Set the injectionTargets.
+ *
+ * @param injectionTargets the injectionTargets.
+ * @throws IllegalArgumentException for a null injectionTargets
+ */
+ public void setInjectionTargets(Set<TestInjectionTargetMetaData> injectionTargets)
+ {
+ if (injectionTargets == null)
+ throw new IllegalArgumentException("Null injectionTargets");
+ this.injectionTargets = injectionTargets;
+ }
+
+ /**
+ * Get the ignoreDependency.
+ *
+ * @return the ignoreDependency.
+ */
+ public boolean getIgnoreDependency()
+ {
+ return ignoreDependency;
+ }
+
+ /**
+ * Set the ignoreDependency.
+ *
+ * @param flag the ignoreDependency.
+ * @throws IllegalArgumentException for a null ignoreDependency
+ */
+ public void setIgnoreDependency(boolean flag)
+ {
+ this.ignoreDependency = flag;
+ }
+
+ /**
+ * Get whether the dependency is ignored
+ *
+ * @return true when the dependency is ignored
+ */
+ public boolean isDependencyIgnored()
+ {
+ return ignoreDependency;
+ }
+}
Added: projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/TestInjectionTargetMetaData.java
===================================================================
--- projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/TestInjectionTargetMetaData.java (rev 0)
+++ projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/TestInjectionTargetMetaData.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,127 @@
+/*
+ * 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.component.support.container;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class TestInjectionTargetMetaData
+{
+ /** The injection target class */
+ private String injectionTargetClass;
+
+ /** The injection target name */
+ private String injectionTargetName;
+
+ /**
+ * Create a new ResourceInjectionTargetMetaData.
+ */
+ public TestInjectionTargetMetaData()
+ {
+ }
+
+ /**
+ * Get the injectionTargetClass.
+ *
+ * @return the injectionTargetClass.
+ */
+ public String getInjectionTargetClass()
+ {
+ return injectionTargetClass;
+ }
+
+ /**
+ * Set the injectionTargetClass.
+ *
+ * @param injectionTargetClass the injectionTargetClass.
+ * @throws IllegalArgumentException for a null injectionTargetClass
+ */
+ //@JBossXmlNsPrefix(prefix="jee")
+ public void setInjectionTargetClass(String injectionTargetClass)
+ {
+ if (injectionTargetClass == null)
+ throw new IllegalArgumentException("Null injectionTargetClass");
+ this.injectionTargetClass = injectionTargetClass;
+ }
+
+ /**
+ * Get the injectionTargetName.
+ *
+ * @return the injectionTargetName.
+ */
+ public String getInjectionTargetName()
+ {
+ return injectionTargetName;
+ }
+
+ /**
+ * Set the injectionTargetName.
+ *
+ * @param injectionTargetName the injectionTargetName.
+ * @throws IllegalArgumentException for a null injectionTargetName
+ */
+ //@JBossXmlNsPrefix(prefix="jee")
+ public void setInjectionTargetName(String injectionTargetName)
+ {
+ if (injectionTargetName == null)
+ throw new IllegalArgumentException("Null injectionTargetName");
+ this.injectionTargetName = injectionTargetName;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + ((injectionTargetClass == null) ? 0 : injectionTargetClass.hashCode());
+ result = PRIME * result + ((injectionTargetName == null) ? 0 : injectionTargetName.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final TestInjectionTargetMetaData other = (TestInjectionTargetMetaData) obj;
+ if (injectionTargetClass == null)
+ {
+ if (other.injectionTargetClass != null)
+ return false;
+ }
+ else if (!injectionTargetClass.equals(other.injectionTargetClass))
+ return false;
+ if (injectionTargetName == null)
+ {
+ if (other.injectionTargetName != null)
+ return false;
+ }
+ else if (!injectionTargetName.equals(other.injectionTargetName))
+ return false;
+ return true;
+ }
+}
Added: projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/TestPooledBeanFactory.java
===================================================================
--- projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/TestPooledBeanFactory.java (rev 0)
+++ projects/component-factory/trunk/src/test/java/org/jboss/test/component/support/container/TestPooledBeanFactory.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.component.support.container;
+
+import org.jboss.beans.metadata.plugins.factory.GenericBeanFactory;
+import org.jboss.kernel.spi.config.KernelConfigurator;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 71105 $
+ */
+public class TestPooledBeanFactory extends GenericBeanFactory
+{
+ public TestPooledBeanFactory(KernelConfigurator configurator, int size)
+ {
+ super(configurator);
+ }
+}
Added: projects/component-factory/trunk/src/test/java/org/jboss/test/component/test/BeanContainerUsageMDTestCase.java
===================================================================
--- projects/component-factory/trunk/src/test/java/org/jboss/test/component/test/BeanContainerUsageMDTestCase.java (rev 0)
+++ projects/component-factory/trunk/src/test/java/org/jboss/test/component/test/BeanContainerUsageMDTestCase.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,352 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, 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.component.test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Test;
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
+import org.jboss.beans.metadata.plugins.AbstractParameterMetaData;
+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.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.ParameterMetaData;
+import org.jboss.beans.metadata.spi.PropertyMetaData;
+import org.jboss.beans.metadata.spi.factory.GenericBeanFactoryMetaData;
+import org.jboss.component.plugin.GenericComponentFactory;
+import org.jboss.component.spi.ComponentFactory;
+import org.jboss.component.spi.ComponentInstance;
+import org.jboss.component.spi.ComponentVisitor;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.test.component.support.container.BaseContext;
+import org.jboss.test.component.support.container.Bean1Type;
+import org.jboss.test.component.support.container.BeanContainer;
+import org.jboss.test.component.support.container.BeanContextFactory;
+import org.jboss.test.component.support.container.InstanceInterceptor;
+
+
+/**
+ * Programatic version of the BeanContainerUsageTestCase tests
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 71929 $
+ */
+public class BeanContainerUsageMDTestCase extends BeanContainerUsageTestCase
+{
+ public static Test suite()
+ {
+ return suite(BeanContainerUsageMDTestCase.class);
+ }
+
+ public BeanContainerUsageMDTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test of the ComponentFactory usecase
+ *
+ * @see {@link GenericComponentFactory}
+ * @see {@link ComponentFactory}
+ * @throws Throwable for any error
+ */
+ @SuppressWarnings("unchecked")
+ public void testComponentBeanFactory()
+ throws Throwable
+ {
+ bootstrap();
+ // Lookup the ComponentFactory implementation
+ ComponentFactory<BaseContext<Bean1Type, BeanContainer<Bean1Type>>> factory =
+ (ComponentFactory<BaseContext<Bean1Type, BeanContainer<Bean1Type>>>) getBean("ComponentBeanFactory");
+ getLog().info("ComponentBeanFactory bean: "+factory);
+ // Create a component instance
+ ComponentInstance<BaseContext<Bean1Type, BeanContainer<Bean1Type>>> contextInstance =
+ factory.createComponents("ComponentBeanFactory");
+ // Validate the component bean names
+ List<String> beanNames = contextInstance.getComponentNames();
+ getLog().info("createComponents(ComponentBeanFactory): "+beanNames);
+
+ HashSet<String> expectedBeanNames = new HashSet<String>();
+ expectedBeanNames.add("ComponentBeanFactory at ContextFactory#1");
+ expectedBeanNames.add("ComponentBeanFactory at BeanInstance#1");
+ expectedBeanNames.add("ComponentBeanFactory at Interceptor:0#1");
+ assertEquals(expectedBeanNames, new HashSet<String>(beanNames));
+ long compID = contextInstance.getComponentID();
+ assertEquals(1, compID);
+ BaseContext<Bean1Type, BeanContainer<Bean1Type>> context = contextInstance.getContext();
+ assertNotNull(context);
+ String contextName = contextInstance.getContextName();
+ assertEquals("ComponentBeanFactory at ContextFactory#1", contextName);
+ Object contextBean = getBean("ComponentBeanFactory at ContextFactory#1");
+ assertTrue(contextBean == context);
+ Bean1Type bean1 = (Bean1Type) getBean("ComponentBeanFactory at BeanInstance#1");
+ assertTrue(bean1 == context.getInstance());
+
+ Object interceptor = getBean("ComponentBeanFactory at Interceptor:0#1");
+ assertNotNull(interceptor);
+ List expectedInterceptors = new ArrayList();
+ expectedInterceptors.add(interceptor);
+ List interceptors = context.getInterceptors();
+ assertEquals(interceptors, expectedInterceptors);
+
+ factory.destroyComponents(contextInstance);
+ expectedBeanNames.clear();
+ expectedBeanNames.add("ComponentBeanFactory");
+ // Only the ComponentBeanFactory should exist
+ assertBeansExist(expectedBeanNames);
+
+ // Create a second component instance
+ ComponentInstance<BaseContext<Bean1Type, BeanContainer<Bean1Type>>> contextInstance2 =
+ factory.createComponents("ComponentBeanFactory");
+ // Validate the component bean names
+ List<String> beanNames2 = contextInstance2.getComponentNames();
+ getLog().info("createComponents(ComponentBeanFactory): "+beanNames2);
+ expectedBeanNames = new HashSet<String>();
+ expectedBeanNames.add("ComponentBeanFactory at ContextFactory#2");
+ expectedBeanNames.add("ComponentBeanFactory at BeanInstance#2");
+ expectedBeanNames.add("ComponentBeanFactory at Interceptor:0#2");
+ assertEquals(expectedBeanNames, new HashSet<String>(beanNames2));
+ compID = contextInstance2.getComponentID();
+ assertEquals(2, compID);
+ BaseContext<Bean1Type, BeanContainer<Bean1Type>> context2 = contextInstance2.getContext();
+ assertNotNull(context2);
+ String contextName2 = contextInstance2.getContextName();
+ assertEquals("ComponentBeanFactory at ContextFactory#2", contextName2);
+ Object contextBean2 = getBean("ComponentBeanFactory at ContextFactory#2");
+ assertTrue(contextBean2 == context2);
+ Bean1Type bean2 = (Bean1Type) getBean("ComponentBeanFactory at BeanInstance#2");
+ assertTrue(bean2 == context2.getInstance());
+ assertTrue(bean2 != bean1);
+
+ Object interceptor2 = getBean("ComponentBeanFactory at Interceptor:0#2");
+ assertNotNull(interceptor2);
+ List expectedInterceptors2 = new ArrayList();
+ expectedInterceptors2.add(interceptor2);
+ List interceptors2 = context2.getInterceptors();
+ assertEquals(interceptors2, expectedInterceptors2);
+
+ factory.destroyComponents(contextInstance2);
+ expectedBeanNames.clear();
+ expectedBeanNames.add("ComponentBeanFactory");
+ // Only the ComponentBeanFactory should exist
+ assertBeansExist(expectedBeanNames);
+
+ shutdown();
+ }
+
+ /*
+ <beanfactory name="Bean1TypeFactory" class="org.jboss.test.kernel.deployment.support.container.Bean1Type"/>
+ <bean name="Bean1TypePool" class="org.jboss.test.kernel.deployment.support.container.BeanPool">
+ <property name="factory"><inject bean="Bean1TypeFactory"/></property>
+ </bean>
+ <bean name="BeanContainer1Type" class="org.jboss.test.kernel.deployment.support.container.BeanContainer">
+ <property name="pool"><inject bean="Bean1TypePool"/></property>
+ </bean>
+ <beanfactory name="Bean2TypeFactory" class="org.jboss.test.kernel.deployment.support.container.Bean2Type">
+ <property name="bean1"><value-factory bean="Bean1TypePool" method="createBean" /></property>
+ </beanfactory>
+ <bean name="Bean2TypePool" class="org.jboss.test.kernel.deployment.support.container.BeanPool">
+ <property name="factory"><inject bean="Bean2TypeFactory"/></property>
+ </bean>
+ <bean name="BeanContainer2Type" class="org.jboss.test.kernel.deployment.support.container.BeanContainer">
+ <property name="pool"><inject bean="Bean2TypePool"/></property>
+ </bean>
+ */
+ protected KernelDeployment getDeploymentForDependencyInjectionOfBean()
+ {
+ AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+ deployment.setName("DependencyInjectionOfBean");
+ ArrayList<BeanMetaDataFactory> beanFactories = new ArrayList<BeanMetaDataFactory>();
+ // Bean1TypeFactory
+ GenericBeanFactoryMetaData Bean1TypeFactory = new GenericBeanFactoryMetaData("Bean1TypeFactory",
+ "org.jboss.test.component.support.container.Bean1Type");
+ beanFactories.add(Bean1TypeFactory);
+ // Bean1TypePool
+ AbstractBeanMetaData Bean1TypePool = new AbstractBeanMetaData("Bean1TypePool",
+ "org.jboss.test.component.support.container.BeanPool");
+ Set<PropertyMetaData> Bean1TypePool_propertys = new HashSet<PropertyMetaData>();
+ Bean1TypePool_propertys.add(new AbstractPropertyMetaData("factory",
+ new AbstractDependencyValueMetaData("Bean1TypeFactory")));
+ Bean1TypePool.setProperties(Bean1TypePool_propertys);
+ beanFactories.add(Bean1TypePool);
+ // BeanContainer1Type
+ AbstractBeanMetaData BeanContainer1Type = new AbstractBeanMetaData("BeanContainer1Type",
+ "org.jboss.test.component.support.container.BeanContainer");
+ Set<PropertyMetaData> BeanContainer1Type_propertys = new HashSet<PropertyMetaData>();
+ BeanContainer1Type_propertys.add(new AbstractPropertyMetaData("pool",
+ new AbstractDependencyValueMetaData("Bean1TypePool")));
+ BeanContainer1Type.setProperties(BeanContainer1Type_propertys);
+ beanFactories.add(BeanContainer1Type);
+
+ // Bean2TypeFactory
+ GenericBeanFactoryMetaData Bean2TypeFactory = new GenericBeanFactoryMetaData("Bean2TypeFactory",
+ "org.jboss.test.component.support.container.Bean2Type");
+ Set<PropertyMetaData> Bean2TypeFactory_propertys = new HashSet<PropertyMetaData>();
+ AbstractValueFactoryMetaData bean1CreateMethod = new AbstractValueFactoryMetaData("Bean1TypePool", "createBean");
+ Bean2TypeFactory_propertys.add(new AbstractPropertyMetaData("bean1", bean1CreateMethod));
+ Bean2TypeFactory.setProperties(Bean2TypeFactory_propertys);
+ beanFactories.add(Bean2TypeFactory);
+ // Bean2TypePool
+ AbstractBeanMetaData Bean2TypePool = new AbstractBeanMetaData("Bean2TypePool",
+ "org.jboss.test.component.support.container.BeanPool");
+ Set<PropertyMetaData> Bean2TypePool_propertys = new HashSet<PropertyMetaData>();
+ Bean2TypePool_propertys.add(new AbstractPropertyMetaData("factory",
+ new AbstractDependencyValueMetaData("Bean2TypeFactory")));
+ Bean2TypePool.setProperties(Bean2TypePool_propertys);
+ beanFactories.add(Bean2TypePool);
+ // BeanContainer2Type
+ AbstractBeanMetaData BeanContainer2Type = new AbstractBeanMetaData("BeanContainer2Type",
+ "org.jboss.test.component.support.container.BeanContainer");
+ Set<PropertyMetaData> BeanContainer2Type_propertys = new HashSet<PropertyMetaData>();
+ BeanContainer2Type_propertys.add(new AbstractPropertyMetaData("pool",
+ new AbstractDependencyValueMetaData("Bean2TypePool")));
+ BeanContainer2Type.setProperties(BeanContainer2Type_propertys);
+ beanFactories.add(BeanContainer2Type);
+
+ deployment.setBeanFactories(beanFactories);
+
+ return deployment;
+ }
+ /*
+ <beanfactory name="Bean1TypeFactory" class="org.jboss.test.component.support.container.Bean1Type"/>
+ <bean name="Bean1TypePool" class="org.jboss.test.component.support.container.BeanPool">
+ <constructor>
+ <parameter>3</parameter>
+ </constructor>
+ <property name="factory"><inject bean="Bean1TypeFactory"/></property>
+ </bean>
+ <bean name="BeanContainer1Type" class="org.jboss.test.component.support.container.BeanContainer">
+ <property name="pool"><inject bean="Bean1TypePool"/></property>
+ </bean>
+ <beanfactory name="Bean2TypeFactory" class="org.jboss.test.component.support.container.Bean2Type">
+ <property name="bean1"><value-factory bean="Bean1TypePool" method="createBean" /></property>
+ </beanfactory>
+ <bean name="Bean2TypePool" class="org.jboss.test.component.support.container.BeanPool">
+ <constructor>
+ <parameter>4</parameter>
+ </constructor>
+ <property name="factory"><inject bean="Bean2TypeFactory"/></property>
+ </bean>
+ <bean name="BeanContainer2Type" class="org.jboss.test.component.support.container.BeanContainer">
+ <property name="pool"><inject bean="Bean2TypePool"/></property>
+ </bean>
+ */
+ protected KernelDeployment getDeploymentForDependencyInjectionOfBeanWithMismatchedPoolSizes()
+ {
+ KernelDeployment deployment = getDeploymentForDependencyInjectionOfBean();
+ // Update the pool ctors
+ List<BeanMetaDataFactory> beanFactories = deployment.getBeanFactories();
+ for(BeanMetaDataFactory bmdf : beanFactories)
+ {
+ if(bmdf instanceof AbstractBeanMetaData)
+ {
+ AbstractBeanMetaData abmd = (AbstractBeanMetaData) bmdf;
+ if(abmd.getName().equals("Bean1TypePool"))
+ {
+ AbstractConstructorMetaData ctor = new AbstractConstructorMetaData();
+ ArrayList<ParameterMetaData> params = new ArrayList<ParameterMetaData>();
+ params.add(new AbstractParameterMetaData(int.class.getName(), "3"));
+ ctor.setParameters(params);
+ abmd.setConstructor(ctor);
+ }
+ else if(abmd.getName().equals("Bean2TypePool"))
+ {
+ AbstractConstructorMetaData ctor = new AbstractConstructorMetaData();
+ ArrayList<ParameterMetaData> params = new ArrayList<ParameterMetaData>();
+ params.add(new AbstractParameterMetaData(int.class.getName(), "4"));
+ ctor.setParameters(params);
+ abmd.setConstructor(ctor);
+ }
+ }
+ }
+ return deployment;
+ }
+ /**
+ * MetaData version of testComponentBeanFactory
+ *
+ * @return the kernel deployment
+ */
+ @SuppressWarnings("unchecked")
+ protected KernelDeployment getDeploymentForComponentBeanFactory()
+ {
+ AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+ deployment.setName("ComponentBeanFactory");
+ ArrayList<BeanMetaDataFactory> beanFactories = new ArrayList<BeanMetaDataFactory>();
+ // Bean context factory for Bean1Type
+ BeanContainer<Bean1Type> container = new BeanContainer<Bean1Type>();
+ BeanContextFactory<Bean1Type> contextFactory = new BeanContextFactory<Bean1Type>();
+ contextFactory.setBeanClass(Bean1Type.class.getName());
+ contextFactory.setContainer(container);
+ String[] interceptorNames = {InstanceInterceptor.class.getName()};
+ contextFactory.setInterceptorNames(Arrays.asList(interceptorNames));
+ /*
+ BeanMetaDataFactory contextFactoryMD = installBeanInstance("ComponentBeanFactory", contextFactory);
+ beanFactories.add(contextFactoryMD);
+ */
+ ComponentVisitor visitor = null;
+ GenericComponentFactory componentFactory = new GenericComponentFactory(contextFactory, visitor);
+ BeanMetaDataFactory componentFactoryMD = installBeanInstance("ComponentBeanFactory", componentFactory);
+ beanFactories.add(componentFactoryMD);
+ deployment.setBeanFactories(beanFactories);
+
+ return deployment;
+ }
+
+ protected BeanMetaDataFactory installBeanInstance(String name, Object bean)
+ {
+ AbstractBeanMetaData beanMD = new AbstractBeanMetaData(name, bean.getClass().getName());
+ beanMD.setConstructor(new AlreadyInstantiated(bean));
+ return beanMD;
+ }
+
+ public static class AlreadyInstantiated extends AbstractConstructorMetaData
+ {
+ private static final long serialVersionUID = 1L;
+
+ private Object bean;
+
+ public class Factory
+ {
+
+ public Object create()
+ {
+ return bean;
+ }
+ }
+
+ public AlreadyInstantiated(Object bean)
+ {
+ this.bean = bean;
+ this.setFactory(new AbstractValueMetaData(new Factory()));
+ this.setFactoryClass(Factory.class.getName());
+ this.setFactoryMethod("create");
+ }
+ }
+}
Added: projects/component-factory/trunk/src/test/java/org/jboss/test/component/test/BeanContainerUsageTestCase.java
===================================================================
--- projects/component-factory/trunk/src/test/java/org/jboss/test/component/test/BeanContainerUsageTestCase.java (rev 0)
+++ projects/component-factory/trunk/src/test/java/org/jboss/test/component/test/BeanContainerUsageTestCase.java 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,219 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.component.test;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.Test;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.ControllerStateModel;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.test.component.support.container.Bean1Type;
+import org.jboss.test.component.support.container.Bean2Type;
+import org.jboss.test.component.support.container.BeanContainer;
+import org.jboss.test.component.support.container.BeanPool;
+import org.jboss.test.kernel.AbstractKernelTest;
+
+/**
+ * Bean Container Test Case.
+ *
+ * @author <a href="scott.stark at jboss.com">Scott Stark</a>
+ * @version $Revision: 71929 $
+ */
+public class BeanContainerUsageTestCase extends AbstractKernelTest
+{
+ private Kernel kernel;
+ private BasicXMLDeployer deployer;
+
+ public static Test suite()
+ {
+ return suite(BeanContainerUsageTestCase.class);
+ }
+
+ public BeanContainerUsageTestCase(String name)
+ {
+ super(name);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testDependencyInjectionOfBean() throws Throwable
+ {
+ bootstrap();
+ // ???? BeanContainer<Bean1Type> container1 = (BeanContainer<Bean1Type>) getBean("BeanContainer1Type");
+ getBean("BeanContainer1Type");
+ BeanPool<Bean1Type> pool1 = (BeanPool<Bean1Type>) getBean("Bean1TypePool");
+ BeanContainer<Bean2Type> container2 = (BeanContainer<Bean2Type>) getBean("BeanContainer2Type");
+ Bean2Type bean21 = container2.getBean();
+ getLog().debug("bean21: "+bean21);
+ Bean1Type bean11 = bean21.getBean1();
+ assertEquals(0, pool1.size());
+ getLog().debug("bean11: "+bean11);
+ assertNotNull(bean11);
+ // Create another Bean2Type instance
+ Bean2Type bean22 = container2.getBean();
+ getLog().debug("bean22: "+bean22);
+ assertTrue(bean22 != bean21);
+ // The injected bean should not be the same as injected into bean21
+ Bean1Type bean12 = bean22.getBean1();
+ getLog().debug("bean12: "+bean12);
+ assertNotNull(bean12);
+ assertTrue(bean12 != bean11);
+
+ // Create another bean 2 type, should fail
+ Bean2Type bean23 = container2.getBean();
+ getLog().debug("bean23: "+bean23);
+ Bean1Type bean13Injected = bean23.getBean1();
+ getLog().debug("bean13Injected: "+bean13Injected);
+ assertNotNull(bean13Injected);
+ deployer.shutdown();
+ }
+ @SuppressWarnings("unchecked")
+ public void testDependencyInjectionOfBeanWithMismatchedPoolSizes()
+ throws Throwable
+ {
+ bootstrap();
+ BeanContainer<Bean2Type> container2 = (BeanContainer<Bean2Type>) getBean("BeanContainer2Type");
+ try
+ {
+ fail("Should not have been able to create a Bean2Type: " + container2.getBean());
+ }
+ catch(IllegalStateException e)
+ {
+ getLog().info("Saw expected IllegalStateException");
+ }
+ deployer.shutdown();
+ }
+
+ /**
+ * There is no xml version of ?
+ * @return ???
+ */
+ protected KernelDeployment getDeploymentForDependencyInjectionOfBean()
+ {
+ return null;
+ }
+
+ /**
+ * Either deploy a test specific xml descriptor, or obtain a test
+ * specific KernelDeployment by looking for a method
+ * "getDeploymentFor"+ getName().substring(4);
+ */
+ protected Kernel bootstrap() throws Throwable
+ {
+ kernel = super.bootstrap();
+ deployer = new BasicXMLDeployer(kernel, ControllerMode.AUTOMATIC);
+ String testName = "getDeploymentFor"+ getName().substring(4);
+ KernelDeployment deployment = null;
+ try
+ {
+ Method getDeployment = getClass().getDeclaredMethod(testName);
+ deployment = (KernelDeployment) getDeployment.invoke(this);
+ }
+ catch(NoSuchMethodException e)
+ {
+ getLog().debug("Ignoring: "+e);
+ }
+
+ if(deployment == null)
+ {
+ String xmlName = getClass().getName() + "_" + super.getName();
+ xmlName = xmlName.replace('.', '/') + ".xml";
+ URL url = getClass().getClassLoader().getResource(xmlName);
+ if (url != null)
+ deployer.deploy(url);
+ else
+ getLog().debug("No test specific deployment " + xmlName);
+ }
+ else
+ {
+ deployer.deploy(deployment);
+ }
+ deployer.validate();
+ return kernel;
+ }
+ protected void shutdown()
+ {
+ deployer.shutdown();
+ }
+ protected void assertNoBeansExist()
+ {
+ KernelController controller = kernel.getController();
+ ControllerStateModel states = controller.getStates();
+ int beanCount = 0;
+ for(ControllerState s : states)
+ {
+ Set<ControllerContext> ctxs = controller.getContextsByState(s);
+ beanCount += ctxs.size();
+ }
+ assertEquals(0, beanCount);
+ }
+ protected void assertBeansExist(Set<String> names)
+ {
+ Set<String> unexpectedBeanNames = new HashSet<String>();
+ KernelController controller = kernel.getController();
+ ControllerStateModel states = controller.getStates();
+ for(ControllerState s : states)
+ {
+ Set<ControllerContext> ctxs = controller.getContextsByState(s);
+ for(ControllerContext ctx : ctxs)
+ {
+ String name = ctx.getName().toString();
+ if(names.contains(name) == false)
+ unexpectedBeanNames.add(name);
+ }
+ }
+ assertEquals(Collections.<String>emptySet(), unexpectedBeanNames);
+ }
+ protected Object getBean(final Object name)
+ {
+ KernelControllerContext context = getControllerContext(name, ControllerState.INSTALLED);
+ return context.getTarget();
+ }
+ protected KernelControllerContext getControllerContext(final Object name, final ControllerState state)
+ {
+ KernelController controller = kernel.getController();
+ KernelControllerContext context = (KernelControllerContext) controller.getContext(name, state);
+ if (context == null)
+ {
+ getLog().error("Bean not found " + name + " at state " + state);
+ ControllerStateModel states = controller.getStates();
+ for(ControllerState s : states)
+ {
+ getLog().info(s+": "+controller.getContextsByState(s));
+ }
+ throw new IllegalStateException("Bean not found " + name + " at state " + state);
+ }
+ return context;
+ }
+
+}
Added: projects/component-factory/trunk/src/test/resources/org/jboss/test/component/test/BeanContainerUsageTestCase_testDependencyInjectionOfBean.xml
===================================================================
--- projects/component-factory/trunk/src/test/resources/org/jboss/test/component/test/BeanContainerUsageTestCase_testDependencyInjectionOfBean.xml (rev 0)
+++ projects/component-factory/trunk/src/test/resources/org/jboss/test/component/test/BeanContainerUsageTestCase_testDependencyInjectionOfBean.xml 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <beanfactory name="Bean1TypeFactory" class="org.jboss.test.component.support.container.Bean1Type"/>
+ <bean name="Bean1TypePool" class="org.jboss.test.component.support.container.BeanPool">
+ <property name="factory"><inject bean="Bean1TypeFactory"/></property>
+ </bean>
+ <bean name="BeanContainer1Type" class="org.jboss.test.component.support.container.BeanContainer">
+ <property name="pool"><inject bean="Bean1TypePool"/></property>
+ </bean>
+ <beanfactory name="Bean2TypeFactory" class="org.jboss.test.component.support.container.Bean2Type">
+ <property name="bean1"><value-factory bean="Bean1TypePool" method="createBean" /></property>
+ </beanfactory>
+ <bean name="Bean2TypePool" class="org.jboss.test.component.support.container.BeanPool">
+ <property name="factory"><inject bean="Bean2TypeFactory"/></property>
+ </bean>
+ <bean name="BeanContainer2Type" class="org.jboss.test.component.support.container.BeanContainer">
+ <property name="pool"><inject bean="Bean2TypePool"/></property>
+ </bean>
+
+</deployment>
Added: projects/component-factory/trunk/src/test/resources/org/jboss/test/component/test/BeanContainerUsageTestCase_testDependencyInjectionOfBeanWithMismatchedPoolSizes.xml
===================================================================
--- projects/component-factory/trunk/src/test/resources/org/jboss/test/component/test/BeanContainerUsageTestCase_testDependencyInjectionOfBeanWithMismatchedPoolSizes.xml (rev 0)
+++ projects/component-factory/trunk/src/test/resources/org/jboss/test/component/test/BeanContainerUsageTestCase_testDependencyInjectionOfBeanWithMismatchedPoolSizes.xml 2009-03-17 16:21:17 UTC (rev 86002)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <beanfactory name="Bean1TypeFactory" class="org.jboss.test.component.support.container.Bean1Type"/>
+ <bean name="Bean1TypePool" class="org.jboss.test.component.support.container.BeanPool">
+ <constructor>
+ <parameter>3</parameter>
+ </constructor>
+ <property name="factory"><inject bean="Bean1TypeFactory"/></property>
+ </bean>
+ <bean name="BeanContainer1Type" class="org.jboss.test.component.support.container.BeanContainer">
+ <property name="pool"><inject bean="Bean1TypePool"/></property>
+ </bean>
+ <beanfactory name="Bean2TypeFactory" class="org.jboss.test.component.support.container.Bean2Type">
+ <property name="bean1"><value-factory bean="Bean1TypePool" method="createBean" /></property>
+ </beanfactory>
+ <bean name="Bean2TypePool" class="org.jboss.test.component.support.container.BeanPool">
+ <constructor>
+ <parameter>4</parameter>
+ </constructor>
+ <property name="factory"><inject bean="Bean2TypeFactory"/></property>
+ </bean>
+ <bean name="BeanContainer2Type" class="org.jboss.test.component.support.container.BeanContainer">
+ <property name="pool"><inject bean="Bean2TypePool"/></property>
+ </bean>
+
+</deployment>
More information about the jboss-cvs-commits
mailing list