1 7 package org.jboss.tutorial.service.bean; 8 9 import org.jboss.annotation.ejb.Service; 10 import org.jboss.annotation.ejb.Depends; 11 import org.jboss.annotation.ejb.Depends; 12 import org.jboss.annotation.ejb.Service; 13 14 import javax.ejb.AroundInvoke; 15 import javax.ejb.InvocationContext; 16 import javax.management.ObjectName ; 17 import javax.management.MBeanServerFactory ; 18 import javax.management.MBeanServer ; 19 20 24 @Service 25 public class ServiceThree implements ServiceThreeManagement 26 { 27 @Depends ("jboss.j2ee:name=org.jboss.tutorial.service.bean.ServiceOne,service=EJB3,type=service") 28 public ObjectName serviceOneName; 29 private ServiceTwoManagement service2; 30 31 @Depends ("tutorial:service=serviceTwo") 32 public void setServiceTwo(ServiceTwoManagement service2) 33 { 34 this.service2 = service2; 35 } 36 37 public String serviceOneHello()throws Exception 38 { 39 Object [] args = new Object [0]; 40 String [] signature = new String [0]; 41 System.out.println("ServiceThree - Calling ServiceOne.sayHello() via JMX server"); 42 MBeanServer server = (MBeanServer )MBeanServerFactory.findMBeanServer(null).get(0); 43 return (String )server.invoke(serviceOneName, "sayHello", args, signature); 44 } 45 46 public String serviceTwoHello() 47 { 48 System.out.println("ServiceThree - Calling ServiceTwo.sayHello() via MBean proxy"); 49 return service2.sayHello(); 50 } 51 52 @AroundInvoke 54 public Object intercept(InvocationContext ctx) throws Exception 55 { 56 System.out.println("ServiceThree - Interceptor"); 57 return ctx.proceed(); 58 } 59 60 public void start() throws Exception 62 { 63 System.out.println("ServiceThree - Starting"); 64 } 65 66 public void stop() 67 { 68 System.out.println("ServiceThree - Stopping"); 69 } 70 71 } 72 | Popular Tags |