KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > common > ejbs > stateless > containermanaged > exception > SLSBExceptionXML


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: SLSBExceptionXML.java 799 2006-06-29 12:17:01Z pinheirg $
23  * --------------------------------------------------------------------------
24  */

25 package org.objectweb.easybeans.tests.common.ejbs.stateless.containermanaged.exception;
26
27 import java.sql.SQLException JavaDoc;
28
29 import javax.ejb.Remote JavaDoc;
30 import javax.ejb.Stateless JavaDoc;
31 import javax.naming.NamingException JavaDoc;
32 import javax.transaction.NotSupportedException JavaDoc;
33 import javax.transaction.SystemException JavaDoc;
34
35 import org.objectweb.easybeans.tests.common.db.TableManager;
36 import org.objectweb.easybeans.tests.common.exception.CustomException00;
37 import org.objectweb.easybeans.tests.common.exception.CustomException01;
38 import org.objectweb.easybeans.tests.common.exception.IllegalException;
39 import org.objectweb.easybeans.tests.common.exception.RollbackApplicationException;
40
41 /**
42  * Inserts a table in the database and throws application exceptions defined in
43  * the deployment descriptor.
44  * @author Gisele Pinheiro Souza
45  * @author Eduardo Studzinski Estima de Castro
46  */

47 @Stateless JavaDoc
48 @Remote JavaDoc(ItfExceptionXML.class)
49 public class SLSBExceptionXML implements ItfExceptionXML {
50
51     /**
52      * Inserts a table in the database and after throws an exception that is
53      * defined in the deployment descriptor as application exception with
54      * rollback false.
55      * @param dbName the database name in the registry.
56      * @throws NamingException if a lookup error occurs.
57      * @throws SystemException if an unexpected error occurs.
58      * @throws NotSupportedException if the resquest cannot be made.
59      * @throws SQLException if a database error occurs.
60      */

61     public void createTableWithAppException(final String JavaDoc dbName) throws NamingException JavaDoc, NotSupportedException JavaDoc,
62             SystemException JavaDoc, SQLException JavaDoc {
63         TableManager tableManager = new TableManager(dbName);
64         tableManager.insertTable(TABLE);
65         throw new CustomException01("The bean threw an application exception defined in the deployment descriptor.");
66     }
67
68     /**
69      * Inserts a table in the database and after throws an exception that is
70      * defined in the deployment descriptor as application exception with
71      * rollback true.
72      * @param dbName the database name in the registry.
73      * @throws NamingException if a lookup error occurs.
74      * @throws SystemException if an unexpected error occurs.
75      * @throws NotSupportedException if the resquest cannot be made.
76      * @throws SQLException if a database error occurs.
77      * @throws CustomException00 an application exception defined in the
78      * deployment descriptor, it is always thrown.
79      */

80     public void createTableWithAppExceptionAndRollback(final String JavaDoc dbName) throws NamingException JavaDoc,
81             NotSupportedException JavaDoc, SystemException JavaDoc, SQLException JavaDoc, CustomException00 {
82         TableManager tableManager = new TableManager(dbName);
83         tableManager.insertTable(TABLE);
84         throw new CustomException00("The bean threw an application exception defined in the deployment descriptor.");
85     }
86
87     /**
88      * Inserts a table in the database and after throws an exception that is
89      * defined in the deployment descriptor as application exception with
90      * the default value for the rollback.
91      * @param dbName the database name in the registry.
92      * @throws NamingException if a lookup error occurs.
93      * @throws SystemException if an unexpected error occurs.
94      * @throws NotSupportedException if the resquest cannot be made.
95      * @throws SQLException if a database error occurs.
96      */

97     public void createTableWithAppExceptionDefault(final String JavaDoc dbName) throws NamingException JavaDoc, NotSupportedException JavaDoc,
98             SystemException JavaDoc, SQLException JavaDoc {
99         TableManager tableManager = new TableManager(dbName);
100         tableManager.insertTable(TABLE);
101         throw new IllegalException("The bean threw an application exception defined in the deployment descriptor.");
102     }
103
104     /**
105      * Inserts a table in the database and after throws an exception that is
106      * defined by annotation, but the rollback element is overrided in the
107      * deployment descriptor.
108      * @param dbName the database name in the registry.
109      * @throws NamingException if a lookup error occurs.
110      * @throws SystemException if an unexpected error occurs.
111      * @throws NotSupportedException if the resquest cannot be made.
112      * @throws SQLException if a database error occurs.
113      * @throws RollbackApplicationException an application exception defined in
114      * the deployment descriptor, it is always thrown.
115      */

116     public void createTableWithAppExceptionOverride(final String JavaDoc dbName) throws NamingException JavaDoc, NotSupportedException JavaDoc,
117             SystemException JavaDoc, SQLException JavaDoc, RollbackApplicationException {
118         TableManager tableManager = new TableManager(dbName);
119         tableManager.insertTable(TABLE);
120         throw new RollbackApplicationException("The bean threw an application exception defined by annotation.");
121     }
122
123 }
124
Popular Tags