KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > interceptors2 > StatusBean


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * 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.interceptors2;
23
24 import java.util.ArrayList JavaDoc;
25
26 import javax.interceptor.ExcludeDefaultInterceptors;
27 import javax.ejb.PostActivate JavaDoc;
28 import javax.annotation.PostConstruct;
29 import javax.annotation.PreDestroy;
30 import javax.ejb.PrePassivate JavaDoc;
31
32 import org.jboss.annotation.ejb.Service;
33
34 /**
35  *
36  * @author <a HREF="kabir.khan@jboss.com">Kabir Khan</a>
37  * @version $Revision: 44679 $
38  */

39 @Service
40 @ExcludeDefaultInterceptors
41 public class StatusBean implements StatusRemote
42 {
43    static ArrayList JavaDoc<Interception> interceptions = new ArrayList JavaDoc<Interception>();
44    static ArrayList JavaDoc<Interception> postConstructs = new ArrayList JavaDoc<Interception>();
45    static ArrayList JavaDoc<Interception> postActivates = new ArrayList JavaDoc<Interception>();
46    static ArrayList JavaDoc<Interception> prePassivates = new ArrayList JavaDoc<Interception>();
47    static ArrayList JavaDoc<Interception> preDestroys = new ArrayList JavaDoc<Interception>();
48    
49    public void clear()
50    {
51       System.out.println("Clearing interceptions");
52       interceptions.clear();
53       postConstructs.clear();
54       postActivates.clear();
55       prePassivates.clear();
56       preDestroys.clear();
57    }
58    
59    public ArrayList JavaDoc<Interception> getInterceptions()
60    {
61       System.out.println("Getting interceptions " + interceptions.size());
62       return interceptions;
63    }
64    
65    
66    public ArrayList JavaDoc<Interception> getPostActivates()
67    {
68       return postActivates;
69    }
70
71    public ArrayList JavaDoc<Interception> getPostConstructs()
72    {
73       return postConstructs;
74    }
75
76    public ArrayList JavaDoc<Interception> getPreDestroys()
77    {
78       return preDestroys;
79    }
80
81    public ArrayList JavaDoc<Interception> getPrePassivates()
82    {
83       return prePassivates;
84    }
85
86    public void addInterception(Interception intercepted)
87    {
88       interceptions.add(intercepted);
89       System.out.println("Adding interception (" + interceptions.size() + ")" + intercepted.getClassname() + "." + intercepted.getMethod() + " - " + intercepted.getInstance());
90    }
91    
92    public static void addInterceptionStatic(Interception intercepted)
93    {
94       interceptions.add(intercepted);
95       System.out.println("Adding interception (" + interceptions.size() + ")" + intercepted.getClassname() + "." + intercepted.getMethod() + " - " + intercepted.getInstance());
96    }
97    
98    public void addLifecycle(Class JavaDoc type, Interception intercepted)
99    {
100       if (type == PostConstruct.class)
101       {
102          addPostConstruct(intercepted);
103       }
104       else if (type == PostActivate JavaDoc.class)
105       {
106          addPostActivate(intercepted);
107       }
108       else if (type == PrePassivate JavaDoc.class)
109       {
110          addPrePassivate(intercepted);
111       }
112       else if (type == PreDestroy.class)
113       {
114          addPreDestroy(intercepted);
115       }
116    }
117    
118    public static void addPostConstruct(Interception intercepted)
119    {
120       postConstructs.add(intercepted);
121       System.out.println("Adding PostConstruct (" + postConstructs.size() + ")" + intercepted.getClassname() + "." + intercepted.getMethod() + " - " + intercepted.getInstance());
122    }
123
124    public static void addPostActivate(Interception intercepted)
125    {
126       postActivates.add(intercepted);
127       System.out.println("Adding PostActivate (" + postConstructs.size() + ")" + intercepted.getClassname() + "." + intercepted.getMethod() + " - " + intercepted.getInstance());
128    }
129
130    public static void addPrePassivate(Interception intercepted)
131    {
132       prePassivates.add(intercepted);
133       System.out.println("Adding PrePassivate (" + postConstructs.size() + ")" + intercepted.getClassname() + "." + intercepted.getMethod() + " - " + intercepted.getInstance());
134    }
135
136    public static void addPreDestroy(Interception intercepted)
137    {
138       preDestroys.add(intercepted);
139       System.out.println("Adding PreDestroy (" + postConstructs.size() + ")" + intercepted.getClassname() + "." + intercepted.getMethod() + " - " + intercepted.getInstance());
140    }
141
142    
143 }
144
Popular Tags