KickJava   Java API By Example, From Geeks To Geeks.

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


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: AbsSessionBean.java 484 2006-05-22 15:44:11Z 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
33
34 /**
35  * Simple common methods for a session bean.
36  * @author Florent Benoit
37  */

38
39 public class AbsSessionBean implements SessionBeanItf {
40
41     /**
42      * postConstruct method has been called ?
43      */

44     private boolean postConstructCalled = false;
45
46
47     /**
48      * preDestroy method has been called ?
49      */

50     private boolean preDestroyCalled = false;
51
52     /**
53      * Counter for the super lifecycle method.
54      */

55     private int superLifeCycleCounter = 0;
56
57
58     /**
59      * Sets that method marked by @{@link javax.ejb.PostConstruct} has been called.
60      */

61     public void calledPostConstruct() {
62         this.postConstructCalled = true;
63     }
64
65     /**
66      * @return true if method marked by @{@link javax.ejb.PostConstruct} has been called.
67      */

68     public boolean isPostConstructCalled() {
69         return postConstructCalled;
70     }
71
72
73     /**
74      * Sets that method marked by @{@link javax.ejb.PreDestroy} has been called.
75      */

76     public void calledPreDestroy() {
77         this.preDestroyCalled = true;
78     }
79
80
81     /**
82      * @return true if method marked by @{@link javax.ejb.PreDestroy} has been called.
83      */

84     public boolean isPreDestroyCalled() {
85         return preDestroyCalled;
86     }
87
88
89     /**
90      * LifeCycle method defined in a super class. Increments a counter.
91      */

92     @PostConstruct
93     @PostActivate JavaDoc
94     public void superLifeCycleMethodIncrement() {
95         superLifeCycleCounter++;
96     }
97
98     /**
99      * LifeCycle method defined in a super class. Decrements a counter.
100      */

101     @PreDestroy
102     @PrePassivate JavaDoc
103     public void superLifeCycleMethodDecrement() {
104         superLifeCycleCounter--;
105     }
106
107     /**
108      * @return value of the counter of the super lifecycle method
109      */

110     public int getSuperLifeCycleCounter() {
111         return superLifeCycleCounter;
112     }
113
114
115 }
116
Popular Tags