KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > base > transaction > ContainerTransactionMandatory


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: ContainerTransactionMandatory.java 808 2006-07-03 13:58:29Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.base.transaction;
26
27 import javax.ejb.TransactionAttribute JavaDoc;
28 import javax.ejb.TransactionAttributeType JavaDoc;
29 import javax.ejb.TransactionManagement JavaDoc;
30 import javax.ejb.TransactionManagementType JavaDoc;
31 import javax.transaction.RollbackException JavaDoc;
32
33 import org.objectweb.easybeans.tests.common.exception.TransactionException;
34
35 /**
36  * Inserts the table test in two databases using the annotation @TransactionAttribute(MANDATORY) in all methods.
37  * @author Gisele Pinheiro Souza
38  * @author Eduardo Studzinski Estima de Castro
39  *
40  */

41 @TransactionManagement JavaDoc(value = TransactionManagementType.CONTAINER)
42 public class ContainerTransactionMandatory extends ContainerTransaction {
43
44     /**
45      * Inserts the table test in both database using mandatory transaction.
46      * @param db1 the name of the first database.
47      * @param db2 the name of the second databse.
48      * @throws Exception if an error occurs.
49      */

50     @TransactionAttribute JavaDoc(value = TransactionAttributeType.MANDATORY)
51     @Override JavaDoc
52     public void insertCorrectTableInBothDB(final String JavaDoc db1, final String JavaDoc db2) throws Exception JavaDoc {
53         super.insertCorrectTableInBothDB(db1, db2);
54     }
55
56     /**
57      * Inserts the table test in the first database and makes an incorrect query
58      * in the second database. This method is using mandatory transaction, so
59      * this must to force a roll back if the client calls with a transaction
60      * context, or must to throw a TransactionRequiredException if the client
61      * has not transaction context.
62      * @param db1 the name of the first database.
63      * @param db2 the name of the second databse.
64      * @throws Exception if an error occurs.
65      */

66     @TransactionAttribute JavaDoc(value = TransactionAttributeType.MANDATORY)
67     @Override JavaDoc
68     public void insertCorrectFirstErrorSecond(final String JavaDoc db1, final String JavaDoc db2) throws Exception JavaDoc {
69         super.insertCorrectFirstErrorSecond(db1, db2);
70     }
71
72     /**
73      * Calls the method EJBContext.getRollbackOnly().
74      * @return true if the rollback only is set, false otherwise.
75      * @throws TransactionException if an IllegalStateException occurs.
76      */

77     @Override JavaDoc
78     @TransactionAttribute JavaDoc(value = TransactionAttributeType.MANDATORY)
79     public boolean getRollbackOnly() throws TransactionException {
80         return super.getRollbackOnly();
81     }
82
83     /**
84      * Calls the method SessionContext.setRollbackOnly().
85      * @param dbName1 the first database where the table should be inserted.
86      * @param dbName2 the second database where the table should be inserted.
87      * @throws Exception if an error occurs.
88      */

89     @Override JavaDoc
90     @TransactionAttribute JavaDoc(value = TransactionAttributeType.MANDATORY)
91     public void setRollbackOnly(final String JavaDoc dbName1, final String JavaDoc dbName2) throws Exception JavaDoc {
92         super.setRollbackOnly(dbName1, dbName2);
93     }
94
95     /**
96      * @see org.objectweb.easybeans.tests.common.ejbs.base.transaction.ContainerTransaction
97      * @param db1 the name of the first database.
98      * @param db2 the name of the second database.
99      * @throws Exception if an error during the execution occurs.
100      */

101     @Override JavaDoc
102     @TransactionAttribute JavaDoc(value = TransactionAttributeType.MANDATORY)
103     public void insertTablesUsingAuxBeanReq(final String JavaDoc db1, final String JavaDoc db2) throws Exception JavaDoc {
104         super.insertTablesUsingAuxBeanReq(db1, db2);
105     }
106
107     /**
108      * @see org.objectweb.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 JavaDoc
114     @TransactionAttribute JavaDoc(value = TransactionAttributeType.MANDATORY)
115     public void insertTablesUsingAuxBeanNotSup(final String JavaDoc db1, final String JavaDoc db2) throws Exception JavaDoc {
116         super.insertTablesUsingAuxBeanNotSup(db1, db2);
117     }
118
119     /**
120      * @see org.objectweb.easybeans.tests.common.ejbs.base.transaction.ContainerTransaction
121      * @throws Exception if an error occurs.
122      */

123     @Override JavaDoc
124     @TransactionAttribute JavaDoc(value = TransactionAttributeType.MANDATORY)
125     public void getUserTransactionWithLookup() throws Exception JavaDoc {
126         super.getUserTransactionWithLookup();
127     }
128
129     /**
130      * @see org.objectweb.easybeans.tests.common.ejbs.base.transaction.ContainerTransaction
131      * @throws Exception if an error occurs..
132      */

133     @Override JavaDoc
134     @TransactionAttribute JavaDoc(value = TransactionAttributeType.MANDATORY)
135     public void getUserTransactionWithEJBContext() throws Exception JavaDoc, RollbackException JavaDoc {
136         super.getUserTransactionWithEJBContext();
137     }
138
139 }
140
Popular Tags