|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.picocontainer.injectors.AbstractInjectionFactory
org.picocontainer.gems.adapters.DelegateAdaptorFactory
public class DelegateAdaptorFactory
Mirrored AdaptorFactory for handling delegate methods.
Constructor Summary | |
---|---|
DelegateAdaptorFactory()
Default constructor. |
Method Summary | ||
---|---|---|
|
createComponentAdapter(ComponentMonitor componentMonitor,
LifecycleStrategy lifecycleStrategy,
Properties componentProperties,
Object componentKey,
Class<T> componentImplementation,
Parameter... parameters)
Create a new component adapter based on the specified arguments. |
|
static
|
createDelegate(Class<INSTANCE> targetType,
String methodName,
Object... parameters)
Generic-friendly instantiation. |
|
static Properties |
createDelegateProprties(Object targetObject,
String methodName,
Object... parameters)
Use this static factory method as a way of creating all the necessary properties that are required by the adapter. |
Methods inherited from class org.picocontainer.injectors.AbstractInjectionFactory |
---|
accept, verify |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DelegateAdaptorFactory()
Method Detail |
---|
public <T> ComponentAdapter<T> createComponentAdapter(ComponentMonitor componentMonitor, LifecycleStrategy lifecycleStrategy, Properties componentProperties, Object componentKey, Class<T> componentImplementation, Parameter... parameters) throws PicoCompositionException
componentMonitor
- the component monitorlifecycleStrategy
- te lifecycle strategycomponentProperties
- the component propertiescomponentKey
- the key to be associated with this adapter. This
value should be returned from a call to
ComponentAdapter.getComponentKey()
on the created
adapter.componentImplementation
- the implementation class to be associated
with this adapter. This value should be returned from a call
to ComponentAdapter.getComponentImplementation()
on
the created adapter. Should not be null.parameters
- additional parameters to use by the component adapter
in constructing component instances. These may be used, for
example, to make decisions about the arguments passed into the
component constructor. These should be considered hints; they
may be ignored by some implementations. May be null, and may
be of zero length.
PicoCompositionException
- if the creation of the component adapter
results in a PicoCompositionException
.public static Properties createDelegateProprties(Object targetObject, String methodName, Object... parameters)
Example:
DelegateAdapterFactory factory = new DelegateAdapterFactory(); HttpServletRequest request = .....; //When object is instantiated will lazily call: request.getSession(false); Properties props = createDelegateProperties(request, "getSession", false); DelegateMethodAdapter adapter = createComponentAdapter(new ConsoleComponentMonitor(), new DefaultLifecycleStrategy(), props, HttpSession.class, HttpSession.class);
targetObject
- the object to be operated on.methodName
- the name of the method to invoke.parameters
- the parameters to supply upon invocation. (Also used to find matching argument).
public static <INSTANCE,RETURN_TYPE> DelegateMethod<INSTANCE,RETURN_TYPE> createDelegate(Class<INSTANCE> targetType, String methodName, Object... parameters)
INSTANCE
- RETURN_TYPE
- targetType
- the type of object being instantiated.methodName
- the method name to invoke when called.parameters
- the method paramters to use.
|
![]() |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |