KickJava   Java API By Example, From Geeks To Geeks.

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


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: SFSBSimpleBeanOverrided.java 956 2006-07-27 07:15:49Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.stateful.containermanaged.xmldescriptor;
26
27 import javax.ejb.Local JavaDoc;
28 import javax.ejb.Remote JavaDoc;
29 import javax.ejb.Stateful JavaDoc;
30 import javax.ejb.TransactionManagement JavaDoc;
31 import javax.ejb.TransactionManagementType JavaDoc;
32 import javax.naming.NamingException JavaDoc;
33 import javax.transaction.HeuristicMixedException JavaDoc;
34 import javax.transaction.HeuristicRollbackException JavaDoc;
35 import javax.transaction.NotSupportedException JavaDoc;
36 import javax.transaction.RollbackException JavaDoc;
37 import javax.transaction.SystemException JavaDoc;
38 import javax.transaction.UserTransaction JavaDoc;
39
40 import org.objectweb.easybeans.tests.common.exception.TransactionException;
41 import org.objectweb.easybeans.tests.common.helper.TransactionHelper;
42
43 /**
44  * Used to verify if the deployment descriptor overrides the annotation. The
45  * deployment descriptor defines: <ul>
46  * <li>The session bean as stateful. The session type cannot be overrided (page 491-FINAL REALEASE);</li>
47  * <li>The bean name: SLSBSimpleBeanOverrideLocal;</li>
48  * <li>The transaction
49  * type as Bean;</li>
50  * <li>The local interface: ItfSimpleBeanOverridedLocal;</li>
51  * <li>The remote interface: ItfSimpleBeanOverridedRemote.</li> </ul>
52  * @author Gisele Pinheiro Souza
53  * @author Eduardo Studzinski Estima de Castro
54  */

55 @Stateful JavaDoc(name = "SFSBSimpleBeanByAnnotation")
56 @TransactionManagement JavaDoc(TransactionManagementType.CONTAINER)
57 @Local JavaDoc(ItfSimpleBeanOverridedRemote.class)
58 @Remote JavaDoc(ItfSimpleBeanOverridedLocal.class)
59 public class SFSBSimpleBeanOverrided implements ItfSimpleBeanOverridedLocal, ItfSimpleBeanOverridedRemote {
60
61     /**
62      * Opens a transaction without close. If the bean is stateless, this method
63      * call will throw an EJBException.However, for a stateful the method will
64      * be executed without problem.
65      * @throws NamingException if a problem to get the transaction occurs.
66      * @throws NotSupportedException if the bean is already associated with a transaction.
67      * @throws SystemException if an unexpected error occurs during the transaction.
68      */

69     public void openTransaction() throws NamingException JavaDoc, NotSupportedException JavaDoc, SystemException JavaDoc {
70         UserTransaction JavaDoc utx = TransactionHelper.getUserTransaction();
71         utx.begin();
72     }
73
74     /**
75      * Verifies if the bean has a bean-managed transaction. If the transaction
76      * type is defined as container managed transaction, this method must throw
77      * an exception.
78      * @throws NamingException if a lookup error occurs.
79      * @throws SystemException if an unexpected error occurs.
80      * @throws NotSupportedException if the resquest cannot be made.
81      * @throws HeuristicRollbackException if a heuristic decision was made and
82      * some relevant update was rolled back.
83      * @throws RollbackException if the transaction was rolled back instead of
84      * committed.
85      * @throws HeuristicMixedException if a heuristic decision was made and some
86      * relevant update was commited and others rolled back.
87      * @throws TransactionException if a rollback was made.
88      */

89     public void verifyBMT() throws IllegalStateException JavaDoc, SecurityException JavaDoc, HeuristicMixedException JavaDoc,
90             HeuristicRollbackException JavaDoc, RollbackException JavaDoc, SystemException JavaDoc, NotSupportedException JavaDoc, NamingException JavaDoc {
91         UserTransaction JavaDoc utx = TransactionHelper.getUserTransaction();
92         utx.begin();
93         utx.commit();
94     }
95 }
96
Popular Tags