KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > jms > message > standard > MessageFactoryInterceptor


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.jms.message.standard;
8
9 import javax.jms.Message JavaDoc;
10
11 import org.jboss.aop.advice.Interceptor;
12 import org.jboss.aop.joinpoint.Invocation;
13 import org.jboss.aop.joinpoint.MethodInvocation;
14 import org.jboss.jms.client.SessionDelegate;
15 import org.jboss.jms.container.Container;
16
17 /**
18  * An interceptor for creating messages
19  *
20  * @author <a HREF="mailto:adrian@jboss.org>Adrian Brock</a>
21  * @version $Revision: 1.4 $
22  */

23 public class MessageFactoryInterceptor
24    implements Interceptor
25 {
26    // Constants -----------------------------------------------------
27

28    // Attributes ----------------------------------------------------
29

30    // Static --------------------------------------------------------
31

32    public static final MessageFactoryInterceptor singleton = new MessageFactoryInterceptor();
33
34    // Constructors --------------------------------------------------
35

36    // Public --------------------------------------------------------
37

38    // Interceptor implementation -----------------------------------
39

40    public String JavaDoc getName()
41    {
42       return "MessageFactoryInterceptor";
43    }
44
45    public Object JavaDoc invoke(Invocation invocation) throws Throwable JavaDoc
46    {
47       String JavaDoc methodName = ((MethodInvocation) invocation).getMethod().getName();
48       if (methodName.equals("createMessage"))
49          return createMessage(invocation);
50       else
51          return invocation.invokeNext();
52    }
53
54    // Protected ------------------------------------------------------
55

56    protected Message JavaDoc createMessage(Invocation invocation)
57       throws Throwable JavaDoc
58    {
59       return new StandardMessage((SessionDelegate) Container.getProxy(invocation));
60    }
61
62    // Package Private ------------------------------------------------
63

64    // Private --------------------------------------------------------
65

66    // Inner Classes --------------------------------------------------
67

68 }
69
Popular Tags