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: ContainerTransactionMandatory.java 1970 2007-10-16 11:49:25Z benoitf $
023: * --------------------------------------------------------------------------
024: */package org.ow2.easybeans.tests.common.ejbs.base.transaction;
025:
026: import javax.ejb.TransactionAttribute;
027: import javax.ejb.TransactionAttributeType;
028: import javax.ejb.TransactionManagement;
029: import javax.ejb.TransactionManagementType;
030: import javax.transaction.RollbackException;
031:
032: import org.ow2.easybeans.tests.common.exception.TransactionException;
033:
034: /**
035: * Inserts the table test in two databases using the annotation @TransactionAttribute(MANDATORY) in all methods.
036: * @author Gisele Pinheiro Souza
037: * @author Eduardo Studzinski Estima de Castro
038: *
039: */
040: @TransactionManagement(value=TransactionManagementType.CONTAINER)
041: public class ContainerTransactionMandatory extends ContainerTransaction {
042:
043: /**
044: * Inserts the table test in both database using mandatory transaction.
045: * @param db1 the name of the first database.
046: * @param db2 the name of the second databse.
047: * @throws Exception if an error occurs.
048: */
049: @TransactionAttribute(value=TransactionAttributeType.MANDATORY)
050: @Override
051: public void insertCorrectTableInBothDB(final String db1,
052: final String db2) throws Exception {
053: super .insertCorrectTableInBothDB(db1, db2);
054: }
055:
056: /**
057: * Inserts the table test in the first database and makes an incorrect query
058: * in the second database. This method is using mandatory transaction, so
059: * this must to force a roll back if the client calls with a transaction
060: * context, or must to throw a TransactionRequiredException if the client
061: * has not transaction context.
062: * @param db1 the name of the first database.
063: * @param db2 the name of the second databse.
064: * @throws Exception if an error occurs.
065: */
066: @TransactionAttribute(value=TransactionAttributeType.MANDATORY)
067: @Override
068: public void insertCorrectFirstErrorSecond(final String db1,
069: final String db2) throws Exception {
070: super .insertCorrectFirstErrorSecond(db1, db2);
071: }
072:
073: /**
074: * Calls the method EJBContext.getRollbackOnly().
075: * @return true if the rollback only is set, false otherwise.
076: * @throws TransactionException if an IllegalStateException occurs.
077: */
078: @Override
079: @TransactionAttribute(value=TransactionAttributeType.MANDATORY)
080: public boolean getRollbackOnly() throws TransactionException {
081: return super .getRollbackOnly();
082: }
083:
084: /**
085: * Calls the method SessionContext.setRollbackOnly().
086: * @param dbName1 the first database where the table should be inserted.
087: * @param dbName2 the second database where the table should be inserted.
088: * @throws Exception if an error occurs.
089: */
090: @Override
091: @TransactionAttribute(value=TransactionAttributeType.MANDATORY)
092: public void setRollbackOnly(final String dbName1,
093: final String dbName2) throws Exception {
094: super .setRollbackOnly(dbName1, dbName2);
095: }
096:
097: /**
098: * @see org.ow2.easybeans.tests.common.ejbs.base.transaction.ContainerTransaction
099: * @param db1 the name of the first database.
100: * @param db2 the name of the second database.
101: * @throws Exception if an error during the execution occurs.
102: */
103: @Override
104: @TransactionAttribute(value=TransactionAttributeType.MANDATORY)
105: public void insertTablesUsingAuxBeanReq(final String db1,
106: final String db2) throws Exception {
107: super .insertTablesUsingAuxBeanReq(db1, db2);
108: }
109:
110: /**
111: * @see org.ow2.easybeans.tests.common.ejbs.base.transaction.ContainerTransaction
112: * @param db1 the name of the first database.
113: * @param db2 the name of the second database.
114: * @throws Exception if an error during the execution occurs.
115: */
116: @Override
117: @TransactionAttribute(value=TransactionAttributeType.MANDATORY)
118: public void insertTablesUsingAuxBeanNotSup(final String db1,
119: final String db2) throws Exception {
120: super .insertTablesUsingAuxBeanNotSup(db1, db2);
121: }
122:
123: /**
124: * @see org.ow2.easybeans.tests.common.ejbs.base.transaction.ContainerTransaction
125: * @throws Exception if an error occurs.
126: */
127: @Override
128: @TransactionAttribute(value=TransactionAttributeType.MANDATORY)
129: public void getUserTransactionWithLookup() throws Exception {
130: super .getUserTransactionWithLookup();
131: }
132:
133: /**
134: * @see org.ow2.easybeans.tests.common.ejbs.base.transaction.ContainerTransaction
135: * @throws Exception if an error occurs..
136: */
137: @Override
138: @TransactionAttribute(value=TransactionAttributeType.MANDATORY)
139: public void getUserTransactionWithEJBContext() throws Exception,
140: RollbackException {
141: super.getUserTransactionWithEJBContext();
142: }
143:
144: }
|