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.20 $
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
 void accept(PicoVisitor visitor)
          Accepts a visitor for this ComponentAdapter.
protected  void checkTypeCompatibility()
           
 Class getComponentImplementation()
          Retrieve the class of the component.
 Object getComponentKey()
          Retrieve the key associated with the component.
 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
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.
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()

checkTypeCompatibility

protected void checkTypeCompatibility()
                               throws AssignabilityRegistrationException
Throws:
AssignabilityRegistrationException

toString

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

accept

public void accept(PicoVisitor visitor)
Description copied from interface: ComponentAdapter
Accepts a visitor for this ComponentAdapter. The method is normally called by visiting a PicoContainer, that cascades the visitor also down to all its ComponentAdapter instances.

Specified by:
accept in interface ComponentAdapter
Parameters:
visitor - the visitor.


Copyright © 2003-2004 Codehaus. All Rights Reserved.