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.rmi.RemoteException;
039:
040: /**
041: * <p> The SessionSynchronization interface allows a session Bean instance
042: * to be notified by its container of transaction boundaries.
043: *
044: * <p> An session Bean class is not required to implement this interface.
045: * A session Bean class should implement this interface only if it wishes
046: * to synchronize its state with the transactions.
047: */
048: public interface SessionSynchronization {
049: /**
050: * The afterBegin method notifies a session Bean instance that a new
051: * transaction has started, and that the subsequent business methods on the
052: * instance will be invoked in the context of the transaction.
053: *
054: * <p> The instance can use this method, for example, to read data
055: * from a database and cache the data in the instance fields.
056: *
057: * <p> This method executes in the proper transaction context.
058: *
059: * @exception EJBException Thrown by the method to indicate a failure
060: * caused by a system-level error.
061: *
062: * @exception RemoteException This exception is defined in the method
063: * signature to provide backward compatibility for enterprise beans
064: * written for the EJB 1.0 specification. Enterprise beans written
065: * for the EJB 1.1 and higher specifications should throw the
066: * javax.ejb.EJBException instead of this exception.
067: * Enterprise beans written for the EJB 2.0 and higher specifications
068: * must not throw the java.rmi.RemoteException.
069: */
070: public void afterBegin() throws EJBException, RemoteException;
071:
072: /**
073: * The beforeCompletion method notifies a session Bean instance that
074: * a transaction is about to be committed. The instance can use this
075: * method, for example, to write any cached data to a database.
076: *
077: * <p> This method executes in the proper transaction context.
078: *
079: * <p><b>Note:</b> The instance may still cause the container to
080: * rollback the transaction by invoking the setRollbackOnly() method
081: * on the instance context, or by throwing an exception.
082: *
083: * @exception EJBException Thrown by the method to indicate a failure
084: * caused by a system-level error.
085: *
086: * @exception RemoteException This exception is defined in the method
087: * signature to provide backward compatibility for enterprise beans
088: * written for the EJB 1.0 specification. Enterprise beans written
089: * for the EJB 1.1 and higher specification should throw the
090: * javax.ejb.EJBException instead of this exception.
091: * Enterprise beans written for the EJB 2.0 and higher specifications
092: * must not throw the java.rmi.RemoteException.
093: */
094: public void beforeCompletion() throws EJBException, RemoteException;
095:
096: /**
097: * The afterCompletion method notifies a session Bean instance that a
098: * transaction commit protocol has completed, and tells the instance
099: * whether the transaction has been committed or rolled back.
100: *
101: * <p> This method executes with no transaction context.
102: *
103: * <p> This method executes with no transaction context.
104: *
105: * @param committed True if the transaction has been committed, false
106: * if is has been rolled back.
107: *
108: * @exception EJBException Thrown by the method to indicate a failure
109: * caused by a system-level error.
110: *
111: * @exception RemoteException This exception is defined in the method
112: * signature to provide backward compatibility for enterprise beans
113: * written for the EJB 1.0 specification. Enterprise beans written
114: * for the EJB 1.1 and higher specification should throw the
115: * javax.ejb.EJBException instead of this exception.
116: * Enterprise beans written for the EJB 2.0 and higher specifications
117: * must not throw the java.rmi.RemoteException.
118: */
119: public void afterCompletion(boolean committed) throws EJBException,
120: RemoteException;
121: }
|