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: SFSBSimpleBeanOverrided.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.common.ejbs.stateful.containermanaged.xmldescriptor;
025:
026: import javax.ejb.Local;
027: import javax.ejb.Remote;
028: import javax.ejb.Stateful;
029: import javax.ejb.TransactionManagement;
030: import javax.ejb.TransactionManagementType;
031: import javax.naming.NamingException;
032: import javax.transaction.HeuristicMixedException;
033: import javax.transaction.HeuristicRollbackException;
034: import javax.transaction.NotSupportedException;
035: import javax.transaction.RollbackException;
036: import javax.transaction.SystemException;
037: import javax.transaction.UserTransaction;
038:
039: import org.ow2.easybeans.tests.common.exception.TransactionException;
040: import org.ow2.easybeans.tests.common.helper.TransactionHelper;
041:
042: /**
043: * Used to verify if the deployment descriptor overrides the annotation. The
044: * deployment descriptor defines: <ul>
045: * <li>The session bean as stateful. The session type cannot be overrided (page 491-FINAL REALEASE);</li>
046: * <li>The bean name: SLSBSimpleBeanOverrideLocal;</li>
047: * <li>The transaction
048: * type as Bean;</li>
049: * <li>The local interface: ItfSimpleBeanOverridedLocal;</li>
050: * <li>The remote interface: ItfSimpleBeanOverridedRemote.</li> </ul>
051: * @author Gisele Pinheiro Souza
052: * @author Eduardo Studzinski Estima de Castro
053: */
054: @Stateful(name="SFSBSimpleBeanByAnnotation")
055: @TransactionManagement(TransactionManagementType.CONTAINER)
056: @Local(ItfSimpleBeanOverridedRemote.class)
057: @Remote(ItfSimpleBeanOverridedLocal.class)
058: public class SFSBSimpleBeanOverrided implements
059: ItfSimpleBeanOverridedLocal, ItfSimpleBeanOverridedRemote {
060:
061: /**
062: * Opens a transaction without close. If the bean is stateless, this method
063: * call will throw an EJBException.However, for a stateful the method will
064: * be executed without problem.
065: * @throws NamingException if a problem to get the transaction occurs.
066: * @throws NotSupportedException if the bean is already associated with a transaction.
067: * @throws SystemException if an unexpected error occurs during the transaction.
068: */
069: public void openTransaction() throws NamingException,
070: NotSupportedException, SystemException {
071: UserTransaction utx = TransactionHelper.getUserTransaction();
072: utx.begin();
073: }
074:
075: /**
076: * Verifies if the bean has a bean-managed transaction. If the transaction
077: * type is defined as container managed transaction, this method must throw
078: * an exception.
079: * @throws IllegalStateException if begin or commit is not permit
080: * @throws SecurityException if an unexpected error occurs.
081: * @throws HeuristicMixedException if an unexpected error occurs.
082: * @throws NamingException if a lookup error occurs.
083: * @throws SystemException if an unexpected error occurs.
084: * @throws NotSupportedException if the resquest cannot be made.
085: * @throws HeuristicRollbackException if a heuristic decision was made and
086: * some relevant update was rolled back.
087: * @throws RollbackException if the transaction was rolled back instead of
088: * committed.
089: * @throws HeuristicMixedException if a heuristic decision was made and some
090: * relevant update was commited and others rolled back.
091: */
092: public void verifyBMT() throws IllegalStateException,
093: SecurityException, HeuristicMixedException,
094: HeuristicRollbackException, RollbackException,
095: SystemException, NotSupportedException, NamingException {
096: UserTransaction utx = TransactionHelper.getUserTransaction();
097: utx.begin();
098: utx.commit();
099: }
100: }
|