org.picocontainer.gems.containers
Class Log4jTracingContainerDecorator

java.lang.Object
  extended by org.picocontainer.gems.containers.Log4jTracingContainerDecorator
All Implemented Interfaces:
Serializable, Disposable, MutablePicoContainer, PicoContainer, Startable

Deprecated. Since PicoContainer 2.3, Pico 2 ComponentAdapters can now do everything that this decorator provided.

@Deprecated
public class Log4jTracingContainerDecorator
extends Object
implements MutablePicoContainer, Serializable

Decorates a MutablePicoContainer to provide extensive tracing capabilities for all function calls into the Picocontainers.

By default, this class uses org.picocontainer.PicoContainer as its logging category, however, this may be changed by providing the logger in its alternate constructor.

Start and Stop events are logged under info priority, as are all conditions where querying for an object returns a null object (e.g., getComponentAdapter(Object) returns null). All other functions use debug priority.

If used in nanocontainer, you can add wrap your PicoContainer with the Log4jTracingContainerDecorator: (Groovy Example)

                pico = builder.container(parent: parent) {
                        //addComponent(.....)
                        //And others.
                }

                //Wrap the underlying NanoContainer with a Decorated Pico.
                pico = new org.picocontainer.gems.containers.Log4jTracingContainerDecorator (pico.getPico())
 

Author:
Michael Rimov
See Also:
Serialized Form

Constructor Summary
Log4jTracingContainerDecorator(MutablePicoContainer delegate)
          Deprecated. Default typical wrapper that wraps another MutablePicoContainer.
Log4jTracingContainerDecorator(MutablePicoContainer delegate, org.apache.log4j.Logger logger)
          Deprecated. Alternate constructor that allows specification of the Logger to use.
 
Method Summary
 void accept(PicoVisitor visitor)
          Deprecated. Accepts a visitor that should visit the child containers, component adapters and component instances.
 MutablePicoContainer addAdapter(ComponentAdapter componentAdapter)
          Deprecated. Register a component via a ComponentAdapter.
 MutablePicoContainer addChildContainer(PicoContainer child)
          Deprecated. Add a child container.
 MutablePicoContainer addComponent(Object implOrInstance)
          Deprecated. Register an arbitrary object.
 MutablePicoContainer addComponent(Object componentKey, Object componentImplementationOrInstance, Parameter... parameters)
          Deprecated. Register a component and creates specific instructions on which constructor to use, along with which components and/or constants to provide as constructor arguments.
 MutablePicoContainer addConfig(String name, Object val)
          Deprecated. Register a config item.
 MutablePicoContainer as(Properties... properties)
          Deprecated. You can set for the following operation only the characteristic of registration of a component on the fly.
 MutablePicoContainer change(Properties... properties)
          Deprecated. You can change the characteristic of registration of all subsequent components in this container.
 void dispose()
          Deprecated. Dispose this component.
<T> T
getComponent(Class<T> componentType)
          Deprecated. Retrieve a component keyed by the component type.
<T> T
getComponent(Class<T> componentType, Class<? extends Annotation> binding)
          Deprecated.  
 Object getComponent(Object componentKeyOrType)
          Deprecated. Retrieve a component instance registered with a specific key or type.
 Object getComponent(Object componentKeyOrType, Type into)
          Deprecated.  
<T> ComponentAdapter<T>
getComponentAdapter(Class<T> componentType, Class<? extends Annotation> binding)
          Deprecated.  
<T> ComponentAdapter<T>
getComponentAdapter(Class<T> componentType, NameBinding componentNameBinding)
          Deprecated. Find a component adapter associated with the specified type.
 ComponentAdapter<?> getComponentAdapter(Object componentKey)
          Deprecated. Find a component adapter associated with the specified key.
 Collection<ComponentAdapter<?>> getComponentAdapters()
          Deprecated. Retrieve all the component adapters inside this container.
<T> List<ComponentAdapter<T>>
getComponentAdapters(Class<T> componentType)
          Deprecated. Retrieve all component adapters inside this container that are associated with the specified type.
<T> List<ComponentAdapter<T>>
getComponentAdapters(Class<T> componentType, Class<? extends Annotation> binding)
          Deprecated.  
 List getComponents()
          Deprecated. Retrieve all the registered component instances in the container, (not including those in the parent container).
<T> List<T>
getComponents(Class<T> componentType)
          Deprecated. Returns a List of components of a certain componentType.
 org.apache.log4j.Logger getLoggerUsed()
          Deprecated. Retrieves the logger instance used by this decorator.
 PicoContainer getParent()
          Deprecated. Retrieve the parent container of this container.
 MutablePicoContainer makeChildContainer()
          Deprecated. Make a child container, using the same implementation of MutablePicoContainer as the parent.
protected  void onKeyOrTypeDoesNotExistInContainer(Object componentKeyOrType, org.apache.log4j.Logger target)
          Deprecated. Standard message handling for cases when a null object is returned for a given key.
 boolean removeChildContainer(PicoContainer child)
          Deprecated. Remove a child container from this container.
 ComponentAdapter removeComponent(Object componentKey)
          Deprecated. Unregister a component by key.
 ComponentAdapter removeComponentByInstance(Object componentInstance)
          Deprecated. Unregister a component by instance.
 void start()
          Deprecated. Start this component.
 void stop()
          Deprecated. Stop this component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Log4jTracingContainerDecorator

public Log4jTracingContainerDecorator(MutablePicoContainer delegate)
Deprecated. 
Default typical wrapper that wraps another MutablePicoContainer.

Parameters:
delegate - Container to be decorated.
Throws:
NullPointerException - if delegate is null.

Log4jTracingContainerDecorator

public Log4jTracingContainerDecorator(MutablePicoContainer delegate,
                                      org.apache.log4j.Logger logger)
Deprecated. 
Alternate constructor that allows specification of the Logger to use.

Parameters:
delegate - Container to be decorated.
logger - specific Log4j Logger to use.
Throws:
NullPointerException - if delegate or logger is null.
Method Detail

onKeyOrTypeDoesNotExistInContainer

protected void onKeyOrTypeDoesNotExistInContainer(Object componentKeyOrType,
                                                  org.apache.log4j.Logger target)
Deprecated. 
Standard message handling for cases when a null object is returned for a given key.

Parameters:
componentKeyOrType - Component key that does not exist
target - Logger to log into

accept

public void accept(PicoVisitor visitor)
Deprecated. 
Accepts a visitor that should visit the child containers, component adapters and component instances.

Specified by:
accept in interface PicoContainer
Parameters:
visitor -
See Also:
PicoContainer.accept(org.picocontainer.PicoVisitor)

addChildContainer

public MutablePicoContainer addChildContainer(PicoContainer child)
Deprecated. 
Add a child container. This action will list the the 'child' as exactly that in the parents scope. It will not change the child's view of a parent. That is determined by the constructor arguments of the child itself. Lifecycle events will be cascaded from parent to child as a consequence of calling this method.

Specified by:
addChildContainer in interface MutablePicoContainer
Parameters:
child -
Returns:
See Also:
MutablePicoContainer.addChildContainer(org.picocontainer.PicoContainer)

dispose

public void dispose()
Deprecated. 
Dispose this component. The component should deallocate all resources. The contract for this method defines a single call at the end of this component's life.

Specified by:
dispose in interface Disposable
See Also:
Disposable.dispose()

getComponentAdapter

public ComponentAdapter<?> getComponentAdapter(Object componentKey)
Deprecated. 
Find a component adapter associated with the specified key. If a component adapter cannot be found in this container, the parent container (if one exists) will be searched.

Specified by:
getComponentAdapter in interface PicoContainer
Parameters:
componentKey -
Returns:
See Also:
PicoContainer.getComponentAdapter(java.lang.Object)

getComponentAdapter

public <T> ComponentAdapter<T> getComponentAdapter(Class<T> componentType,
                                                   NameBinding componentNameBinding)
Deprecated. 
Find a component adapter associated with the specified type. If a component adapter cannot be found in this container, the parent container (if one exists) will be searched.

Specified by:
getComponentAdapter in interface PicoContainer
Parameters:
componentType -
Returns:
ComponentAdapter or null.
See Also:
org.picocontainer.PicoContainer#getComponentAdapter(java.lang.Class)

getComponentAdapters

public Collection<ComponentAdapter<?>> getComponentAdapters()
Deprecated. 
Retrieve all the component adapters inside this container. The component adapters from the parent container are not returned.

Specified by:
getComponentAdapters in interface PicoContainer
Returns:
Collection or null.
See Also:
PicoContainer.getComponentAdapters()

getComponentAdapters

public <T> List<ComponentAdapter<T>> getComponentAdapters(Class<T> componentType)
Deprecated. 
Retrieve all component adapters inside this container that are associated with the specified type. The addComponent adapters from the parent container are not returned.

Specified by:
getComponentAdapters in interface PicoContainer
Parameters:
componentType -
Returns:
List of ComponentAdapters
See Also:
PicoContainer.getComponentAdapters(java.lang.Class)

getComponentAdapters

public <T> List<ComponentAdapter<T>> getComponentAdapters(Class<T> componentType,
                                                          Class<? extends Annotation> binding)
Deprecated. 
Specified by:
getComponentAdapters in interface PicoContainer

getComponentAdapter

public <T> ComponentAdapter<T> getComponentAdapter(Class<T> componentType,
                                                   Class<? extends Annotation> binding)
Deprecated. 
Specified by:
getComponentAdapter in interface PicoContainer

getComponent

public Object getComponent(Object componentKeyOrType)
Deprecated. 
Retrieve a component instance registered with a specific key or type. If a component cannot be found in this container, the parent container (if one exists) will be searched.

Specified by:
getComponent in interface PicoContainer
Parameters:
componentKeyOrType -
Returns:
See Also:
PicoContainer.getComponent(java.lang.Object)

getComponent

public Object getComponent(Object componentKeyOrType,
                           Type into)
Deprecated. 
Specified by:
getComponent in interface PicoContainer

getComponent

public <T> T getComponent(Class<T> componentType)
Deprecated. 
Description copied from interface: PicoContainer
Retrieve a component keyed by the component type.

Specified by:
getComponent in interface PicoContainer
Type Parameters:
T - the type of the component.
Parameters:
componentType - the type of the component
Returns:
the typed resulting object instance or null if the object does not exist.

getComponent

public <T> T getComponent(Class<T> componentType,
                          Class<? extends Annotation> binding)
Deprecated. 
Specified by:
getComponent in interface PicoContainer

getComponents

public List getComponents()
Deprecated. 
Retrieve all the registered component instances in the container, (not including those in the parent container). The components are returned in their order of instantiation, which depends on the dependency order between them.

Specified by:
getComponents in interface PicoContainer
Returns:
See Also:
PicoContainer.getComponents()

getComponents

public <T> List<T> getComponents(Class<T> componentType)
Deprecated. 
Returns a List of components of a certain componentType. The list is ordered by instantiation order, starting with the components instantiated first at the beginning.

Specified by:
getComponents in interface PicoContainer
Parameters:
componentType -
Returns:
See Also:
PicoContainer.getComponents(java.lang.Class)

getParent

public PicoContainer getParent()
Deprecated. 
Retrieve the parent container of this container.

Specified by:
getParent in interface PicoContainer
Returns:
See Also:
PicoContainer.getParent()

makeChildContainer

public MutablePicoContainer makeChildContainer()
Deprecated. 
Make a child container, using the same implementation of MutablePicoContainer as the parent. It will have a reference to this as parent. This will list the resulting MPC as a child. Lifecycle events will be cascaded from parent to child as a consequence of this.

Specified by:
makeChildContainer in interface MutablePicoContainer
Returns:
See Also:
MutablePicoContainer.makeChildContainer()

addAdapter

public MutablePicoContainer addAdapter(ComponentAdapter componentAdapter)
Deprecated. 
Register a component via a ComponentAdapter. Use this if you need fine grained control over what ComponentAdapter to use for a specific component. The adapter will be wrapped in whatever behaviors that the the container has been set up with. If you want to bypass that behavior for the adapter you are adding, you should use Characteristics.NONE like so pico.as(Characteristics.NONE).addAdapter(...)

Specified by:
addAdapter in interface MutablePicoContainer
Parameters:
componentAdapter -
Returns:
See Also:
MutablePicoContainer.addAdapter(org.picocontainer.ComponentAdapter)

addComponent

public MutablePicoContainer addComponent(Object componentKey,
                                         Object componentImplementationOrInstance,
                                         Parameter... parameters)
Deprecated. 
Register a component and creates specific instructions on which constructor to use, along with which components and/or constants to provide as constructor arguments. These "directives" are provided through an array of Parameter objects. Parameter[0] correspondes to the first constructor argument, Parameter[N] corresponds to the N+1th constructor argument.

Tips for Parameter usage


addComponent

public MutablePicoContainer addComponent(Object implOrInstance)
Deprecated. 
Register an arbitrary object. The class of the object will be used as a key. Calling this method is equivalent to calling addComponent(componentImplementation, componentImplementation).

Specified by:
addComponent in interface MutablePicoContainer
Parameters:
implOrInstance -
Returns:
See Also:
MutablePicoContainer.addComponent(java.lang.Object)

addConfig

public MutablePicoContainer addConfig(String name,
                                      Object val)
Deprecated. 
Description copied from interface: MutablePicoContainer
Register a config item.

Specified by:
addConfig in interface MutablePicoContainer
Parameters:
name - the name of the config item
val - the value of the config item
Returns:
the same instance of MutablePicoContainer

removeChildContainer

public boolean removeChildContainer(PicoContainer child)
Deprecated. 
Remove a child container from this container. It will not change the child's view of a parent. Lifecycle event will no longer be cascaded from the parent to the child.

Specified by:
removeChildContainer in interface MutablePicoContainer
Parameters:
child -
Returns:
See Also:
MutablePicoContainer.removeChildContainer(org.picocontainer.PicoContainer)

start

public void start()
Deprecated. 
Start this component. Called initially at the begin of the lifecycle. It can be called again after a stop.

Specified by:
start in interface Startable
See Also:
Startable.start()

stop

public void stop()
Deprecated. 
Stop this component. Called near the end of the lifecycle. It can be called again after a further start. Implement Disposable if you need a single call at the definite end of the lifecycle.

Specified by:
stop in interface Startable
See Also:
Startable.stop()

removeComponent

public ComponentAdapter removeComponent(Object componentKey)
Deprecated. 
Unregister a component by key.

Specified by:
removeComponent in interface MutablePicoContainer
Parameters:
componentKey -
Returns:
See Also:
MutablePicoContainer.removeComponent(java.lang.Object)

removeComponentByInstance

public ComponentAdapter removeComponentByInstance(Object componentInstance)
Deprecated. 
Unregister a component by instance.

Specified by:
removeComponentByInstance in interface MutablePicoContainer
Parameters:
componentInstance -
Returns:
See Also:
MutablePicoContainer.removeComponentByInstance(java.lang.Object)

getLoggerUsed

public org.apache.log4j.Logger getLoggerUsed()
Deprecated. 
Retrieves the logger instance used by this decorator.

Returns:
Logger instance.

change

public MutablePicoContainer change(Properties... properties)
Deprecated. 
Description copied from interface: MutablePicoContainer
You can change the characteristic of registration of all subsequent components in this container.

Specified by:
change in interface MutablePicoContainer
Returns:
the same Pico instance with changed properties

as

public MutablePicoContainer as(Properties... properties)
Deprecated. 
Description copied from interface: MutablePicoContainer
You can set for the following operation only the characteristic of registration of a component on the fly.

Specified by:
as in interface MutablePicoContainer
Returns:
the same Pico instance with temporary properties


Copyright © 2003-2010 Codehaus. All Rights Reserved.