1 22 package org.jboss.tutorial.service_deployment_descriptor.bean; 23 24 import org.jboss.annotation.ejb.Depends; 25 26 import javax.interceptor.AroundInvoke; 27 import javax.interceptor.InvocationContext; 28 import javax.management.ObjectName ; 29 import javax.management.MBeanServerFactory ; 30 import javax.management.MBeanServer ; 31 32 36 public class ServiceThree implements ServiceThreeManagement 37 { 38 @Depends ("jboss.j2ee:jar=tutorial.jar,name=ServiceOne,service=EJB3,type=ManagementInterface") 39 public ObjectName serviceOneName; 40 private ServiceTwoManagement service2; 41 42 @Depends ("tutorial:service=serviceTwo") 43 public void setServiceTwo(ServiceTwoManagement service2) 44 { 45 this.service2 = service2; 46 } 47 48 public String serviceOneHello()throws Exception 49 { 50 Object [] args = new Object [0]; 51 String [] signature = new String [0]; 52 System.out.println("ServiceThree - Calling ServiceOne.sayHello() via JMX server"); 53 MBeanServer server = (MBeanServer )MBeanServerFactory.findMBeanServer(null).get(0); 54 return (String )server.invoke(serviceOneName, "sayHello", args, signature); 55 } 56 57 public String serviceTwoHello() 58 { 59 System.out.println("ServiceThree - Calling ServiceTwo.sayHello() via MBean proxy"); 60 return service2.sayHello(); 61 } 62 63 @AroundInvoke 65 public Object intercept(InvocationContext ctx) throws Exception 66 { 67 System.out.println("ServiceThree - Interceptor"); 68 return ctx.proceed(); 69 } 70 71 public void start() throws Exception 73 { 74 System.out.println("ServiceThree - Starting"); 75 } 76 77 public void stop() 78 { 79 System.out.println("ServiceThree - Stopping"); 80 } 81 82 } 83 | Popular Tags |