01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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 javax.ejb.SessionContext;
20:
21: /**
22: * Base class for all Spring-based EJB session beans. Not intended for direct
23: * subclassing: Extend {@link AbstractStatelessSessionBean} or
24: * {@link AbstractStatefulSessionBean} instead.
25: *
26: * <p>This class saves the session context provided by the EJB container in an
27: * instance variable and exposes it through the {@link SmartSessionBean} interface.
28: *
29: * @author Rod Johnson
30: * @author Juergen Hoeller
31: */
32: public abstract class AbstractSessionBean extends
33: AbstractEnterpriseBean implements SmartSessionBean {
34:
35: /** The SessionContext passed to this EJB */
36: private SessionContext sessionContext;
37:
38: /**
39: * Set the session context for this EJB.
40: * <p><b>When overriding this method, be sure to invoke this form of it first.</b>
41: */
42: public void setSessionContext(SessionContext sessionContext) {
43: this .sessionContext = sessionContext;
44: }
45:
46: /**
47: * Convenience method for subclasses, returning the EJB session context
48: * saved on initialization ({@link #setSessionContext}).
49: */
50: public final SessionContext getSessionContext() {
51: return this.sessionContext;
52: }
53:
54: }
|