jfun.yan
Class SimpleComponent<T>

java.lang.Object
  extended by jfun.yan.Component<T>
      extended by jfun.yan.SimpleComponent<T>
All Implemented Interfaces:
java.io.Serializable, Creator<T>, Stateful, Typeful, Verifiable

public abstract class SimpleComponent<T>
extends Component<T>

This abstract class provides a convenient way to create Component implementations that do not have dependencies to resolve.

Author:
Ben Yu Nov 12, 2005 11:05:17 AM
See Also:
Serialized Form

Constructor Summary
SimpleComponent(java.lang.Class type)
           
 
Method Summary
abstract  T create()
          Subclasses can override this method to provide actual creation logic.
 T create(Dependency dep)
          Create a component instance.
 java.lang.Class getType()
          Get the type of instances that this component is responsible to create.
 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, getState, 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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SimpleComponent

public SimpleComponent(java.lang.Class type)
Method Detail

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<T>
Specified by:
getType in interface Typeful
Specified by:
getType in class Component<T>
Returns:
the type of the component.

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.


create

public T 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.

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.

create

public abstract T create()
                  throws java.lang.Throwable
Subclasses can override this method to provide actual creation logic.

Returns:
the component instance.
Throws:
java.lang.Throwable - any error can be thrown out of here.

toString

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

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.