001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036: package javax.ejb;
037:
038: import java.util.*;
039: import java.security.Identity;
040: import javax.xml.rpc.handler.MessageContext;
041:
042: /**
043: * The SessionContext interface provides access to the runtime session context
044: * that the container provides for a session enterprise Bean instance. The
045: * container passes the SessionContext interface to an instance after the
046: * instance has been created. The session context remains associated with
047: * the instance for the lifetime of the instance.
048: */
049: public interface SessionContext extends EJBContext {
050: /**
051: * Obtain a reference to the EJB local object that is
052: * associated with the instance.
053: *
054: * <p> An instance of a session enterprise Bean can call this method
055: * at anytime between the ejbCreate() and ejbRemove() methods, including
056: * from within the ejbCreate() and ejbRemove() methods.
057: *
058: * <p> An instance can use this method, for example, when it wants to
059: * pass a reference to itself in a method argument or result.
060: *
061: * @return The EJB local object currently associated with the instance.
062: *
063: * @exception IllegalStateException Thrown if the instance invokes this
064: * method while the instance is in a state that does not allow the
065: * instance to invoke this method, or if the instance does not have
066: * a local interface.
067: */
068: EJBLocalObject getEJBLocalObject() throws IllegalStateException;
069:
070: /**
071: * Obtain a reference to the EJB object that is currently associated with
072: * the instance.
073: *
074: * <p> An instance of a session enterprise Bean can call this method
075: * at anytime between the ejbCreate() and ejbRemove() methods, including
076: * from within the ejbCreate() and ejbRemove() methods.
077: *
078: * <p> An instance can use this method, for example, when it wants to
079: * pass a reference to itself in a method argument or result.
080: *
081: * @return The EJB object currently associated with the instance.
082: *
083: * @exception IllegalStateException Thrown if the instance invokes this
084: * method while the instance is in a state that does not allow the
085: * instance to invoke this method, or if the instance does not have
086: * a remote interface.
087: */
088: EJBObject getEJBObject() throws IllegalStateException;
089:
090: /**
091: * Obtain a reference to the JAX-RPC MessageContext.
092: *
093: * <p> An instance of a stateless session bean can call this method
094: * from any business method invoked through its web service
095: * endpoint interface.
096: *
097: * @return The MessageContext for this web service invocation.
098: *
099: * @exception IllegalStateException Thrown if this method is invoked
100: * while the instance is in a state that does not allow access
101: * to this method.
102: */
103: MessageContext getMessageContext() throws IllegalStateException;
104:
105: /**
106: * Obtain an object that can be used to invoke the current bean through
107: * the given business interface.
108: *
109: * @param businessInterface One of the local business interfaces
110: * or remote business interfaces for this session bean.
111: *
112: * @return The business object corresponding to the given business
113: * interface.
114: *
115: * @exception IllegalStateException Thrown if this method is invoked
116: * with an invalid business interface for the current bean.
117: */
118: <T> T getBusinessObject(Class<T> businessInterface)
119: throws IllegalStateException;
120:
121: /**
122: * Obtain the business interface through which the current business
123: * method invocation was made.
124: *
125: * @exception IllegalStateException Thrown if this method is called
126: * and the bean has not been invoked through a business interface.
127: */
128: Class getInvokedBusinessInterface() throws IllegalStateException;
129:
130: }
|