1. /*
  2. * Copyright 2002-2004 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. package org.springframework.ejb.support;
  17. import javax.ejb.SessionBean;
  18. import javax.ejb.SessionContext;
  19. /**
  20. * Superclass for all session beans, not intended for direct client subclassing.
  21. *
  22. * <p>This class saves the session context provided by the EJB container in an instance
  23. * variable and provides a NOP implementation of the ejbRemove() lifecycle method.
  24. *
  25. * @version $Id: AbstractSessionBean.java,v 1.4 2004/03/18 02:46:14 trisberg Exp $
  26. * @author Rod Johnson
  27. */
  28. abstract class AbstractSessionBean extends AbstractEnterpriseBean implements SessionBean {
  29. /** the SessionContext passed to this object */
  30. private SessionContext sessionContext;
  31. /**
  32. * Sets the session context.
  33. * <p><b>If overriding this method, be sure to invoke this form of it first.</b>
  34. * @param sessionContext SessionContext context for session
  35. */
  36. public void setSessionContext(SessionContext sessionContext) {
  37. this.sessionContext = sessionContext;
  38. }
  39. /**
  40. * Convenience method for subclasses.
  41. * Return the EJB context saved on initialization.
  42. * @return the SessionContext saved on initialization by this class's
  43. * implementation of the setSessionContext() method.
  44. */
  45. protected final SessionContext getSessionContext() {
  46. return sessionContext;
  47. }
  48. }