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: ContainerTransactionRequiredNew.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.naming.NamingException;
031:
032: import org.ow2.easybeans.tests.common.exception.TransactionException;
033:
034: /**
035: * Inserts the table test in two databases using the annotation @TransactionAttribute(REQUIRED_NEW) 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 ContainerTransactionRequiredNew extends
042: ContainerTransaction {
043:
044: /**
045: * Inserts the table test in both database using required new transaction.
046: * @param db1 the first databse name.
047: * @param db2 the second database name.
048: * @throws Exception if an error occurs.
049: */
050: @TransactionAttribute(value=TransactionAttributeType.REQUIRES_NEW)
051: @Override
052: public void insertCorrectTableInBothDB(final String db1,
053: final String db2) throws Exception {
054: super .insertCorrectTableInBothDB(db1, db2);
055: }
056:
057: /**
058: * Inserts the table test in the first database and makes an incorrect query in the second database.
059: * This method is using required new transaction, so this must to force a roll back.
060: * @param db1 the first databse name.
061: * @param db2 the second database name.
062: * @throws Exception if an error occurs.
063: */
064: @TransactionAttribute(value=TransactionAttributeType.REQUIRES_NEW)
065: @Override
066: public void insertCorrectFirstErrorSecond(final String db1,
067: final String db2) throws Exception {
068: super .insertCorrectFirstErrorSecond(db1, db2);
069: }
070:
071: /**
072: * Calls the method EJBContext.getRollbackOnly().
073: * @return true if the rollback only is set, false otherwise.
074: * @throws TransactionException if an IllegalStateException occurs.
075: */
076: @Override
077: @TransactionAttribute(value=TransactionAttributeType.REQUIRES_NEW)
078: public boolean getRollbackOnly() throws TransactionException {
079: return super .getRollbackOnly();
080: }
081:
082: /**
083: * Calls the method SessionContext.setRollbackOnly().
084: * @param dbName1 the first database where the table should be inserted.
085: * @param dbName2 the second database where the table should be inserted.
086: * @throws Exception if an error occurs.
087: */
088: @Override
089: @TransactionAttribute(value=TransactionAttributeType.REQUIRES_NEW)
090: public void setRollbackOnly(final String dbName1,
091: final String dbName2) throws Exception, NamingException {
092: super .setRollbackOnly(dbName1, dbName2);
093: }
094:
095: /**
096: * @see org.ow2.easybeans.tests.common.ejbs.base.transaction.ContainerTransaction
097: * @param db1 the name of the first database.
098: * @param db2 the name of the second database.
099: * @throws Exception if an error during the execution occurs.
100: */
101: @Override
102: @TransactionAttribute(value=TransactionAttributeType.REQUIRES_NEW)
103: public void insertTablesUsingAuxBeanReq(final String db1,
104: final String db2) throws Exception {
105: super .insertTablesUsingAuxBeanReq(db1, db2);
106: }
107:
108: /**
109: * @see org.ow2.easybeans.tests.common.ejbs.base.transaction.ContainerTransaction
110: * @param db1 the name of the first database.
111: * @param db2 the name of the second database.
112: * @throws Exception if an error during the execution occurs.
113: */
114: @Override
115: @TransactionAttribute(value=TransactionAttributeType.REQUIRES_NEW)
116: public void insertTablesUsingAuxBeanNotSup(final String db1,
117: final String db2) throws Exception {
118: super .insertTablesUsingAuxBeanNotSup(db1, db2);
119: }
120:
121: /**
122: * @see org.ow2.easybeans.tests.common.ejbs.base.transaction.ContainerTransaction
123: * @throws Exception if an error occurs.
124: */
125: @Override
126: @TransactionAttribute(value=TransactionAttributeType.REQUIRES_NEW)
127: public void getUserTransactionWithLookup() throws Exception {
128: super .getUserTransactionWithLookup();
129: }
130:
131: /**
132: * @see org.ow2.easybeans.tests.common.ejbs.base.transaction.ContainerTransaction
133: * @throws Exception if an error occurs.
134: */
135: @Override
136: @TransactionAttribute(value=TransactionAttributeType.REQUIRES_NEW)
137: public void getUserTransactionWithEJBContext() throws Exception {
138: super.getUserTransactionWithEJBContext();
139: }
140: }
|