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: SFSBTransAttributeDefinition.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.TransactionAttribute;
027: import javax.ejb.TransactionAttributeType;
028:
029: import org.ow2.easybeans.tests.common.db.TableManager;
030:
031: /**
032: * Adds values in the database to verify the transaction attribute that id
033: * defined by deployment descriptor.
034: * @author Gisele Pinheiro Souza
035: * @author Eduardo Studzinski Estima de Castro
036: */
037: public class SFSBTransAttributeDefinition implements
038: ItfTransAttributeDefinition {
039:
040: /**
041: * Inserts a table the database.
042: * @param dbName is the name of the database in the registry.
043: * @param tableName is the table name.
044: * @throws Exception if an error occurs.
045: */
046: protected void insertTable(final String dbName,
047: final String tableName) throws Exception {
048: TableManager tableManager = new TableManager(dbName);
049: tableManager.insertTable(tableName);
050: }
051:
052: /**
053: * Inserts a table the database. The transaction attribute is defined in the
054: * deployment descriptor.
055: * @param dbName is the name of the database in the registry.
056: * @param tableName is the table name.
057: * @throws Exception if an error occurs.
058: */
059: public void insertTableCorrect(final String dbName,
060: final String tableName) throws Exception {
061: insertTable(dbName, tableName);
062: }
063:
064: /**
065: * Inserts a table the database. The transaction attribute is defined in the
066: * deployment descriptor.
067: * @param dbName is the name of the database in the registry.
068: * @param tableName is the table name.
069: * @throws Exception if an error occurs.
070: */
071: public void insertTableError(final String dbName,
072: final String tableName) throws Exception {
073: insertTable(dbName, tableName);
074: throw new RuntimeException();
075: }
076:
077: /**
078: * Inserts a table the database. The transaction attribute is defined in the
079: * deployment descriptor.
080: * @param dbName is the name of the database in the registry.
081: * @param tableName is the table name.
082: * @throws Exception if an error occurs.
083: */
084: @TransactionAttribute(TransactionAttributeType.MANDATORY)
085: public void insertTableCorrectMandatory(final String dbName,
086: final String tableName) throws Exception {
087: insertTable(dbName, tableName);
088: }
089:
090: /**
091: * Inserts a table the database. The transaction attribute is defined in the
092: * deployment descriptor.
093: * @param dbName is the name of the database in the registry.
094: * @param tableName is the table name.
095: * @throws Exception if an error occurs.
096: */
097: @TransactionAttribute(TransactionAttributeType.MANDATORY)
098: public void insertTableErrorMandatory(final String dbName,
099: final String tableName) throws Exception {
100: insertTable(dbName, tableName);
101: throw new RuntimeException();
102: }
103:
104: }
|