|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Interface to be implemented by objects that hold a number of bean definitions, each uniquely identified by a String name. An independent instance of any of these objects can be obtained (the Prototype design pattern), or a single shared instance can be obtained (a superior alternative to the Singleton design pattern). Which type of instance will be returned depends on the bean factory configuration--the API is the same. The Singleton approach is much more useful and more common in practice.
The point of this approach is that the BeanFactory is a central registry of application components, and centralizes the configuring of application components (no more do individual objects need to read properties files, for example). See chapters 4 and 11 of "Expert One-on-One J2EE" for a discussion of the benefits of this approach.
| Method Summary | |
java.lang.String[] |
getAliases(java.lang.String name)
Return the aliases for the given bean name, if defined. |
java.lang.Object |
getBean(java.lang.String name)
Return an instance (possibly shared or independent) of the given bean name. |
java.lang.Object |
getBean(java.lang.String name,
java.lang.Class requiredType)
Return an instance (possibly shared or independent) of the given bean name. |
boolean |
isSingleton(java.lang.String name)
Is this bean a singleton? |
| Method Detail |
public java.lang.Object getBean(java.lang.String name)
throws BeansException
name - name of the bean to returnNoSuchBeanDefinitionException - if there's no such bean definition
public java.lang.Object getBean(java.lang.String name,
java.lang.Class requiredType)
throws BeansException
name - name of the bean to returnrequiredType - type the bean may match. Can be an interface or superclass
of the actual class. For example, if the value is Object.class, this method will
succeed whatever the class of the returned instance.BeanNotOfRequiredTypeException - if the bean is not of the required typeNoSuchBeanDefinitionException - if there's no such bean definition
public boolean isSingleton(java.lang.String name)
throws NoSuchBeanDefinitionException
name - name of the bean to queryNoSuchBeanDefinitionException - if there is no bean with the given namepublic java.lang.String[] getAliases(java.lang.String name)
name - the bean name to check for aliases
|
[Deprecated API] | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | CURRENT API | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||