KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > context > ConfigurableApplicationContext


1 /*
2  * Copyright 2002-2007 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.context;
18
19 import org.springframework.beans.BeansException;
20 import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
21 import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
22
23 /**
24  * SPI interface to be implemented by most if not all application contexts.
25  * Provides facilities to configure an application context in addition
26  * to the application context client methods in the
27  * {@link org.springframework.context.ApplicationContext} interface.
28  *
29  * <p>Configuration and lifecycle methods are encapsulated here to avoid
30  * making them obvious to ApplicationContext client code. The present
31  * methods should only be used by startup and shutdown code.
32  *
33  * @author Juergen Hoeller
34  * @since 03.11.2003
35  */

36 public interface ConfigurableApplicationContext extends ApplicationContext, Lifecycle {
37
38     /**
39      * Set the parent of this application context.
40      * <p>Note that the parent shouldn't be changed: It should only be set outside
41      * a constructor if it isn't available when an object of this class is created,
42      * for example in case of WebApplicationContext setup.
43      * @param parent the parent context
44      * @see org.springframework.web.context.ConfigurableWebApplicationContext
45      */

46     void setParent(ApplicationContext parent);
47
48     /**
49      * Add a new BeanFactoryPostProcessor that will get applied to the internal
50      * bean factory of this application context on refresh, before any of the
51      * bean definitions get evaluated. To be invoked during context configuration.
52      * @param beanFactoryPostProcessor the factory processor to register
53      */

54     void addBeanFactoryPostProcessor(BeanFactoryPostProcessor beanFactoryPostProcessor);
55
56     /**
57      * Load or refresh the persistent representation of the configuration,
58      * which might an XML file, properties file, or relational database schema.
59      * <p>As this is a startup method, it should destroy already created singletons
60      * if it fails, to avoid dangling resources. In other words, after invocation
61      * of that method, either all or no singletons at all should be instantiated.
62      * @throws BeansException if the bean factory could not be initialized
63      * @throws IllegalStateException if already initialized and multiple refresh
64      * attempts are not supported
65      */

66     void refresh() throws BeansException, IllegalStateException JavaDoc;
67
68     /**
69      * Register a shutdown hook with the JVM runtime, closing this context
70      * on JVM shutdown unless it has already been closed at that time.
71      * <p>This method can be called multiple times. Only one shutdown hook
72      * (at max) will be registered for each context instance.
73      * @see java.lang.Runtime#addShutdownHook
74      * @see #close()
75      */

76     void registerShutdownHook();
77
78     /**
79      * Close this application context, releasing all resources and locks that the
80      * implementation might hold. This includes destroying all cached singleton beans.
81      * <p>Note: Does <i>not</i> invoke <code>close</code> on a parent context;
82      * parent contexts have their own, independent lifecycle.
83      * <p>This method can be called multiple times without side effects: Subsequent
84      * <code>close</code> calls on an already closed context will be ignored.
85      */

86     void close();
87
88     /**
89      * Determine whether this application context is active, that is,
90      * whether it has been refreshed at least once and has not been closed yet.
91      * @return whether the context is still active
92      * @see #refresh()
93      * @see #close()
94      * @see #getBeanFactory()
95      */

96     boolean isActive();
97
98     /**
99      * Return the internal bean factory of this application context.
100      * Can be used to access specific functionality of the underlying factory.
101      * <p>Note: Do not use this to post-process the bean factory; singletons
102      * will already have been instantiated before. Use a BeanFactoryPostProcessor
103      * to intercept the BeanFactory setup process before beans get touched.
104      * <p>Generally, this internal factory will only be accessible while the context
105      * is active, that is, inbetween {@link #refresh()} and {@link #close()}.
106      * The {@link #isActive()} flag can be used to check whether the context
107      * is in an appropriate state.
108      * @return the underlying bean factory
109      * @throws IllegalStateException if the context does not hold an internal
110      * bean factory (usually if {@link #refresh()} hasn't been called yet or
111      * if {@link #close()} has already been called)
112      * @see #isActive()
113      * @see #refresh()
114      * @see #close()
115      * @see #addBeanFactoryPostProcessor
116      */

117     ConfigurableListableBeanFactory getBeanFactory() throws IllegalStateException JavaDoc;
118
119 }
120
Popular Tags