KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > jca > ejb > XAExceptionTestSessionBean


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.test.jca.ejb;
23
24 import javax.ejb.EJBException JavaDoc;
25 import javax.ejb.SessionBean JavaDoc;
26 import javax.ejb.SessionContext JavaDoc;
27 import javax.ejb.TransactionRolledbackLocalException JavaDoc;
28 import javax.naming.InitialContext JavaDoc;
29 import javax.transaction.TransactionRolledbackException JavaDoc;
30
31 import org.jboss.logging.Logger;
32 import org.jboss.test.jca.interfaces.XAExceptionSession;
33 import org.jboss.test.jca.interfaces.XAExceptionSessionHome;
34 import org.jboss.test.jca.interfaces.XAExceptionSessionLocal;
35 import org.jboss.test.jca.interfaces.XAExceptionSessionLocalHome;
36
37 /**
38  * XAExceptionTestSessionBean.java
39  *
40  * @author <a HREF="mailto:d_jencks@users.sourceforge.net">David Jencks</a>
41  * @version <tt>$Revision: 37406 $</tt>
42  *
43  * @ejb:bean name="XAExceptionTestSession"
44  * jndi-name="test/XAExceptionTestSessionHome"
45  * view-type="remote"
46  * type="Stateless"
47  * @ejb.transaction type="Never"
48  */

49 public class XAExceptionTestSessionBean implements SessionBean JavaDoc
50 {
51
52    /** The serialVersionUID */
53    private static final long serialVersionUID = 1L;
54
55    private Logger log = Logger.getLogger(getClass());
56
57    /**
58     * Describe <code>ejbCreate</code> method here.
59     * @ejb.interface-method
60     */

61    public void ejbCreate()
62    {
63    }
64
65    /**
66     * Describe <code>testXAException</code> method here.
67     * @ejb.interface-method
68     */

69    public void testXAExceptionToTransactionRolledbackException()
70    {
71       try
72       {
73          XAExceptionSessionHome xh = (XAExceptionSessionHome) new InitialContext JavaDoc()
74                .lookup("test/XAExceptionSessionHome");
75          XAExceptionSession x = xh.create();
76          try
77          {
78             x.testXAExceptionToTransactionRolledbackException();
79          }
80          catch (TransactionRolledbackException JavaDoc tre)
81          {
82             log.info("Test worked");
83             return;
84          }
85       }
86       catch (Exception JavaDoc e)
87       {
88          log.info("unexpected exception", e);
89          throw new EJBException JavaDoc("Unexpected exception: " + e);
90       }
91       throw new EJBException JavaDoc("No exception");
92    }
93
94    /**
95     * Describe <code>testXAException</code> method here.
96     * @ejb.interface-method
97     */

98    public void testXAExceptionToTransactionRolledbackLocalException()
99    {
100       try
101       {
102          XAExceptionSessionLocalHome xh = (XAExceptionSessionLocalHome) new InitialContext JavaDoc()
103                .lookup("test/XAExceptionSessionLocalHome");
104          XAExceptionSessionLocal x = xh.create();
105          try
106          {
107             x.testXAExceptionToTransactionRolledbackException();
108          }
109          catch (TransactionRolledbackLocalException JavaDoc tre)
110          {
111             log.info("Test worked");
112             return;
113          }
114       }
115       catch (Exception JavaDoc e)
116       {
117          log.info("unexpected exception", e);
118          throw new EJBException JavaDoc("Unexpected exception: " + e);
119       }
120       throw new EJBException JavaDoc("No exception");
121    }
122
123    /**
124     * Describe <code>testXAException</code> method here.
125     * @ejb.interface-method
126     */

127    public void testRMERRInOnePCToTransactionRolledbackException()
128    {
129       try
130       {
131          XAExceptionSessionHome xh = (XAExceptionSessionHome) new InitialContext JavaDoc()
132                .lookup("test/XAExceptionSessionHome");
133          XAExceptionSession x = xh.create();
134          try
135          {
136             x.testRMERRInOnePCToTransactionRolledbackException();
137          }
138          catch (TransactionRolledbackException JavaDoc tre)
139          {
140             log.info("Test worked");
141             return;
142          }
143       }
144       catch (Exception JavaDoc e)
145       {
146          log.info("unexpected exception", e);
147          throw new EJBException JavaDoc("Unexpected exception: " + e);
148       }
149       throw new EJBException JavaDoc("No exception");
150    }
151
152    /**
153     * Describe <code>testXAException</code> method here.
154     * @ejb.interface-method
155     */

156    public void testXAExceptionToTransactionRolledbacLocalkException()
157    {
158       try
159       {
160          XAExceptionSessionLocalHome xh = (XAExceptionSessionLocalHome) new InitialContext JavaDoc()
161                .lookup("test/XAExceptionSessionLocalHome");
162          XAExceptionSessionLocal x = xh.create();
163          try
164          {
165             x.testRMERRInOnePCToTransactionRolledbackException();
166          }
167          catch (TransactionRolledbackLocalException JavaDoc tre)
168          {
169             log.info("Test worked");
170             return;
171          }
172       }
173       catch (Exception JavaDoc e)
174       {
175          log.info("unexpected exception", e);
176          throw new EJBException JavaDoc("Unexpected exception: " + e);
177       }
178       throw new EJBException JavaDoc("No exception");
179    }
180
181    public void ejbActivate()
182    {
183    }
184
185    public void ejbPassivate()
186    {
187    }
188
189    public void ejbRemove()
190    {
191    }
192
193    public void setSessionContext(SessionContext JavaDoc ctx)
194    {
195    }
196
197    public void unsetSessionContext()
198    {
199    }
200
201 }
202
Popular Tags