KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > stateful > containermanaged > xmldescriptor > SFSBTransAttributeDefinition


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: SFSBTransAttributeDefinition.java 659 2006-06-15 13:41:59Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.xmldescriptor;
26
27 import javax.ejb.TransactionAttribute JavaDoc;
28 import javax.ejb.TransactionAttributeType JavaDoc;
29
30 import org.objectweb.easybeans.tests.common.db.TableManager;
31
32 /**
33  * Adds values in the database to verify the transaction attribute that id
34  * defined by deployment descriptor.
35  * @author Gisele Pinheiro Souza
36  * @author Eduardo Studzinski Estima de Castro
37  */

38 public class SFSBTransAttributeDefinition implements ItfTransAttributeDefinition {
39
40     /**
41      * Inserts a table the database.
42      * @param dbName is the name of the database in the registry.
43      * @param tableName is the table name.
44      * @throws Exception if an error occurs.
45      */

46     protected void insertTable(final String JavaDoc dbName, final String JavaDoc tableName) throws Exception JavaDoc {
47         TableManager tableManager = new TableManager(dbName);
48         tableManager.insertTable(tableName);
49     }
50
51     /**
52      * Inserts a table the database. The transaction attribute is defined in the
53      * deployment descriptor.
54      * @param dbName is the name of the database in the registry.
55      * @param tableName is the table name.
56      * @throws Exception if an error occurs.
57      */

58     public void insertTableCorrect(final String JavaDoc dbName, final String JavaDoc tableName) throws Exception JavaDoc{
59         insertTable(dbName, tableName);
60     }
61
62     /**
63      * Inserts a table the database. The transaction attribute is defined in the
64      * deployment descriptor.
65      * @param dbName is the name of the database in the registry.
66      * @param tableName is the table name.
67      * @throws Exception if an error occurs.
68      */

69     public void insertTableError(final String JavaDoc dbName, final String JavaDoc tableName) throws Exception JavaDoc{
70         insertTable(dbName, tableName);
71         throw new RuntimeException JavaDoc();
72     }
73
74     /**
75      * Inserts a table the database. The transaction attribute is defined in the
76      * deployment descriptor.
77      * @param dbName is the name of the database in the registry.
78      * @param tableName is the table name.
79      * @throws Exception if an error occurs.
80      */

81     @TransactionAttribute JavaDoc(TransactionAttributeType.MANDATORY)
82     public void insertTableCorrectMandatory(final String JavaDoc dbName, final String JavaDoc tableName) throws Exception JavaDoc{
83         insertTable(dbName, tableName);
84     }
85
86     /**
87      * Inserts a table the database. The transaction attribute is defined in the
88      * deployment descriptor.
89      * @param dbName is the name of the database in the registry.
90      * @param tableName is the table name.
91      * @throws Exception if an error occurs.
92      */

93     @TransactionAttribute JavaDoc(TransactionAttributeType.MANDATORY)
94     public void insertTableErrorMandatory(final String JavaDoc dbName, final String JavaDoc tableName) throws Exception JavaDoc{
95         insertTable(dbName, tableName);
96         throw new RuntimeException JavaDoc();
97     }
98
99
100 }
101
Popular Tags