KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > beans > factory > support > BeanDefinitionRegistry


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.beans.factory.support;
18
19 import org.springframework.beans.factory.BeanDefinitionStoreException;
20 import org.springframework.beans.factory.NoSuchBeanDefinitionException;
21 import org.springframework.beans.factory.config.BeanDefinition;
22
23 /**
24  * Interface for registries that hold bean definitions, for example RootBeanDefinition
25  * and ChildBeanDefinition instances. Typically implemented by BeanFactories that
26  * internally work with the AbstractBeanDefinition hierarchy.
27  *
28  * <p>This is the only interface in Spring's bean factory packages that encapsulates
29  * <i>registration</i> of bean definitions. The standard BeanFactory interfaces
30  * only cover access to a <i>fully configured factory instance</i>.
31  *
32  * <p>Spring's bean definition readers expect to work on an implementation of this
33  * interface. Known implementors within the Spring core are DefaultListableBeanFactory
34  * and GenericApplicationContext.
35  *
36  * @author Juergen Hoeller
37  * @since 26.11.2003
38  * @see org.springframework.beans.factory.config.BeanDefinition
39  * @see AbstractBeanDefinition
40  * @see RootBeanDefinition
41  * @see ChildBeanDefinition
42  * @see DefaultListableBeanFactory
43  * @see org.springframework.context.support.GenericApplicationContext
44  * @see org.springframework.beans.factory.xml.XmlBeanDefinitionReader
45  * @see PropertiesBeanDefinitionReader
46  */

47 public interface BeanDefinitionRegistry {
48
49     /**
50      * Register a new bean definition with this registry.
51      * Must support RootBeanDefinition and ChildBeanDefinition.
52      * @param beanName the name of the bean instance to register
53      * @param beanDefinition definition of the bean instance to register
54      * @throws BeanDefinitionStoreException if the BeanDefinition is invalid
55      * or if there is already a BeanDefinition for the specified bean name
56      * (and we are not allowed to override it)
57      * @see RootBeanDefinition
58      * @see ChildBeanDefinition
59      */

60     void registerBeanDefinition(String JavaDoc beanName, BeanDefinition beanDefinition)
61             throws BeanDefinitionStoreException;
62
63     /**
64      * Return the BeanDefinition for the given bean name.
65      * @param beanName name of the bean to find a definition for
66      * @return the BeanDefinition for the given name (never <code>null</code>)
67      * @throws NoSuchBeanDefinitionException if there is no such bean definition
68      */

69     BeanDefinition getBeanDefinition(String JavaDoc beanName) throws NoSuchBeanDefinitionException;
70
71     /**
72      * Check if this registry contains a bean definition with the given name.
73      * @param beanName the name of the bean to look for
74      * @return if this registry contains a bean definition with the given name
75      */

76     boolean containsBeanDefinition(String JavaDoc beanName);
77
78     /**
79      * Return the names of all beans defined in this registry.
80      * @return the names of all beans defined in this registry,
81      * or an empty array if none defined
82      */

83     String JavaDoc[] getBeanDefinitionNames();
84
85     /**
86      * Return the number of beans defined in the registry.
87      * @return the number of beans defined in the registry
88      */

89     int getBeanDefinitionCount();
90
91     /**
92      * Given a bean name, create an alias. We typically use this method to
93      * support names that are illegal within XML ids (used for bean names).
94      * @param beanName the canonical name of the bean
95      * @param alias the alias to be registered for the bean
96      * @throws BeanDefinitionStoreException if the alias is already in use
97      */

98     void registerAlias(String JavaDoc beanName, String JavaDoc alias) throws BeanDefinitionStoreException;
99
100     /**
101      * Return the aliases for the given bean name, if defined.
102      * @param beanName the bean name to check for aliases
103      * @return the aliases, or an empty array if none
104      */

105     String JavaDoc[] getAliases(String JavaDoc beanName);
106
107 }
108
Popular Tags