1 22 package org.jboss.ejb3.test.consumer; 23 24 import javax.ejb.ActivationConfigProperty ; 25 import javax.interceptor.AroundInvoke; 26 import javax.interceptor.InvocationContext; 27 import javax.annotation.PostConstruct; 28 import javax.annotation.PreDestroy; 29 import javax.jms.Message ; 30 import org.jboss.annotation.ejb.Consumer; 31 import org.jboss.annotation.ejb.CurrentMessage; 32 33 39 @Consumer(activationConfig = 40 { 41 @ActivationConfigProperty (propertyName="destinationType", propertyValue="javax.jms.Queue"), 42 @ActivationConfigProperty (propertyName="destination", propertyValue="queue/mdbtest") 43 }) 44 public class QueueTestConsumer implements QueueTestRemote, QueueTestXA, QueueTestLocal 45 { 46 @CurrentMessage Message currentMessage; 47 48 private Message setterMessage; 49 50 @CurrentMessage void setMessage(Message msg) 51 { 52 setterMessage = msg; 53 } 54 55 public void method1(String msg, int num) 56 { 57 TestStatusBean.queueRan = "method1"; 58 TestStatusBean.fieldMessage = currentMessage != null; 59 TestStatusBean.setterMessage = setterMessage != null; 60 61 System.out.println("method1(" + msg + ", " + num + ")"); 62 } 63 64 public void method2(String msg, float num) 65 { 66 TestStatusBean.queueRan = "method2"; 67 68 TestStatusBean.fieldMessage = currentMessage != null; 69 TestStatusBean.setterMessage = setterMessage != null; 70 71 System.out.println("method2(" + msg + ", " + num + ")"); 72 } 73 74 @AroundInvoke 75 public Object intercept(InvocationContext ctx) throws Exception 76 { 77 System.out.println("**** intercepted ****" + ctx.getMethod().getName()); 78 TestStatusBean.interceptedQueue = ctx.getMethod().getName(); 79 return ctx.proceed(); 80 } 81 82 @PostConstruct 83 public void postConstruct() 84 { 85 TestStatusBean.postConstruct = true; 86 } 87 88 @PreDestroy 89 public void preDestroy() 90 { 91 TestStatusBean.preDestroy = true; 92 } 93 } 94 | Popular Tags |