KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > ejb > SessionSynchronization


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: SessionSynchronization.java 1100 2006-08-16 13:05:31Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package javax.ejb;
27
28 import java.rmi.RemoteException JavaDoc;
29
30 /**
31  * The SessionSynchronization interface allows a session Bean instance to be
32  * notified by its container of transaction boundaries. An session Bean class is
33  * not required to implement this interface. A session Bean class should
34  * implement this interface only if it wishes to synchronize its state with the
35  * transactions.
36  * @see <a HREF="http://www.jcp.org/en/jsr/detail?id=220">EJB 3.0 specification</a>
37  * @author Florent Benoit
38  */

39 public interface SessionSynchronization {
40
41     /**
42      * The afterBegin method notifies a session Bean instance that a new
43      * transaction has started, and that the subsequent business methods on the
44      * instance will be invoked in the context of the transaction. The instance
45      * can use this method, for example, to read data from a database and cache
46      * the data in the instance fields. This method executes in the proper
47      * transaction context.
48      * @throws EJBException Thrown by the method to indicate a failure caused by
49      * a system-level error.
50      * @throws RemoteException This exception is defined in the method signature
51      * to provide backward compatibility for enterprise beans written
52      * for the EJB 1.0 specification. Enterprise beans written for the
53      * EJB 1.1 and higher specifications should throw the
54      * javax.ejb.EJBException instead of this exception. Enterprise
55      * beans written for the EJB 2.0 and higher specifications must not
56      * throw the java.rmi.RemoteException.
57      */

58     void afterBegin() throws EJBException JavaDoc, RemoteException JavaDoc;
59
60     /**
61      * The beforeCompletion method notifies a session Bean instance that a
62      * transaction is about to be committed. The instance can use this method,
63      * for example, to write any cached data to a database. This method executes
64      * in the proper transaction context. Note: The instance may still cause the
65      * container to rollback the transaction by invoking the setRollbackOnly()
66      * method on the instance context, or by throwing an exception.
67      * @throws EJBException Thrown by the method to indicate a failure caused by
68      * a system-level error.
69      * @throws RemoteException This exception is defined in the method signature
70      * to provide backward compatibility for enterprise beans written
71      * for the EJB 1.0 specification. Enterprise beans written for the
72      * EJB 1.1 and higher specification should throw the
73      * javax.ejb.EJBException instead of this exception. Enterprise
74      * beans written for the EJB 2.0 and higher specifications must not
75      * throw the java.rmi.RemoteException.
76      */

77     void beforeCompletion() throws EJBException JavaDoc, RemoteException JavaDoc;
78
79     /**
80      * The afterCompletion method notifies a session Bean instance that a
81      * transaction commit protocol has completed, and tells the instance whether
82      * the transaction has been committed or rolled back. This method executes
83      * with no transaction context. This method executes with no transaction
84      * context.
85      * @param committed True if the transaction has been committed, false if is
86      * has been rolled back.
87      * @throws EJBException Thrown by the method to indicate a failure caused by
88      * a system-level error.
89      * @throws RemoteException This exception is defined in the method signature
90      * to provide backward compatibility for enterprise beans written
91      * for the EJB 1.0 specification. Enterprise beans written for the
92      * EJB 1.1 and higher specification should throw the
93      * javax.ejb.EJBException instead of this exception. Enterprise
94      * beans written for the EJB 2.0 and higher specifications must not
95      * throw the java.rmi.RemoteException.
96      */

97     void afterCompletion(final boolean committed) throws EJBException JavaDoc, RemoteException JavaDoc;
98
99 }
100
Popular Tags