jfun.yan
Class SimpleDependency

java.lang.Object
  extended by jfun.yan.SimpleDependency
All Implemented Interfaces:
java.io.Serializable, Dependency

public class SimpleDependency
extends java.lang.Object
implements Dependency

A simple implementation of the Dependency interface.
It simply calls ComponentMap.getComponent(Object) and ComponentMap.getComponentOfType(Class) to resolve component parts.
Properties and parameters are resolved by type.

Codehaus.org.

Author:
Ben Yu
See Also:
Serialized Form

Constructor Summary
SimpleDependency(java.lang.Object ckey, ComponentMap cmap)
          Create a SimpleDependency object.
 
Method Summary
 java.lang.Object getArgument(Signature src, int i, java.lang.Class type)
          Get an instance of an argument.
 java.lang.Object getComponentKey()
          Get the key of the component being resolved.
 ComponentMap getComponentMap()
          Get the ComponentMap object.
 Dependency getOriginal()
          To get the Dependency object before the current one is customized, if any.
 Dependency getParent()
          Get the dependency for the parent component.
 java.lang.Object getProperty(java.lang.Class component_type, java.lang.Object lkey, java.lang.Class type)
          Get an instance of a property.
 Dependency seal()
          To create a Dependency that's free of auto-wiring.
 java.lang.Class verifyArgument(Signature src, int i, java.lang.Class type)
          Verifies that the argument instance can be resolved.
 java.lang.Class verifyProperty(java.lang.Class component_type, java.lang.Object lkey, java.lang.Class type)
          Verifies that the property instance can be resolved.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleDependency

public SimpleDependency(java.lang.Object ckey,
                        ComponentMap cmap)
Create a SimpleDependency object.

Parameters:
ckey - the component key.
cmap - the container to look into.
Method Detail

getComponentMap

public ComponentMap getComponentMap()
Description copied from interface: Dependency
Get the ComponentMap object.

Specified by:
getComponentMap in interface Dependency
Returns:
the ComponentMap object.

getArgument

public java.lang.Object getArgument(Signature src,
                                    int i,
                                    java.lang.Class type)
Description copied from interface: Dependency
Get an instance of an argument.

Specified by:
getArgument in interface Dependency
Parameters:
src - the signature of the function requesting this argument.
i - the ordinal position of the argument. Starting from 0.
type - the parameter type.
Returns:
the argument instance.

verifyArgument

public java.lang.Class verifyArgument(Signature src,
                                      int i,
                                      java.lang.Class type)
Description copied from interface: Dependency
Verifies that the argument instance can be resolved. The actual argument type is returned if verification succeeds.

Specified by:
verifyArgument in interface Dependency
Parameters:
src - the signature of the function requesting this argument.
i - the ordinal position of the argument. Starting from 0.
type - the parameter type.
Returns:
the actual type of the argument.

getProperty

public java.lang.Object getProperty(java.lang.Class component_type,
                                    java.lang.Object lkey,
                                    java.lang.Class type)
Description copied from interface: Dependency
Get an instance of a property.

Specified by:
getProperty in interface Dependency
Parameters:
component_type - the type of the component requesting the property.
lkey - the key of the property.
type - the property type.
Returns:
the property instance.

verifyProperty

public java.lang.Class verifyProperty(java.lang.Class component_type,
                                      java.lang.Object lkey,
                                      java.lang.Class type)
Description copied from interface: Dependency
Verifies that the property instance can be resolved. The actual type of the property is returned if verification succeeds.

Specified by:
verifyProperty in interface Dependency
Parameters:
component_type - the type of the component requesting the property.
lkey - the property key.
type - the expected property type.
Returns:
the actual type of the property.

getComponentKey

public java.lang.Object getComponentKey()
Description copied from interface: Dependency
Get the key of the component being resolved.

Specified by:
getComponentKey in interface Dependency
Returns:
the context.

getParent

public Dependency getParent()
Description copied from interface: Dependency
Get the dependency for the parent component. if component 1 is resolved as a part of component 2, component 2 is considered the parent component of component 1. If there's no parent component, null is returned.

Specified by:
getParent in interface Dependency
Returns:
the dependency for the parent component.

getOriginal

public Dependency getOriginal()
Description copied from interface: Dependency
To get the Dependency object before the current one is customized, if any.

Specified by:
getOriginal in interface Dependency

seal

public Dependency seal()
Description copied from interface: Dependency
To create a Dependency that's free of auto-wiring.

Specified by:
seal in interface Dependency