org.picocontainer.defaults
Class AbstractComponentAdapter

java.lang.Object
  extended byorg.picocontainer.defaults.AbstractComponentAdapter
All Implemented Interfaces:
ComponentAdapter, Serializable
Direct Known Subclasses:
InstanceComponentAdapter, InstantiatingComponentAdapter

public abstract class AbstractComponentAdapter
extends Object
implements ComponentAdapter, Serializable

Base class for a ComponentAdapter with general functionality. This implementation provides basic checks for a healthy implementation of a ComponentAdapter. It does not allow to use null for the component key or the implementation, ensures that the implementation is a concrete class and that the key is assignable from the implementation if the key represents a type.

Since:
1.0
Version:
$Revision: 1.14 $
Author:
Paul Hammant, Aslak Hellesøy, Jon Tirsén
See Also:
Serialized Form

Constructor Summary
protected AbstractComponentAdapter(Object componentKey, Class componentImplementation)
          Constructs a new ComponentAdapter for the given key and implementation.
 
Method Summary
 Class getComponentImplementation()
          Retrieve the class of the component.
 Object getComponentKey()
          Retrieve the key associated with the component.
 PicoContainer getContainer()
          Retrieve the container in which the component is registered.
 void setContainer(PicoContainer picoContainer)
          Set the container in which this adapter is registered.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.picocontainer.ComponentAdapter
getComponentInstance, verify
 

Constructor Detail

AbstractComponentAdapter

protected AbstractComponentAdapter(Object componentKey,
                                   Class componentImplementation)
                            throws AssignabilityRegistrationException,
                                   NotConcreteRegistrationException
Constructs a new ComponentAdapter for the given key and implementation.

Parameters:
componentKey - the search key for this implementation
componentImplementation - the concrete implementation
Throws:
AssignabilityRegistrationException - if the key is a type and the implementation cannot be assigned to.
NotConcreteRegistrationException - if the implementation is not a concrete class.
Method Detail

getComponentKey

public Object getComponentKey()
Retrieve the key associated with the component.

Specified by:
getComponentKey in interface ComponentAdapter
Returns:
the component's key. Should either be a class type (normally an interface) or an identifier that is unique (within the scope of the current PicoContainer).
See Also:
ComponentAdapter.getComponentKey()

getComponentImplementation

public Class getComponentImplementation()
Retrieve the class of the component.

Specified by:
getComponentImplementation in interface ComponentAdapter
Returns:
the component's implementation class. Should normally be a concrete class (ie, a class that can be instantiated).
See Also:
ComponentAdapter.getComponentImplementation()

toString

public String toString()
Returns:
Returns the ComponentAdapter's class name and the component's key.
See Also:
Object.toString()

getContainer

public PicoContainer getContainer()
Description copied from interface: ComponentAdapter
Retrieve the container in which the component is registered.

Specified by:
getContainer in interface ComponentAdapter
Returns:
the container in which the component is registered.
See Also:
ComponentAdapter.getContainer()

setContainer

public void setContainer(PicoContainer picoContainer)
Description copied from interface: ComponentAdapter
Set the container in which this adapter is registered. This method will be called once by the container when the adapter is registered in that container. It should usually not be called directly.

Specified by:
setContainer in interface ComponentAdapter
Parameters:
picoContainer - the container in which this adapter is registered.
See Also:
ComponentAdapter.setContainer(org.picocontainer.PicoContainer)


Copyright © 2003-2004 Codehaus. All Rights Reserved.