01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * 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;
25:
26: import javax.ejb.EJBHome;
27: import javax.ejb.EJBMetaData;
28: import javax.ejb.RemoveException;
29: import javax.ejb.Handle;
30: import javax.ejb.EJBHome;
31: import javax.ejb.EJBObject;
32: import javax.ejb.HomeHandle;
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: 57209 $
46: */
47: public class StatelessSessionHomeInterceptor extends HomeInterceptor {
48: /** Serial Version Identifier */
49: private static final long serialVersionUID = 1333656107035759719L;
50:
51: // Attributes ----------------------------------------------------
52:
53: /**
54: * The cached interface
55: */
56: Object cached;
57:
58: // Constructors --------------------------------------------------
59:
60: /**
61: * No-argument constructor for externalization.
62: */
63: public StatelessSessionHomeInterceptor() {
64: }
65:
66: // Public --------------------------------------------------------
67:
68: public Object invoke(Invocation invocation) throws Throwable {
69: // Is this create()?
70: boolean create = invocation.getMethod().getName().equals(
71: "create");
72:
73: // Do we have a cached version?
74: if (create && cached != null)
75: return cached;
76:
77: // Not a cached create
78: Object result = super .invoke(invocation);
79:
80: // We now have something to cache
81: if (create)
82: cached = result;
83:
84: return result;
85: }
86: }
|