KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > tests > enhancer > interceptors > lifecycle > bean > StatefulBean


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: StatefulBean.java 450 2006-05-12 15:30:25Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.tests.enhancer.interceptors.lifecycle.bean;
27
28 import javax.annotation.PostConstruct;
29 import javax.annotation.PreDestroy;
30 import javax.ejb.PostActivate JavaDoc;
31 import javax.ejb.PrePassivate JavaDoc;
32 import javax.ejb.Stateful JavaDoc;
33 import javax.interceptor.Interceptors;
34
35 /**
36  * Simple class for testing callbacks.
37  * @author Florent Benoit
38  */

39 @Stateful JavaDoc(name = "HelloWorldbean3")
40 @Interceptors(MyLifeCycleInterceptorStateful.class)
41 public class StatefulBean extends AbsSessionBean implements SessionBeanItf {
42
43     /**
44      * PrePassivate method has been called ?
45      */

46     private boolean prePassivateCalled = false;
47
48
49     /**
50      * PostActivate method has been called ?
51      */

52     private boolean postActivateCalled = false;
53
54
55     /**
56      * Counter used for all callbacks.
57      */

58     private int counter;
59
60     /**
61      * Sets that method marked by @{@link javax.ejb.PrePassivate} has been called.
62      */

63     public void calledPrePassivate() {
64         this.prePassivateCalled = true;
65     }
66
67     /**
68      * @return true if method marked by @{@link javax.ejb.PrePassivate} has been called.
69      */

70     public boolean isprePassivateCalled() {
71         return prePassivateCalled;
72     }
73
74
75     /**
76      * Sets that method marked by @{@link javax.ejb.PostActivate} has been called.
77      */

78     public void calledPostActivate() {
79         this.postActivateCalled = true;
80     }
81
82
83     /**
84      * @return true if method marked by @{@link javax.ejb.PostActivate} has been called.
85      */

86     public boolean isPostActivateCalled() {
87         return postActivateCalled;
88     }
89
90
91
92     /**
93      * Increment the counter.
94      */

95     @PostConstruct
96     @PreDestroy
97     @PostActivate JavaDoc
98     @PrePassivate JavaDoc
99     public void increment() {
100         counter++;
101     }
102
103     /**
104      * @return the value of the internal counter.
105      */

106     public int getCounter() {
107         return counter;
108     }
109
110 }
111
Popular Tags