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.invocation;
23:
24: import java.io.Externalizable;
25: import java.io.IOException;
26: import java.io.ObjectInput;
27: import java.io.ObjectOutput;
28:
29: /**
30: * An InvokerInterceptor that does not optimize remote invocations.<p>
31: *
32: * This interceptor implements spec compliant behaviour.<p>
33: *
34: * @todo The performance could be improved by simulating marshalling
35: * for "local" remote, rather than going straight for the invoker
36: *
37: * @author <a href="mailto:adrian.brock@happeningtimes.com">Adrian Brock</a>
38: * @version $Revision: 57209 $
39: */
40: public class ByValueInvokerInterceptor extends InvokerInterceptor
41: implements Externalizable {
42: /** Serial Version Identifier. @since 1.1.4.1 */
43: private static final long serialVersionUID = -6402069656713307195L;
44:
45: public ByValueInvokerInterceptor() {
46: // For externalization to work
47: }
48:
49: // Public --------------------------------------------------------
50:
51: /**
52: * Are you local?
53: */
54: public boolean isLocal(Invocation invocation) {
55: InvocationType type = invocation.getType();
56: if (type == InvocationType.LOCAL
57: || type == InvocationType.LOCALHOME)
58: return true;
59: return false;
60: }
61:
62: /**
63: * Invoke using the invoker for remote invocations
64: */
65: public Object invoke(Invocation invocation) throws Exception {
66: // local interface
67: if (isLocal(invocation))
68: // The payload as is is good
69: return localInvoker.invoke(invocation);
70: else
71: // through the invoker
72: return invocation.getInvocationContext().getInvoker()
73: .invoke(invocation);
74: }
75:
76: /**
77: * Externalize this instance.
78: */
79: public void writeExternal(final ObjectOutput out)
80: throws IOException {
81: // We have no state
82: }
83:
84: /**
85: * Un-externalize this instance.
86: */
87: public void readExternal(final ObjectInput in) throws IOException,
88: ClassNotFoundException {
89: // We have no state
90: }
91:
92: // Private -------------------------------------------------------
93:
94: // Inner classes -------------------------------------------------
95: }
|