001: /**
002: * EasyBeans
003: * Copyright (C) 2006 Bull S.A.S.
004: * Contact: easybeans@ow2.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$
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.container.session;
025:
026: import javax.ejb.EJBLocalObject;
027: import javax.ejb.EJBObject;
028: import javax.ejb.SessionContext;
029: import javax.transaction.Transaction;
030:
031: import org.ow2.easybeans.api.bean.EasyBeansSB;
032: import org.ow2.easybeans.api.container.EZBSessionContext;
033: import org.ow2.easybeans.container.EasyBeansEJBContext;
034:
035: /**
036: * Defines the Session Context used by Stateless and Stateful beans.
037: * @param <BeanType> Could be a stateless or stateful.
038: * @author Florent Benoit
039: */
040: public class EasyBeansSessionContext<BeanType extends EasyBeansSB>
041: extends EasyBeansEJBContext<BeanType> implements
042: EZBSessionContext<BeanType>, SessionContext {
043:
044: /**
045: * Reference to the bean.
046: */
047: private BeanType bean = null;
048:
049: /**
050: * Transaction used by this bean. (Used by stateful bean).
051: */
052: private Transaction beanTransaction = null;
053:
054: /**
055: * Gets the transaction used by this bean.
056: * @return the bean transaction.
057: */
058: public Transaction getBeanTransaction() {
059: return beanTransaction;
060: }
061:
062: /**
063: * Sets the transaction used by this bean.
064: * @param beanTransaction the bean transaction.
065: */
066: public void setBeanTransaction(final Transaction beanTransaction) {
067: this .beanTransaction = beanTransaction;
068: }
069:
070: /**
071: * Gets the bean of this context.
072: * @return bean used by this context.
073: */
074: @Override
075: public BeanType getBean() {
076: return this .bean;
077: }
078:
079: /**
080: * Build a new Session context.
081: * @param bean the bean on which we are linked.
082: */
083: public EasyBeansSessionContext(final BeanType bean) {
084: super (bean.getEasyBeansFactory());
085: this .bean = bean;
086: }
087:
088: /**
089: * Obtain a reference to the EJB local object that is associated with the
090: * instance. An instance of a session enterprise Bean can call this method
091: * at anytime between the ejbCreate() and ejbRemove() methods, including
092: * from within the ejbCreate() and ejbRemove() methods. An instance can use
093: * this method, for example, when it wants to pass a reference to itself in
094: * a method argument or result.
095: * @return The EJB local object currently associated with the instance.
096: * @throws java.lang.IllegalStateException - Thrown if the instance invokes
097: * this method while the instance is in a state that does not allow
098: * the instance to invoke this method, or if the instance does not
099: * have a local interface.
100: */
101: public EJBLocalObject getEJBLocalObject()
102: throws java.lang.IllegalStateException {
103: throw new UnsupportedOperationException();
104: }
105:
106: /**
107: * Obtain a reference to the EJB object that is currently associated with
108: * the instance. An instance of a session enterprise Bean can call this
109: * method at anytime between the ejbCreate() and ejbRemove() methods,
110: * including from within the ejbCreate() and ejbRemove() methods. An
111: * instance can use this method, for example, when it wants to pass a
112: * reference to itself in a method argument or result.
113: * @return The EJB object currently associated with the instance.
114: * @throws java.lang.IllegalStateException - Thrown if the instance invokes
115: * this method while the instance is in a state that does not allow
116: * the instance to invoke this method, or if the instance does not
117: * have a remote interface.
118: */
119: public EJBObject getEJBObject()
120: throws java.lang.IllegalStateException {
121: throw new UnsupportedOperationException();
122: }
123:
124: /**
125: * Obtain a reference to the JAX-RPC MessageContext. An instance of a
126: * stateless session bean can call this method from any business method
127: * invoked through its web service endpoint interface.
128: * @return The MessageContext for this web service invocation.
129: * @throws java.lang.IllegalStateException - Thrown if this method is
130: * invoked while the instance is in a state that does not allow
131: * access to this method.
132: */
133: public javax.xml.rpc.handler.MessageContext getMessageContext()
134: throws java.lang.IllegalStateException {
135: throw new UnsupportedOperationException("Not implemented");
136: }
137:
138: /**
139: * Obtain an object that can be used to invoke the current bean through the
140: * given business interface.
141: * @param <T> the interface of the bean
142: * @param businessInterface One of the local business interfaces or remote
143: * business interfaces for this session bean.
144: * @return The business object corresponding to the given business
145: * interface.
146: * @throws IllegalStateException - Thrown if this method is invoked with an
147: * invalid business interface for the current bean.
148: */
149: public <T> T getBusinessObject(final Class<T> businessInterface)
150: throws IllegalStateException {
151: throw new UnsupportedOperationException("Not implemented");
152: }
153:
154: /**
155: * Obtain the business interface through which the current business method
156: * invocation was made.
157: * @return the business interface through which the current business method
158: * invocation was made.
159: * @throws IllegalStateException - Thrown if this method is called and the
160: * bean has not been invoked through a business interface.
161: */
162: public Class getInvokedBusinessInterface()
163: throws IllegalStateException {
164: throw new UnsupportedOperationException("Not implemented");
165: }
166:
167: }
|