KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > invocation > ByValueInvokerInterceptor


1 /*
2 * JBoss, the OpenSource J2EE webOS
3 *
4 * Distributable under LGPL license.
5 * See terms of license at gnu.org.
6 */

7 package org.jboss.invocation;
8
9 import java.io.Externalizable JavaDoc;
10 import java.io.IOException JavaDoc;
11 import java.io.ObjectInput JavaDoc;
12 import java.io.ObjectOutput JavaDoc;
13
14 /**
15 * An InvokerInterceptor that does not optimize remote invocations.<p>
16 *
17 * This interceptor implements spec compliant behaviour.<p>
18 *
19 * @todo The performance could be improved by simulating marshalling
20 * for "local" remote, rather than going straight for the invoker
21 *
22 * @author <a HREF="mailto:adrian.brock@happeningtimes.com">Adrian Brock</a>
23 * @version $Revision: 1.5 $
24 */

25 public class ByValueInvokerInterceptor
26    extends InvokerInterceptor
27    implements Externalizable JavaDoc
28 {
29    /** Serial Version Identifier. @since 1.1.4.1 */
30    private static final long serialVersionUID = -6402069656713307195L;
31
32    public ByValueInvokerInterceptor()
33    {
34       // For externalization to work
35
}
36    
37    // Public --------------------------------------------------------
38

39    /**
40     * Are you local?
41     */

42    public boolean isLocal(Invocation invocation)
43    {
44       InvocationType type = invocation.getType();
45       if (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME)
46          return true;
47       return false;
48    }
49    
50    /**
51     * Invoke using the invoker for remote invocations
52     */

53    public Object JavaDoc invoke(Invocation invocation)
54       throws Exception JavaDoc
55    {
56       // local interface
57
if (isLocal(invocation))
58          // The payload as is is good
59
return localInvoker.invoke(invocation);
60       else
61          // through the invoker
62
return invocation.getInvocationContext().getInvoker().invoke(invocation);
63    }
64    
65    /**
66     * Externalize this instance.
67     */

68    public void writeExternal(final ObjectOutput JavaDoc out)
69       throws IOException JavaDoc
70    {
71       // We have no state
72
}
73    
74    /**
75     * Un-externalize this instance.
76     */

77    public void readExternal(final ObjectInput JavaDoc in)
78       throws IOException JavaDoc, ClassNotFoundException JavaDoc
79    {
80       // We have no state
81
}
82    
83    // Private -------------------------------------------------------
84

85    // Inner classes -------------------------------------------------
86
}
87
Popular Tags