picocontainer.extras
Class BeanStyleComponentFactory
java.lang.Object
picocontainer.extras.BeanStyleComponentFactory
- All Implemented Interfaces:
- ComponentFactory
- public class BeanStyleComponentFactory
- extends Object
- implements ComponentFactory
A Component factory that works with Java Bean style components. That is, components that
have an empty constructor and zero or more setXxx methods with one argument to set dependencies.
Note that this ComponentFactory does not use IoC type 3, but rather a "loosely typed" IoC type 1.
(It's loosely typed since no interfaces need to be implemented - as the presence of setXxx
methods in the component implementation classes is enough to have these methods called).
This class is provided for convenience only, so components adhering to IoC type 1 can be used
without modification. It is however recommended to use DefaultComponentFactory
as the basis for component creation, as this leads to a better component design.
- Version:
- $Revision: 1.2 $
- Author:
- Aslak Hellesøy
Method Summary |
Object |
createComponent(Class componentType,
Class componentImplementation,
Class[] dependencies,
Object[] instanceDependencies)
Create a component. |
Class[] |
getDependencies(Class componentImplementation)
Return the types the componentImplementation component depends on.
The dependencies are resolved by looking at the types of all setXxx methods
taking one parameter. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
BeanStyleComponentFactory
public BeanStyleComponentFactory()
createComponent
public Object createComponent(Class componentType,
Class componentImplementation,
Class[] dependencies,
Object[] instanceDependencies)
throws PicoInstantiationException,
PicoIntrospectionException
- Description copied from interface:
ComponentFactory
- Create a component. Used by the internals of applicable PicoContainers
to instantiate a component.
- Specified by:
createComponent
in interface ComponentFactory
- Parameters:
componentType
- the type the component will be registered as.componentImplementation
- concrete component class.instanceDependencies
- The component instances the created component will depend on.
- Returns:
- The component
- Throws:
PicoInstantiationException
PicoIntrospectionException
getDependencies
public Class[] getDependencies(Class componentImplementation)
throws PicoIntrospectionException
- Return the types the componentImplementation component depends on.
The dependencies are resolved by looking at the types of all setXxx methods
taking one parameter.
- Specified by:
getDependencies
in interface ComponentFactory
- Parameters:
componentImplementation
-
- Returns:
- all classes that are defined in setXxx methods taking one argument.
- Throws:
PicoIntrospectionException
Copyright © 2003 Codehaus. All Rights Reserved.