jfun.yan
Class DelegatingComponent

java.lang.Object
  extended by jfun.yan.Component
      extended by jfun.yan.DelegatingComponent
All Implemented Interfaces:
java.io.Serializable, Creator, Stateful, Typeful, Verifiable
Direct Known Subclasses:
DecoratingComponent

public abstract class DelegatingComponent
extends Component

Base class for delegating Component object. It forwards all method call to the delegated Component object, which makes it handy for customizing a Component object by subclassing.

Codehaus.org.

Author:
Ben Yu
See Also:
Serialized Form

Constructor Summary
DelegatingComponent(Component cc)
          Create a new DelegatingComponent object.
 
Method Summary
 java.lang.Object create(Dependency dep)
          Create a component instance.
 boolean equals(java.lang.Object other)
           
protected  Component getDelegateTarget()
          Gets the Component object being delegated.
 java.lang.Object getState()
          Gets the user state of this component.
 java.lang.Class getType()
          Get the type of instances that this component is responsible to create.
 int hashCode()
           
 boolean isConcrete()
          To determine if the type returned by getType() is the concrete type of the real instance.
 boolean isSingleton()
          Determines if the component always return the same instance and has no side-effect that causes difference when called the second time.
 java.lang.String toString()
           
 java.lang.Class verify(Dependency dep)
          Verifies that the component's dependencies are satisfiable.
 
Methods inherited from class jfun.yan.Component
bean, bean, bean, bind, bind, bindArgument, bindArguments, bindProperties, bindProperty, cast, factory, factory, factory, factory, factory, field, field, field, followedBy, followedBy, followedBy, fromArguments, fromProperties, getter, getter, guard, ifelse, ignoreProperty, incomplete, label, label, map, method, method, method, method, method, mutate, option, optional, optionalParameter, optionalParameters, optionalProperties, optionalProperty, proxy, proxy, proxy, recover, repeat, seal, seq, setter, setter, singleton, singleton, subsume, synchronize, withArgument, withArgument, withArguments, withArguments, withDefaultArgument, withDefaultProperty, withProperties, withProperties, withProperties, withProperty, withProperty, withState
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DelegatingComponent

public DelegatingComponent(Component cc)
Create a new DelegatingComponent object.

Parameters:
cc - the Component object to delegate.
Method Detail

isConcrete

public boolean isConcrete()
Description copied from interface: Creator
To determine if the type returned by getType() is the concrete type of the real instance.

A strict static type check will be performed on concrete types.


isSingleton

public boolean isSingleton()
Description copied from interface: Creator
Determines if the component always return the same instance and has no side-effect that causes difference when called the second time.

This information may be useful to certain optimizations.

Returns:
true if it always return the same instance. False if not singleton or non-determinable.

getState

public java.lang.Object getState()
Description copied from class: Component
Gets the user state of this component. null is returned by default. Subclasses can either override this method to provide user states, or call Component.withState() to associate a user state. Component.withState() is preferable.

Specified by:
getState in interface Stateful
Overrides:
getState in class Component
Returns:
the state.

create

public java.lang.Object create(Dependency dep)
Description copied from interface: Creator
Create a component instance.

Parameters:
dep - the provider that provides all dependent data.
Returns:
the component instance.

equals

public boolean equals(java.lang.Object other)
Overrides:
equals in class java.lang.Object

getType

public java.lang.Class getType()
Description copied from class: Component
Get the type of instances that this component is responsible to create. null is returned if the type of the component cannot be determined at the time. This is typically for components that utilize late-binding strategy where the actual component type is resolved at creation time.

Specified by:
getType in interface Creator
Specified by:
getType in interface Typeful
Specified by:
getType in class Component
Returns:
the type of the component.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

verify

public java.lang.Class verify(Dependency dep)
Description copied from interface: Verifiable
Verifies that the component's dependencies are satisfiable.

Parameters:
dep - the provider that provides all dependent information.

getDelegateTarget

protected final Component getDelegateTarget()
Gets the Component object being delegated.

Returns:
the Component object.