KickJava   Java API By Example, From Geeks To Geeks.

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


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: StatelessBean.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.Stateless JavaDoc;
31 import javax.interceptor.Interceptors;
32
33 /**
34  * Simple class for testing callbacks.
35  * @author Florent Benoit
36  */

37 @Stateless JavaDoc(name = "HelloWorldbean")
38 @Interceptors(MyLifeCycleInterceptorStateless.class)
39 public class StatelessBean extends AbsSessionBean implements SessionBeanItf {
40
41     /**
42      * Counter to be increased by postconstruct and preDestroy.
43      */

44     private int counter = 0;
45
46
47     /**
48      * Increment the counter.
49      */

50     @PostConstruct
51     public void increment() {
52         counter++;
53     }
54
55
56     /**
57      * Decrement the counter.
58      */

59     @PreDestroy
60     public void decrement() {
61         counter--;
62     }
63
64
65     /**
66      * @return the value of the internal counter.
67      */

68     public int getCounter() {
69         return counter;
70     }
71
72 }
73
Popular Tags