KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > beans > factory > access > BeanFactoryReference


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.beans.factory.access;
18
19 import org.springframework.beans.FatalBeanException;
20 import org.springframework.beans.factory.BeanFactory;
21
22 /**
23  * Used to track a reference to a {@link BeanFactory} obtained through
24  * a {@link BeanFactoryLocator}.
25  *
26  * <p>It is safe to call {@link #release()} multiple times, but
27  * {@link #getFactory()} must not be called after calling release.
28  *
29  * @author Colin Sampaleanu
30  * @see BeanFactoryLocator
31  * @see org.springframework.context.access.ContextBeanFactoryReference
32  */

33 public interface BeanFactoryReference {
34
35     /**
36      * Return the {@link BeanFactory} instance held by this reference.
37      * @throws IllegalStateException if invoked after <code>release()</code> has been called
38      */

39     BeanFactory getFactory();
40
41     /**
42      * Indicate that the {@link BeanFactory} instance referred to by this object is not
43      * needed any longer by the client code which obtained the {@link BeanFactoryReference}.
44      * <p>Depending on the actual implementation of {@link BeanFactoryLocator}, and
45      * the actual type of <code>BeanFactory</code>, this may possibly not actually
46      * do anything; alternately in the case of a 'closeable' <code>BeanFactory</code>
47      * or derived class (such as {@link org.springframework.context.ApplicationContext})
48      * may 'close' it, or may 'close' it once no more references remain.
49      * <p>In an EJB usage scenario this would normally be called from
50      * <code>ejbRemove()</code> and <code>ejbPassivate()</code>.
51      * <p>This is safe to call multiple times.
52      * @throws FatalBeanException if the <code>BeanFactory</code> cannot be released
53      * @see BeanFactoryLocator
54      * @see org.springframework.context.access.ContextBeanFactoryReference
55      * @see org.springframework.context.ConfigurableApplicationContext#close()
56      */

57     void release() throws FatalBeanException;
58
59 }
60
Popular Tags