001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2005-2006 Bull S.A.S
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: * Initial developer(s):
022: * --------------------------------------------------------------------------
023: * $Id$
024: * --------------------------------------------------------------------------
025: */package org.objectweb.sampleCluster2.ejb;
026:
027: import javax.ejb.SessionBean;
028: import javax.ejb.SessionContext;
029: import javax.ejb.SessionSynchronization;
030:
031: import org.objectweb.jonas.common.Log;
032: import org.objectweb.util.monolog.api.BasicLevel;
033: import org.objectweb.util.monolog.api.Logger;
034:
035: /**
036: *
037: */
038: public class MyStatefulInner implements SessionBean,
039: SessionSynchronization {
040:
041: /**
042: *
043: */
044: private static final long serialVersionUID = 1L;
045:
046: /**
047: * After the transaction begun
048: */
049: public void afterBegin() {
050: logger.log(BasicLevel.DEBUG, "afterBegin");
051: }
052:
053: /**
054: * before the commit is executed
055: */
056: public void beforeCompletion() {
057: logger.log(BasicLevel.DEBUG, "beforeCompletion");
058: }
059:
060: /**
061: * after the commit or rollback
062: * @param committed true -> commit, false -> rollback
063: */
064: public void afterCompletion(boolean committed) {
065: logger.log(BasicLevel.DEBUG, "afterCompletion: " + committed);
066: }
067:
068: /**
069: * Set the session context
070: * @param ctx the session context
071: */
072: public void setSessionContext(SessionContext ctx) {
073: if (logger == null) {
074: logger = Log.getLogger("org.objectweb.jonas_tests");
075: }
076: logger.log(BasicLevel.DEBUG, "setSessionContext");
077: }
078:
079: /**
080: * removes the ejb
081: */
082: public void ejbRemove() {
083: logger.log(BasicLevel.DEBUG, "ejbRemove");
084: }
085:
086: /**
087: * creation of the ejb
088: */
089: public void ejbCreate() {
090: logger.log(BasicLevel.DEBUG, "ejbCreate()->" + this .toString());
091: }
092:
093: /**
094: * Passivate of the ejb
095: */
096: public void ejbPassivate() {
097: logger.log(BasicLevel.DEBUG, "ejbPassivate");
098: }
099:
100: /**
101: * activation of the ejb
102: */
103: public void ejbActivate() {
104: logger.log(BasicLevel.DEBUG, "ejbActivate");
105: }
106:
107: private int count = 0;
108:
109: private transient boolean isModified = true;
110:
111: public void increment() {
112: count++;
113: isModified = true;
114: }
115:
116: public int getCount() {
117: return count;
118: }
119:
120: /**
121: * The logger
122: */
123: private static Logger logger = null;
124:
125: public boolean isModified() {
126: boolean result = isModified;
127: isModified = false;
128:
129: return result;
130: }
131: }
|