KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > base > xmldescriptor > BasicBean


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: BasicBean.java 640 2006-06-13 09:21:05Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.base.xmldescriptor;
26
27 import javax.naming.NamingException JavaDoc;
28 import javax.transaction.HeuristicMixedException JavaDoc;
29 import javax.transaction.HeuristicRollbackException JavaDoc;
30 import javax.transaction.NotSupportedException JavaDoc;
31 import javax.transaction.RollbackException JavaDoc;
32 import javax.transaction.SystemException JavaDoc;
33 import javax.transaction.UserTransaction JavaDoc;
34
35 import org.objectweb.easybeans.tests.common.exception.TransactionException;
36 import org.objectweb.easybeans.tests.common.helper.TransactionHelper;
37
38 /**
39  * A simple class that is defined as a bean by the deployment descriptor.
40  * @author Gisele Pinheiro Souza
41  * @author Eduardo Studzinski Estima de Castro
42  *
43  */

44 public class BasicBean implements ItfBasicBeanLocal, ItfBasicBeanRemote {
45
46     /**
47      * Opens a transaction without close. If the bean is stateless, this method
48      * call will throw an EJBException.However, for a stateful the method will
49      * be executed without problem.
50      * @throws NamingException if a problem to get the transaction occurs.
51      * @throws NotSupportedException if the bean is already associated with a transaction.
52      * @throws SystemException if an unexpected error occurs during the transaction.
53      */

54     public void openTransaction() throws NamingException JavaDoc, NotSupportedException JavaDoc, SystemException JavaDoc {
55         UserTransaction JavaDoc utx = TransactionHelper.getUserTransaction();
56         utx.begin();
57     }
58
59     /**
60      * Verifies if the bean has a bean-managed transaction. If the transaction
61      * type is defined as container managed transaction, this method must throw
62      * an exception.
63      * @throws NamingException if a lookup error occurs.
64      * @throws SystemException if an unexpected error occurs.
65      * @throws NotSupportedException if the resquest cannot be made.
66      * @throws HeuristicRollbackException if a heuristic decision was made and
67      * some relevant update was rolled back.
68      * @throws RollbackException if the transaction was rolled back instead of
69      * committed.
70      * @throws HeuristicMixedException if a heuristic decision was made and some
71      * relevant update was commited and others rolled back.
72      * @throws TransactionException if a rollback was made.
73      */

74     public void verifyBMT() throws IllegalStateException JavaDoc, SecurityException JavaDoc, HeuristicMixedException JavaDoc,
75             HeuristicRollbackException JavaDoc, RollbackException JavaDoc, SystemException JavaDoc, NotSupportedException JavaDoc, NamingException JavaDoc {
76         UserTransaction JavaDoc utx = TransactionHelper.getUserTransaction();
77         utx.begin();
78         utx.commit();
79     }
80 }
81
Popular Tags