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