KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > aspects > remoting > interceptors > transport > TransportInterceptor


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.aspects.remoting.interceptors.transport;
8
9 import org.jboss.aop.advice.Interceptor;
10 import org.jboss.aop.joinpoint.Invocation;
11 import org.jboss.aspects.remoting.interceptors.invoker.RemotingInterceptorFactory;
12 import org.jboss.remoting.Client;
13 import org.jboss.remoting.marshal.Marshaller;
14
15 /**
16  * @author <a HREF="mailto:tom@jboss.org">Tom Elrod</a>
17  */

18 public class TransportInterceptor implements Interceptor
19 {
20    private Client client;
21
22    public TransportInterceptor(Client client)
23    {
24       this.client = client;
25    }
26
27    public String JavaDoc getName()
28    {
29       return "TransportInterceptor";
30    }
31
32    public Object JavaDoc invoke(Invocation invocation) throws Throwable JavaDoc
33    {
34       // need to add marshaller to invocation so can be found by transport later on
35
Marshaller marshaller = (Marshaller) invocation.getMetaData().getMetaData(RemotingInterceptorFactory.REMOTING,
36             RemotingInterceptorFactory.MARSHALLER);
37
38       if (marshaller != null)
39       {
40          client.setMarshaller(marshaller);
41       }
42
43       return client.invoke(invocation, null);
44
45    }
46 }
Popular Tags