KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > proxy > ejb > StatelessSessionHomeInterceptor


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.proxy.ejb;
23
24 import java.lang.reflect.Method JavaDoc;
25
26 import javax.ejb.EJBHome JavaDoc;
27 import javax.ejb.EJBMetaData JavaDoc;
28 import javax.ejb.RemoveException JavaDoc;
29 import javax.ejb.Handle JavaDoc;
30 import javax.ejb.EJBHome JavaDoc;
31 import javax.ejb.EJBObject JavaDoc;
32 import javax.ejb.HomeHandle JavaDoc;
33
34 import org.jboss.proxy.ejb.handle.HomeHandleImpl;
35 import org.jboss.invocation.Invocation;
36 import org.jboss.invocation.InvocationContext;
37 import org.jboss.invocation.InvocationKey;
38 import org.jboss.invocation.InvocationType;
39
40 /**
41  * The client-side proxy for a stateless session Home object,
42  * that caches the stateless session interface
43  *
44  * @author <a HREF="mailto:adrian@jboss.org">Adrian Brock</a>
45  * @version $Revision: 37459 $
46  */

47 public class StatelessSessionHomeInterceptor
48    extends HomeInterceptor
49 {
50    /** Serial Version Identifier */
51    private static final long serialVersionUID = 1333656107035759719L;
52    
53    // Attributes ----------------------------------------------------
54

55    /**
56     * The cached interface
57     */

58    Object JavaDoc cached;
59    
60    // Constructors --------------------------------------------------
61

62    /**
63    * No-argument constructor for externalization.
64    */

65    public StatelessSessionHomeInterceptor() {}
66    
67    // Public --------------------------------------------------------
68

69    public Object JavaDoc invoke(Invocation invocation)
70       throws Throwable JavaDoc
71    {
72       // Is this create()?
73
boolean create = invocation.getMethod().getName().equals("create");
74
75       // Do we have a cached version?
76
if (create && cached != null)
77          return cached;
78
79       // Not a cached create
80
Object JavaDoc result = super.invoke(invocation);
81
82       // We now have something to cache
83
if (create)
84          cached = result;
85
86       return result;
87    }
88 }
89
Popular Tags