KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > ejb > support > AbstractStatefulSessionBean


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.ejb.support;
18
19 import org.springframework.beans.BeansException;
20 import org.springframework.beans.FatalBeanException;
21
22 /**
23  * Convenient superclass for stateful session beans.
24  * SFSBs should extend this class, leaving them to implement the
25  * <code>ejbActivate()</code> and <code>ejbPassivate()</code> lifecycle
26  * methods to comply with the requirements of the EJB specification.
27  *
28  * <p><b>Note: Subclasses should invoke the <code>loadBeanFactory()</code>
29  * method in their custom <code>ejbCreate()</code> and <code>ejbActivate()</code>
30  * methods, and should invoke the <code>unloadBeanFactory()</code> method in
31  * their <code>ejbPassivate</code> method.</b>
32  *
33  * <p><b>Note: The default BeanFactoryLocator used by this class's superclass
34  * (ContextJndiBeanFactoryLocator) is <b>not</b> serializable. Therefore,
35  * when using the default BeanFactoryLocator, or another variant which is
36  * not serializable, subclasses must call <code>setBeanFactoryLocator(null)</code>
37  * in <code>ejbPassivate()</code>, with a corresponding call to
38  * <code>setBeanFactoryLocator(xxx)</code> in <code>ejbActivate()</code>
39  * unless relying on the default locator.
40  *
41  * @author Rod Johnson
42  * @author Colin Sampaleanu
43  * @see org.springframework.context.access.ContextJndiBeanFactoryLocator
44  */

45 public abstract class AbstractStatefulSessionBean extends AbstractSessionBean {
46
47     /**
48      * Load a Spring BeanFactory namespace. Exposed for subclasses
49      * to load a BeanFactory in their <code>ejbCreate()</code> methods.
50      * Those callers would normally want to catch BeansException and
51      * rethrow it as {@link javax.ejb.CreateException}. Unless the
52      * BeanFactory is known to be serializable, this method must also
53      * be called from <code>ejbActivate()</code>, to reload a context
54      * removed via a call to <code>unloadBeanFactory()</code> from
55      * the <code>ejbPassivate()</code> implementation.
56      */

57     protected void loadBeanFactory() throws BeansException {
58         super.loadBeanFactory();
59     }
60
61     /**
62      * Unload the Spring BeanFactory instance. The default <code>ejbRemove</code>
63      * method invokes this method, but subclasses which override
64      * <code>ejbRemove</code> must invoke this method themselves.
65      * <p>Unless the BeanFactory is known to be serializable, this method
66      * must also be called from <code>ejbPassivate()</code>, with a corresponding
67      * call to <code>loadBeanFactory()</code> from <code>ejbActivate()</code>.
68      */

69     protected void unloadBeanFactory() throws FatalBeanException {
70         super.unloadBeanFactory();
71     }
72
73 }
74
Popular Tags