net.sf.jguiraffe.di.impl
Class ClassDependency

java.lang.Object
  extended by net.sf.jguiraffe.di.impl.ClassDependency
All Implemented Interfaces:
Dependency

public class ClassDependency
extends java.lang.Object
implements Dependency

An implementation of the Dependency interface that allows to define a dependency based on a bean class.

Version:
$Id: ClassDependency.java 156 2009-03-03 21:04:47Z oheger $
Author:
Oliver Heger

Method Summary
 boolean equals(java.lang.Object obj)
          Compares this object with another one.
 ClassDescription getDependentClass()
          Returns the description of the class of this dependency.
static ClassDependency getInstance(java.lang.Class<?> cls)
          Returns a ClassDependency instance for the specified class.
static ClassDependency getInstance(ClassDescription clsdsc)
          Returns a ClassDependency instance for the specified ClassDescription.
 int hashCode()
          Returns a hash code for this object.
 BeanProvider resolve(BeanStore store, DependencyProvider depProvider)
          Resolves this dependency on the specified bean store.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getDependentClass

public ClassDescription getDependentClass()
Returns the description of the class of this dependency.

Returns:
the class of this dependency

resolve

public BeanProvider resolve(BeanStore store,
                            DependencyProvider depProvider)
Resolves this dependency on the specified bean store. This implementation iterates over the beans defined in the store. If a bean provider is found whose bean class is either the same or a sub class of the class defined in this dependency, it is returned. Otherwise the parent bean store will be searched recursively.

Specified by:
resolve in interface Dependency
Parameters:
store - the bean store to be searched
depProvider - the dependency provider
Returns:
the found bean provider
Throws:
InjectionException - if no fitting bean provider can be found

equals

public boolean equals(java.lang.Object obj)
Compares this object with another one. Two class dependencies are considered equal if and only if they refer to the same class.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare to
Returns:
a flag whether the objects are equal

hashCode

public int hashCode()
Returns a hash code for this object.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code

toString

public java.lang.String toString()
Returns a string representation of this object. This string will contain the name of the class referred to by this dependency.

Overrides:
toString in class java.lang.Object
Returns:
a string for this object

getInstance

public static ClassDependency getInstance(java.lang.Class<?> cls)
Returns a ClassDependency instance for the specified class.

Parameters:
cls - the class of the dependency (must not be null)
Returns:
an instance pointing to the specified class
Throws:
java.lang.IllegalArgumentException - if the class is null

getInstance

public static ClassDependency getInstance(ClassDescription clsdsc)
Returns a ClassDependency instance for the specified ClassDescription.

Parameters:
clsdsc - the class description
Returns:
an instance pointing to the specified class
Throws:
java.lang.IllegalArgumentException - if the class description is null


Copyright © 2009 The JGUIraffe Team. All Rights Reserved.