KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > aspects > remoting > interceptors > marshall > MarshallInterceptor


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

18 public class MarshallInterceptor implements Interceptor
19 {
20    private Marshaller marshaller;
21
22    public MarshallInterceptor(Marshaller marshaller)
23    {
24       this.marshaller = marshaller;
25    }
26
27    public String JavaDoc getName()
28    {
29       return "MarshallInterceptor";
30    }
31
32    /**
33     * By default, this will only add the marshaller to be used to the invocation meta data,
34     * which will later be used by the transport.
35     *
36     * @param invocation
37     * @return
38     * @throws Throwable
39     */

40    public Object JavaDoc invoke(Invocation invocation) throws Throwable JavaDoc
41    {
42       // need to add marshaller to invocation so can be found by transport later on
43
invocation.getMetaData().addMetaData(RemotingInterceptorFactory.REMOTING,
44             RemotingInterceptorFactory.MARSHALLER, marshaller, PayloadKey.TRANSIENT);
45
46       return invocation.invokeNext();
47    }
48 }
Popular Tags