1 7 package org.jboss.jms.server.container; 8 9 import org.jboss.aop.advice.Interceptor; 10 import org.jboss.aop.joinpoint.Invocation; 11 import org.jboss.aop.joinpoint.MethodInvocation; 12 import org.jboss.jms.message.JBossMessage; 13 import org.jboss.jms.server.DeliveryEndpoint; 14 import org.jboss.jms.server.DeliveryEndpointFactory; 15 import org.jboss.jms.server.MessageReference; 16 17 23 public class ServerProducerInterceptor 24 implements Interceptor 25 { 26 28 30 32 public static ServerProducerInterceptor singleton = new ServerProducerInterceptor(); 33 34 36 38 40 public String getName() 41 { 42 return "ServerProducerInterceptor"; 43 } 44 45 public Object invoke(Invocation invocation) throws Throwable 46 { 47 MethodInvocation mi = (MethodInvocation) invocation; 48 String methodName = mi.getMethod().getName(); 49 if (methodName.equals("send")) 50 { 51 52 JBossMessage message = (JBossMessage) mi.getArguments()[0]; 53 JBossMessage clone = (JBossMessage) message.clone(); 54 DeliveryEndpointFactory factory = (DeliveryEndpointFactory) mi.getMetaData("JMS", "DeliveryEndpointFactory"); 55 MessageReference reference = factory.getMessageReference(clone); 56 DeliveryEndpoint endpoint = factory.getDeliveryEndpoint(reference); 57 endpoint.deliver(reference); 58 return null; 59 } 60 else if (methodName.equals("closing") || methodName.equals("close")) 61 return null; 62 throw new UnsupportedOperationException (mi.getMethod().toString()); 63 } 64 65 67 69 71 73 } 74 | Popular Tags |