KickJava   Java API By Example, From Geeks To Geeks.

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


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: ContainerTransactionRequired.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.naming.NamingException 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(REQUIRED) 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 ContainerTransactionRequired extends ContainerTransaction {
43
44     /**
45      * Inserts the table test in both database using required transaction.
46      * @param db1 the first databse name.
47      * @param db2 the second database name.
48      * @throws Exception if an error occurs.
49      */

50     @TransactionAttribute JavaDoc(value = TransactionAttributeType.REQUIRED)
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 in the second database.
58      * This method is using required transaction, so this must to force a roll back.
59      * @param db1 the first databse name.
60      * @param db2 the second database name.
61      * @throws Exception if an error occurs.
62      */

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

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

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

98     @Override JavaDoc
99     @TransactionAttribute JavaDoc(value = TransactionAttributeType.REQUIRED)
100     public void insertTablesUsingAuxBeanReq(final String JavaDoc db1, final String JavaDoc db2) throws Exception JavaDoc {
101         super.insertTablesUsingAuxBeanReq(db1, db2);
102     }
103
104     /**
105      * @see org.objectweb.easybeans.tests.common.ejbs.base.transaction.ContainerTransaction
106      * @param db1 the name of the first database.
107      * @param db2 the name of the second database.
108      * @throws Exception if an error during the execution occurs.
109      */

110     @Override JavaDoc
111     @TransactionAttribute JavaDoc(value = TransactionAttributeType.REQUIRED)
112     public void insertTablesUsingAuxBeanNotSup(final String JavaDoc db1, final String JavaDoc db2) throws Exception JavaDoc {
113         super.insertTablesUsingAuxBeanNotSup(db1, db2);
114     }
115
116     /**
117      * @see org.objectweb.easybeans.tests.common.ejbs.base.transaction.ContainerTransaction
118      * @throws Exception if an error occurs.
119      */

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

130     @Override JavaDoc
131     @TransactionAttribute JavaDoc(value = TransactionAttributeType.REQUIRED)
132     public void getUserTransactionWithEJBContext() throws Exception JavaDoc {
133         super.getUserTransactionWithEJBContext();
134     }
135 }
136
Popular Tags