01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * 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.ejb3.test.stateful.nested.base;
23:
24: import java.io.Serializable;
25:
26: import javax.ejb.PostActivate;
27: import javax.ejb.PrePassivate;
28:
29: import org.jboss.logging.Logger;
30:
31: /**
32: * Superclass for SFSBs that monitor calls to @PrePassivate and @PostActivate.
33: *
34: * @author <a href="brian.stansberry@jboss.com">Brian Stansberry</a>
35: * @version $Revision: 1.1 $
36: */
37: public abstract class PassivationActivationWatcherBean implements
38: Serializable, PassivationActivationWatcher {
39: /** The serialVersionUID */
40: private static final long serialVersionUID = 1L;
41:
42: protected Logger log = Logger.getLogger(getClass());
43: private int postActivateCalled = 0;
44: private int prePassivateCalled = 0;
45:
46: public PassivationActivationWatcherBean() {
47: super ();
48: }
49:
50: @PostActivate
51: public void postActivate() {
52: postActivateCalled++;
53: int sysHC = System.identityHashCode(this );
54: log.debug(sysHC + ": Activated -- activate count = "
55: + postActivateCalled);
56: }
57:
58: @PrePassivate
59: public void prePassivate() {
60: prePassivateCalled++;
61: int sysHC = System.identityHashCode(this );
62: log.debug(sysHC + ": Passivated -- passivate count = "
63: + prePassivateCalled);
64: }
65:
66: public int getPostActivate() {
67: int sysHC = System.identityHashCode(this );
68: log.debug(sysHC + ": getPostActivate() -- activate count = "
69: + postActivateCalled);
70: return postActivateCalled;
71: }
72:
73: public int getPrePassivate() {
74: int sysHC = System.identityHashCode(this );
75: log.debug(sysHC + ": getPrePassivate() -- passivate count = "
76: + prePassivateCalled);
77: return prePassivateCalled;
78: }
79:
80: public void reset() {
81: int sysHC = System.identityHashCode(this );
82: log.debug(sysHC + "Being reset");
83: prePassivateCalled = 0;
84: postActivateCalled = 0;
85: }
86:
87: }
|