KickJava   Java API By Example, From Geeks To Geeks.

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


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: StatelessBean3.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.AroundInvoke;
32 import javax.interceptor.InvocationContext;
33
34 /**
35  * Simple class for testing lifecycle events.
36  * Defines lifecycle inside the bean class + business interceptor.
37  * @author Florent Benoit
38  */

39 @Stateless JavaDoc
40 public class StatelessBean3 implements SessionBeanItf {
41
42     /**
43      * Counter to be increased by postconstruct and preDestroy.
44      */

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

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

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

67     public int getCounter() {
68         return counter;
69     }
70
71     /**
72      * Dummy interceptor.
73      * @param iCtx the invocation context object
74      * @return invocation result
75      * @throws Exception if proceed() fails
76      */

77     @AroundInvoke
78     protected Object JavaDoc dummyInterceptor(final InvocationContext iCtx) throws Exception JavaDoc {
79         return iCtx.proceed();
80     }
81
82
83 }
84
Popular Tags