001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: AccountCommon.java 6675 2005-04-29 14:16:18Z ashah $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas.jtests.beans.beanexc;
027:
028: import javax.ejb.EJBContext;
029: import java.rmi.RemoteException;
030:
031: import org.objectweb.util.monolog.api.Logger;
032: import org.objectweb.util.monolog.api.BasicLevel;
033:
034: /**
035: * Common part to all beans.
036: * @author Philippe Durieux, Philippe Coq
037: */
038: public abstract class AccountCommon implements java.io.Serializable {
039:
040: protected static Logger logger = null;
041: protected boolean iAmDestroyed = false;
042:
043: public abstract void setBalance(long val);
044:
045: public abstract EJBContext getContext();
046:
047: public void doAppException_1() throws AppException {
048: logger.log(BasicLevel.DEBUG, "");
049: setBalance(5000);
050: throw new AppException("doAppException_1");
051: }
052:
053: public void doAppException_2(boolean rollflg) throws AppException {
054: logger.log(BasicLevel.DEBUG, "");
055: setBalance(50);
056: if (rollflg) {
057: getContext().setRollbackOnly();
058: }
059: throw new AppException("doAppException_2");
060: }
061:
062: public void doAppException_3() throws AppException {
063: logger.log(BasicLevel.DEBUG, "");
064: throw new AppException("doAppException_3");
065: }
066:
067: public void doUncheckedException_1() {
068: logger.log(BasicLevel.DEBUG, "");
069: int zero = 0;
070: iAmDestroyed = true;
071: float f = 10 / zero;
072: }
073:
074: public void doUncheckedException_2() {
075: logger.log(BasicLevel.DEBUG, "");
076: setBalance(1000);
077: int zero = 0;
078: iAmDestroyed = true;
079: float f = 10 / zero;
080: }
081:
082: public void doUncheckedException_3() {
083: logger.log(BasicLevel.DEBUG, "");
084: int zero = 0;
085: iAmDestroyed = true;
086: float f = 10 / zero;
087: }
088:
089: public void doRemoteException_1() throws RemoteException {
090: logger.log(BasicLevel.DEBUG, "");
091: setBalance(10);
092: iAmDestroyed = true;
093: throw new RemoteException(
094: "RemoteException in doRemoteException_1");
095: }
096:
097: public void doEJBException_1() {
098: logger.log(BasicLevel.DEBUG, "");
099: setBalance(10);
100: iAmDestroyed = true;
101: throw new javax.ejb.EJBException(
102: "EJBException in doEJBException_1");
103: }
104:
105: public void doEJBException_2() {
106: logger.log(BasicLevel.DEBUG, "");
107: setBalance(10);
108: iAmDestroyed = true;
109: throw new javax.ejb.EJBException(
110: "EJBException in doEJBException_2");
111: }
112:
113: public void doEJBException_sup() {
114: logger.log(BasicLevel.DEBUG, "");
115: setBalance(10);
116: iAmDestroyed = true;
117: throw new javax.ejb.EJBException(
118: "EJBException in doEJBException_sup");
119: }
120:
121: public boolean iAmDestroyed() {
122: logger.log(BasicLevel.DEBUG, "");
123: return iAmDestroyed;
124: }
125:
126: public void ping() {
127: logger.log(BasicLevel.DEBUG, "");
128: }
129:
130: public void ejbPostCreate(int flag) {
131: }
132:
133: public void ejbPostCreate(boolean flag) {
134: }
135:
136: }
|