001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: SessionContext.java 1100 2006-08-16 13:05:31Z benoitf $
023: * --------------------------------------------------------------------------
024: */package javax.ejb;
025:
026: import javax.xml.rpc.handler.MessageContext;
027:
028: /**
029: * Context provided by Session Bean.
030: * @see <a href="http://www.jcp.org/en/jsr/detail?id=220">EJB 3.0 specification</a>
031: * @author Florent Benoit
032: */
033: public interface SessionContext extends EJBContext {
034:
035: /**
036: * Obtain a reference to the EJB local object that is associated with the
037: * instance. An instance of a session enterprise Bean can call this method
038: * at anytime between the ejbCreate() and ejbRemove() methods, including
039: * from within the ejbCreate() and ejbRemove() methods. An instance can use
040: * this method, for example, when it wants to pass a reference to itself in
041: * a method argument or result.
042: * @return The EJB local object currently associated with the instance.
043: * @throws IllegalStateException - Thrown if the instance invokes this
044: * method while the instance is in a state that does not allow the
045: * instance to invoke this method, or if the instance does not have
046: * a local interface.
047: */
048: EJBLocalObject getEJBLocalObject() throws IllegalStateException;
049:
050: /**
051: * Obtain a reference to the EJB object that is currently associated with
052: * the instance. An instance of a session enterprise Bean can call this
053: * method at anytime between the ejbCreate() and ejbRemove() methods,
054: * including from within the ejbCreate() and ejbRemove() methods. An
055: * instance can use this method, for example, when it wants to pass a
056: * reference to itself in a method argument or result.
057: * @return The EJB object currently associated with the instance.
058: * @throws IllegalStateException - Thrown if the instance invokes this
059: * method while the instance is in a state that does not allow the
060: * instance to invoke this method, or if the instance does not have
061: * a remote interface.
062: */
063: EJBObject getEJBObject() throws IllegalStateException;
064:
065: /**
066: * Obtain a reference to the JAX-RPC MessageContext. An instance of a
067: * stateless session bean can call this method from any business method
068: * invoked through its web service endpoint interface.
069: * @return The MessageContext for this web service invocation.
070: * @throws IllegalStateException - Thrown if this method is invoked while
071: * the instance is in a state that does not allow access to this
072: * method.
073: */
074: MessageContext getMessageContext() throws IllegalStateException;
075:
076: /**
077: * Obtain an object that can be used to invoke the current bean through the
078: * given business interface.
079: * @param <T> the interface of the bean
080: * @param businessInterface One of the local business interfaces or remote
081: * business interfaces for this session bean.
082: * @return The business object corresponding to the given business
083: * interface.
084: * @throws IllegalStateException - Thrown if this method is invoked with an
085: * invalid business interface for the current bean.
086: * @since EJB 3.0 version.
087: */
088: <T> T getBusinessObject(Class<T> businessInterface)
089: throws IllegalStateException;
090:
091: /**
092: * Obtain the business interface through which the current business method
093: * invocation was made.
094: * @return the business interface through which the current business method
095: * invocation was made.
096: * @throws IllegalStateException - Thrown if this method is called and the
097: * bean has not been invoked through a business interface.
098: * @since EJB 3.0 version.
099: */
100: Class getInvokedBusinessInterface() throws IllegalStateException;
101:
102: }
|