public abstract class InstantiatingComponentAdapter extends AbstractComponentAdapter implements LifecycleStrategy
ComponentAdapter.getComponentInstance(PicoContainer).
That means that when used with a PicoContainer, getComponentInstance will
return a new object each time.| Modifier and Type | Class and Description |
|---|---|
protected static class |
InstantiatingComponentAdapter.Guard
The cycle guard for the verification.
|
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
allowNonPublicClasses
Flag indicating instanciation of non-public classes.
|
protected LifecycleStrategy |
lifecycleStrategy
The strategy used to control the lifecycle
|
protected Parameter[] |
parameters
The parameters to use for initialization.
|
protected InstantiatingComponentAdapter.Guard |
verifyingGuard
The cycle guard for the verification.
|
| Modifier | Constructor and Description |
|---|---|
protected |
InstantiatingComponentAdapter(java.lang.Object componentKey,
java.lang.Class componentImplementation,
Parameter[] parameters,
boolean allowNonPublicClasses)
Constructs a new ComponentAdapter for the given key and implementation.
|
protected |
InstantiatingComponentAdapter(java.lang.Object componentKey,
java.lang.Class componentImplementation,
Parameter[] parameters,
boolean allowNonPublicClasses,
ComponentMonitor monitor)
Constructs a new ComponentAdapter for the given key and implementation.
|
protected |
InstantiatingComponentAdapter(java.lang.Object componentKey,
java.lang.Class componentImplementation,
Parameter[] parameters,
boolean allowNonPublicClasses,
ComponentMonitor monitor,
LifecycleStrategy lifecycleStrategy)
Constructs a new ComponentAdapter for the given key and implementation.
|
| Modifier and Type | Method and Description |
|---|---|
void |
accept(PicoVisitor visitor)
Accepts a visitor for this ComponentAdapter.
|
private void |
checkConcrete() |
protected Parameter[] |
createDefaultParameters(java.lang.Class[] parameters)
Create default parameters for the given types.
|
void |
dispose(java.lang.Object component)
Invoke the "dispose" method on the component instance if this is disposable.
|
protected abstract java.lang.reflect.Constructor |
getGreediestSatisfiableConstructor(PicoContainer container)
Find and return the greediest satisfiable constructor.
|
boolean |
hasLifecycle(java.lang.Class type)
Test if a component instance has a lifecycle.
|
protected java.lang.Object |
newInstance(java.lang.reflect.Constructor constructor,
java.lang.Object[] parameters)
Instantiate an object with given parameters and respect the accessible flag.
|
void |
start(java.lang.Object component)
Invoke the "start" method on the component instance if this is startable.
|
void |
stop(java.lang.Object component)
Invoke the "stop" method on the component instance if this is stoppable.
|
void |
verify(PicoContainer container)
Verify that all dependencies for this adapter can be satisifed.
|
checkTypeCompatibility, getComponentImplementation, getComponentKey, toStringchangeMonitor, currentMonitorclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetComponentInstanceprotected transient InstantiatingComponentAdapter.Guard verifyingGuard
protected transient Parameter[] parameters
protected boolean allowNonPublicClasses
protected LifecycleStrategy lifecycleStrategy
protected InstantiatingComponentAdapter(java.lang.Object componentKey,
java.lang.Class componentImplementation,
Parameter[] parameters,
boolean allowNonPublicClasses,
ComponentMonitor monitor,
LifecycleStrategy lifecycleStrategy)
componentKey - the search key for this implementationcomponentImplementation - the concrete implementationparameters - the parameters to use for the initializationallowNonPublicClasses - flag to allow instantiation of non-public classesmonitor - the component monitor used by this ComponentAdapterlifecycleStrategy - the lifecycle strategy used by this ComponentAdapterAssignabilityRegistrationException - if the key is a type and the implementation cannot be assigned toNotConcreteRegistrationException - if the implementation is not a concrete classjava.lang.NullPointerException - if one of the parameters is nullprotected InstantiatingComponentAdapter(java.lang.Object componentKey,
java.lang.Class componentImplementation,
Parameter[] parameters,
boolean allowNonPublicClasses,
ComponentMonitor monitor)
componentKey - the search key for this implementationcomponentImplementation - the concrete implementationparameters - the parameters to use for the initializationallowNonPublicClasses - flag to allow instantiation of non-public classesmonitor - the component monitor used by this ComponentAdapterAssignabilityRegistrationException - if the key is a type and the implementation cannot be assigned toNotConcreteRegistrationException - if the implementation is not a concrete classjava.lang.NullPointerException - if one of the parameters is nullprotected InstantiatingComponentAdapter(java.lang.Object componentKey,
java.lang.Class componentImplementation,
Parameter[] parameters,
boolean allowNonPublicClasses)
componentKey - the search key for this implementationcomponentImplementation - the concrete implementationparameters - the parameters to use for the initializationallowNonPublicClasses - flag to allow instantiation of non-public classes.AssignabilityRegistrationException - if the key is a type and the implementation cannot be assigned to.NotConcreteRegistrationException - if the implementation is not a concrete class.java.lang.NullPointerException - if one of the parameters is nullprivate void checkConcrete()
throws NotConcreteRegistrationException
NotConcreteRegistrationExceptionprotected Parameter[] createDefaultParameters(java.lang.Class[] parameters)
parameters - the parameter typespublic void verify(PicoContainer container) throws PicoIntrospectionException
ComponentAdapterverify in interface ComponentAdaptercontainer - the PicoContainer, that is used to resolve any possible dependencies of the instance.PicoIntrospectionException - if one or more dependencies cannot be resolved.public void accept(PicoVisitor visitor)
ComponentAdapterPicoContainer, that
cascades the visitor also down to all its ComponentAdapter instances.accept in interface ComponentAdapteraccept in class AbstractComponentAdaptervisitor - the visitor.public void start(java.lang.Object component)
LifecycleStrategystart in interface LifecycleStrategycomponent - the instance of the component to startpublic void stop(java.lang.Object component)
LifecycleStrategystop in interface LifecycleStrategycomponent - the instance of the component to stoppublic void dispose(java.lang.Object component)
LifecycleStrategydispose in interface LifecycleStrategycomponent - the instance of the component to disposepublic boolean hasLifecycle(java.lang.Class type)
LifecycleStrategyhasLifecycle in interface LifecycleStrategytype - the component's typetrue if the component has a lifecycleprotected java.lang.Object newInstance(java.lang.reflect.Constructor constructor,
java.lang.Object[] parameters)
throws java.lang.InstantiationException,
java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
constructor - the constructor to useparameters - the parameters for the constructorjava.lang.InstantiationExceptionjava.lang.IllegalAccessExceptionjava.lang.reflect.InvocationTargetExceptionprotected abstract java.lang.reflect.Constructor getGreediestSatisfiableConstructor(PicoContainer container) throws PicoIntrospectionException, UnsatisfiableDependenciesException, AmbiguousComponentResolutionException, AssignabilityRegistrationException, NotConcreteRegistrationException
container - the PicoContainer to resolve dependencies.PicoIntrospectionExceptionUnsatisfiableDependenciesExceptionAmbiguousComponentResolutionExceptionAssignabilityRegistrationExceptionNotConcreteRegistrationException