KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > jtests > beans > beanexc > AccountCommon


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@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: AccountCommon.java,v 1.8 2005/04/29 14:16:18 ashah Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas.jtests.beans.beanexc;
27
28 import javax.ejb.EJBContext JavaDoc;
29 import java.rmi.RemoteException JavaDoc;
30
31 import org.objectweb.util.monolog.api.Logger;
32 import org.objectweb.util.monolog.api.BasicLevel;
33
34 /**
35  * Common part to all beans.
36  * @author Philippe Durieux, Philippe Coq
37  */

38 public abstract class AccountCommon implements java.io.Serializable JavaDoc {
39
40     protected static Logger logger = null;
41     protected boolean iAmDestroyed = false;
42
43     public abstract void setBalance(long val);
44     public abstract EJBContext JavaDoc getContext();
45
46     public void doAppException_1() throws AppException {
47         logger.log(BasicLevel.DEBUG, "");
48         setBalance(5000);
49         throw new AppException("doAppException_1");
50     }
51
52     public void doAppException_2(boolean rollflg) throws AppException {
53         logger.log(BasicLevel.DEBUG, "");
54         setBalance(50);
55         if (rollflg) {
56             getContext().setRollbackOnly();
57         }
58         throw new AppException("doAppException_2");
59     }
60
61     public void doAppException_3() throws AppException {
62         logger.log(BasicLevel.DEBUG, "");
63         throw new AppException("doAppException_3");
64     }
65
66     public void doUncheckedException_1() {
67         logger.log(BasicLevel.DEBUG, "");
68         int zero = 0;
69         iAmDestroyed = true;
70         float f = 10 / zero;
71     }
72
73     public void doUncheckedException_2() {
74         logger.log(BasicLevel.DEBUG, "");
75         setBalance(1000);
76         int zero = 0;
77         iAmDestroyed = true;
78         float f = 10 / zero;
79     }
80
81     public void doUncheckedException_3() {
82         logger.log(BasicLevel.DEBUG, "");
83         int zero = 0;
84         iAmDestroyed = true;
85         float f = 10 / zero;
86     }
87
88     public void doRemoteException_1() throws RemoteException JavaDoc {
89         logger.log(BasicLevel.DEBUG, "");
90         setBalance(10);
91         iAmDestroyed = true;
92         throw new RemoteException JavaDoc("RemoteException in doRemoteException_1");
93     }
94
95     public void doEJBException_1() {
96         logger.log(BasicLevel.DEBUG, "");
97         setBalance(10);
98         iAmDestroyed = true;
99         throw new javax.ejb.EJBException JavaDoc("EJBException in doEJBException_1");
100     }
101
102     public void doEJBException_2() {
103         logger.log(BasicLevel.DEBUG, "");
104         setBalance(10);
105         iAmDestroyed = true;
106         throw new javax.ejb.EJBException JavaDoc("EJBException in doEJBException_2");
107     }
108     
109     public void doEJBException_sup() {
110         logger.log(BasicLevel.DEBUG, "");
111         setBalance(10);
112         iAmDestroyed = true;
113         throw new javax.ejb.EJBException JavaDoc("EJBException in doEJBException_sup");
114     }
115     
116     public boolean iAmDestroyed() {
117         logger.log(BasicLevel.DEBUG, "");
118         return iAmDestroyed;
119     }
120
121     public void ping() {
122         logger.log(BasicLevel.DEBUG, "");
123     }
124
125     public void ejbPostCreate(int flag) {
126     }
127
128     public void ejbPostCreate(boolean flag) {
129     }
130     
131 }
132
Popular Tags