KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > container > session > EasyBeansSessionContext


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id$
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.container.session;
27
28 import javax.ejb.EJBLocalObject JavaDoc;
29 import javax.ejb.EJBObject JavaDoc;
30 import javax.ejb.SessionContext JavaDoc;
31 import javax.transaction.Transaction JavaDoc;
32
33 import org.objectweb.easybeans.api.bean.EasyBeansSB;
34 import org.objectweb.easybeans.api.container.EZBSessionContext;
35 import org.objectweb.easybeans.container.EasyBeansEJBContext;
36
37 /**
38  * Defines the Session Context used by Stateless and Stateful beans.
39  * @param <BeanType> Could be a stateless or stateful.
40  * @author Florent Benoit
41  */

42 public class EasyBeansSessionContext<BeanType extends EasyBeansSB> extends EasyBeansEJBContext<BeanType> implements
43         EZBSessionContext<BeanType>, SessionContext JavaDoc {
44
45     /**
46      * Reference to the bean.
47      */

48     private BeanType bean = null;
49
50     /**
51      * Transaction used by this bean. (Used by stateful bean).
52      */

53     private Transaction JavaDoc beanTransaction = null;
54
55     /**
56      * Gets the transaction used by this bean.
57      * @return the bean transaction.
58      */

59     public Transaction JavaDoc getBeanTransaction() {
60         return beanTransaction;
61     }
62
63     /**
64      * Sets the transaction used by this bean.
65      * @param beanTransaction the bean transaction.
66      */

67     public void setBeanTransaction(final Transaction JavaDoc beanTransaction) {
68         this.beanTransaction = beanTransaction;
69     }
70
71     /**
72      * Gets the bean of this context.
73      * @return bean used by this context.
74      */

75     @Override JavaDoc
76     public BeanType getBean() {
77         return this.bean;
78     }
79
80     /**
81      * Build a new Session context.
82      * @param bean the bean on which we are linked.
83      */

84     public EasyBeansSessionContext(final BeanType bean) {
85         super(bean.getEasyBeansFactory());
86         this.bean = bean;
87     }
88
89     /**
90      * Obtain a reference to the EJB local object that is associated with the
91      * instance. An instance of a session enterprise Bean can call this method
92      * at anytime between the ejbCreate() and ejbRemove() methods, including
93      * from within the ejbCreate() and ejbRemove() methods. An instance can use
94      * this method, for example, when it wants to pass a reference to itself in
95      * a method argument or result.
96      * @return The EJB local object currently associated with the instance.
97      * @throws java.lang.IllegalStateException - Thrown if the instance invokes
98      * this method while the instance is in a state that does not allow
99      * the instance to invoke this method, or if the instance does not
100      * have a local interface.
101      */

102     public EJBLocalObject JavaDoc getEJBLocalObject() throws java.lang.IllegalStateException JavaDoc {
103         throw new UnsupportedOperationException JavaDoc();
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 JavaDoc getEJBObject() throws java.lang.IllegalStateException JavaDoc {
120         throw new UnsupportedOperationException JavaDoc();
121     }
122
123     /**
124      * Obtain a reference to the JAX-RPC MessageContext. An instance of a
125      * stateless session bean can call this method from any business method
126      * invoked through its web service endpoint interface.
127      * @return The MessageContext for this web service invocation.
128      * @throws java.lang.IllegalStateException - Thrown if this method is
129      * invoked while the instance is in a state that does not allow
130      * access to this method.
131      */

132     public javax.xml.rpc.handler.MessageContext JavaDoc getMessageContext() throws java.lang.IllegalStateException JavaDoc {
133         throw new UnsupportedOperationException JavaDoc("Not implemented");
134     }
135
136     /**
137      * Obtain an object that can be used to invoke the current bean through the
138      * given business interface.
139      * @param <T> the interface of the bean
140      * @param businessInterface One of the local business interfaces or remote
141      * business interfaces for this session bean.
142      * @return The business object corresponding to the given business
143      * interface.
144      * @throws IllegalStateException - Thrown if this method is invoked with an
145      * invalid business interface for the current bean.
146      */

147     public <T> T getBusinessObject(final Class JavaDoc<T> businessInterface) throws IllegalStateException JavaDoc {
148         throw new UnsupportedOperationException JavaDoc("Not implemented");
149     }
150
151     /**
152      * Obtain the business interface through which the current business method
153      * invocation was made.
154      * @return the business interface through which the current business method
155      * invocation was made.
156      * @throws IllegalStateException - Thrown if this method is called and the
157      * bean has not been invoked through a business interface.
158      */

159     public Class JavaDoc getInvokedBusinessInterface() throws IllegalStateException JavaDoc {
160         throw new UnsupportedOperationException JavaDoc("Not implemented");
161     }
162
163 }
164
Popular Tags