[Design the new POJO MicroContainer] - Re: GenericBeanFactory and install methods (Repost)
by scott.stark@jboss.org
Which has now expanded to:
| /**
| * Factory for the BeanMetaData describing component instances.
| * @author Scott.Stark(a)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);
| }
|
| /**
| * A factory for creating a collection of related mc beans based on a
| * template of BeanMetaData[] from a BeanMetaDataFactory.
| *
| * @author Scott.Stark(a)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;
| }
|
| /**
| * The component context instance. This is the bean that acts as the container
| * for the component bean instances.
| *
| * @author Scott.Stark(a)jboss.org
| * @version $Revision:$
| */
| public interface ComponentInstance<T>
| {
| /**
| * Get the name of the bean for the component context instance
| * @return
| */
| public String getContextName();
| /**
| * Get the component bean names
| * @return
| */
| public List<String> getComponentNames();
| /**
| * Get the id associated with this component
| * @return
| */
| public long getComponentID();
| /**
| * Get the component context instance
| * @return
| */
| public T getContext();
|
| }
|
| /**
| * Abstraction for building/parsing component names
| *
| * @author Scott.Stark(a)jboss.org
| * @version $Revision:$
| */
| public interface ComponentNameBuilder
| {
| /**
| * Create a globally unique mc bean name
| * @param baseName - base name used to derive unique bean name
| * @param compName - the component name used to derive unique bean name
| * @param compID - component id used to derive unique bean name
| * @return the unique mc bean name
| */
| public String buildName(String baseName, String compName, long compID);
| /**
| * Parse a mc bean name for the component id
| * @param name - the mc bean name
| * @return the component id
| * @throws NumberFormatException
| */
| public long getComponentID(String name) throws NumberFormatException;
| }
|
| /**
| * A component bean factory visitor plugin that allows for extension of the
| * bean metadata produced by the factory.
| *
| * @author Scott.Stark(a)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);
|
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4142624#4142624
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4142624
18 years
[Design the new POJO MicroContainer] - Indirect dependency names
by scott.stark@jboss.org
One issue I have with creating the component factory notion pattern is that the factory wants to describe relationships between components with logical names that have to be transformed into unique names for the mc beans that are installed when the factory is asked to create the component beans.
For example, and ejb component factory would have BeanMetaData for the interceptors that included an
| AbstractInstallMetaData install = new AbstractInstallMetaData()
| install.setBean("BeanContext");
| install.setMethodName("addInterceptor");
| ...
|
The "BeanContext" name is the logical component name portion of the bean context. When its created as an mc bean instance by the component factory, this gets transformed into a unique name using an input base name and component id number. I'm going to have to extend all of the dependency related metadata and builders to override the depends name to allow for a transformed name.
I'm wondering if we should have consistent support for a dependency name abstraction that would allow for name transformation more easily. The existing String/Object based name methods would just call the generalized version taking a DependencyName with an IdentityDependencyName implementation:
| interface DependencyName
| {
| Object getName();
| }
| class IdentityDependencyName implements DependencyName
| {
| private Object name;
| IdentityDependencyName(Object name)...
| Object getName() { return name; }
| }
|
| class AbstractInstallMetaData
| {
| private DependencyName bean;
|
| public setBean(String bean)
| {
| setBean(new IdentityDependencyName(bean));
| }
| public setBean(DependencyName bean)
| {
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4143035#4143035
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4143035
18 years