1 /*2 * JBoss, the OpenSource J2EE webOS3 *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 ;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 messages19 * 20 * @author <a HREF="mailto:adrian@jboss.org>Adrian Brock</a>21 * @version $Revision: 1.4 $22 */23 public class MessageFactoryInterceptor24 implements Interceptor25 {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 getName()41 {42 return "MessageFactoryInterceptor";43 }44 45 public Object invoke(Invocation invocation) throws Throwable 46 {47 String methodName = ((MethodInvocation) invocation).getMethod().getName();48 if (methodName.equals("createMessage"))49 return createMessage(invocation);50 else51 return invocation.invokeNext();52 }53 54 // Protected ------------------------------------------------------55 56 protected Message createMessage(Invocation invocation)57 throws Throwable 58 {59 return new StandardMessage((SessionDelegate) Container.getProxy(invocation));60 }61 62 // Package Private ------------------------------------------------63 64 // Private --------------------------------------------------------65 66 // Inner Classes --------------------------------------------------67 68 }69