01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package javax.ejb;
23:
24: import java.rmi.RemoteException;
25:
26: /**
27: * <P>The SessionSynchronization interface allows a session Bean instance
28: * to be notified by its container of transaction boundaries.</P>
29: *
30: * <P>An session Bean class is not required to implement this interface. A
31: * session Bean class should implement this interface only if it wishes to
32: * synchronize its state with the transactions.</P>
33: */
34: public interface SessionSynchronization {
35:
36: /**
37: * <P>The afterBegin method notifies a session Bean instance that a new transaction has started, and that
38: * the subsequent business methods on the instance will be invoked in the context of the transaction.</P>
39: *
40: * <P>The instance can use this method, for example, to read data from a database and cache the data in
41: * the instance fields.</P>
42: *
43: * <P>This method executes in the proper transaction context.</P>
44: *
45: * @exception EJBException - Thrown by the method to indicate a failure caused by a system-level error.
46: * @exception java.rmi.RemoteException - This exception is defined in the method signature to provide backward
47: * compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the
48: * EJB 1.1 and higher specifications should throw the javax.ejb.EJBException instead of this exception.
49: * Enterprise beans written for the EJB 2.0 and higher specifications must not throw the java.rmi.RemoteException.
50: */
51: public void afterBegin() throws EJBException, RemoteException;
52:
53: /**
54: * <P>The beforeCompletion method notifies a session Bean instance that a transaction is about to be committed.
55: * The instance can use this method, for example, to write any cached data to a database.</P>
56: *
57: * <P>This method executes in the proper transaction context.</P>
58: *
59: * <P><B>Note:</B> The instance may still cause the container to rollback the transaction by invoking the
60: * setRollbackOnly() method on the instance context, or by throwing an exception.</P>
61: *
62: * @exception EJBException - Thrown by the method to indicate a failure caused by a system-level error.
63: * @exception java.rmi.RemoteException - This exception is defined in the method signature to provide backward
64: * compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the
65: * EJB 1.1 and higher specifications should throw the javax.ejb.EJBException instead of this exception.
66: * Enterprise beans written for the EJB 2.0 and higher specifications must not throw the java.rmi.RemoteException.
67: */
68: public void beforeCompletion() throws EJBException, RemoteException;
69:
70: /**
71: * <P>The afterCompletion method notifies a session Bean instance that a transaction commit protocol has
72: * completed, and tells the instance whether the transaction has been committed or rolled back.</P>
73: *
74: * <P>This method executes with no transaction context.</P>
75: *
76: * <P>This method executes with no transaction context.</P>
77: *
78: * @param committed - True if the transaction has been committed, false if is has been rolled back.
79: * @exception EJBException - Thrown by the method to indicate a failure caused by a system-level error.
80: * @exception java.rmi.RemoteException - This exception is defined in the method signature to provide backward
81: * compatibility for enterprise beans written for the EJB 1.0 specification. Enterprise beans written for the
82: * EJB 1.1 and higher specifications should throw the javax.ejb.EJBException instead of this exception.
83: * Enterprise beans written for the EJB 2.0 and higher specifications must not throw the java.rmi.RemoteException.
84: */
85: public void afterCompletion(boolean committed) throws EJBException,
86: RemoteException;
87: }
|