org.wamblee.general
Interface BeanFactory


public interface BeanFactory

Bean factory used to obtain objects in a transparent way.

Author:
Erik Brakkee

Method Summary
<T> T
find(java.lang.Class<T> aClass)
          Finds a bean of the given class and which can be cast to the specified class.
 java.lang.Object find(java.lang.String aId)
          Finds a bean based on id.
<T> T
find(java.lang.String aId, java.lang.Class<T> aClass)
          Finds a bean with the given id which can be cast to the specified class.
 

Method Detail

find

java.lang.Object find(java.lang.String aId)
Finds a bean based on id.

Parameters:
aId - Id of the bean.
Returns:
Object (always non-null).
Throws:
BeanFactoryException - In case the object could not be found.

find

<T> T find(java.lang.Class<T> aClass)
Finds a bean of the given class and which can be cast to the specified class. This is typically used by specifying the interface class for retrieving an implementation of that class. This means that the bean implementing the class is configured in the bean factory with id equal to the class name of the interface.

Parameters:
aClass - Class of the object to find.
Returns:
Object (always non-null).
Throws:
BeanFactoryException - In case the object could not be found.

find

<T> T find(java.lang.String aId,
           java.lang.Class<T> aClass)
Finds a bean with the given id which can be cast to the specified class.

Type Parameters:
T - Type of the object to get.
Parameters:
aId - Id of the object to lookup.
aClass - Class that the object must extends.
Returns:
Object, always non-null.
Throws:
BeanFactoryException - In case the object could not be found.


Copyright © 2010. All Rights Reserved.