1 package org.objectweb.celtix.bus.jaxws; 2 3 4 import java.util.ArrayList ; 5 import java.util.List ; 6 7 import javax.wsdl.Port; 8 import javax.wsdl.WSDLException; 9 import javax.xml.namespace.QName ; 10 import javax.xml.ws.handler.Handler; 11 12 import org.objectweb.celtix.bus.management.jmx.export.annotation.ManagedAttribute; 13 import org.objectweb.celtix.bus.management.jmx.export.annotation.ManagedOperation; 14 import org.objectweb.celtix.bus.management.jmx.export.annotation.ManagedResource; 15 import org.objectweb.celtix.management.Instrumentation; 16 import org.objectweb.celtix.wsdl.EndpointReferenceUtils; 17 18 @ManagedResource(componentName = "Endpoint", 19 description = "The Celtix bus Endpoint", 20 currencyTimeLimit = 15, persistPolicy = "OnUpdate") 21 public class EndpointInstrumentation implements Instrumentation { 22 private static final String INSTRUMENTED_NAME = "Bus.Endpoint"; 23 private String objectName; 24 private EndpointImpl endPoint; 25 26 public EndpointInstrumentation(EndpointImpl ep) { 27 endPoint = ep; 28 objectName = ",Bus.Service=\"" 30 + getEndpointServiceName() + "\"" 31 + ",Bus.Port=" + getEndpointPortName() 32 + ",name=Endpoint"; 33 } 34 35 public String getInstrumentationName() { 36 return INSTRUMENTED_NAME; 37 } 38 39 public Object getComponent() { 40 return endPoint; 41 } 42 43 public String getUniqueInstrumentationName() { 44 return objectName; 45 } 46 47 private String getEndpointServiceName() { 48 QName serviceName = EndpointReferenceUtils.getServiceName(endPoint.getEndpointReferenceType()); 49 if (serviceName != null) { 50 return serviceName.toString(); 51 } else { 52 return ""; 53 } 54 55 } 56 57 private String getEndpointPortName() { 58 Port port; 59 String portName = null; 60 try { 61 62 port = EndpointReferenceUtils.getPort(endPoint.getBus().getWSDLManager(), 63 endPoint.getEndpointReferenceType()); 64 if (null != port) { 65 portName = port.getName(); 66 } else { 67 portName = ""; 68 } 69 70 } catch (WSDLException e) { 71 } 74 if (portName != null) { 75 return portName; 76 } else { 77 return ""; 78 } 79 } 80 81 @ManagedAttribute(currencyTimeLimit = 30, 82 description = "The celtix bus Endpoint service name") 83 public String getServiceName() { 84 return getEndpointServiceName(); 85 } 86 87 @ManagedAttribute(currencyTimeLimit = 30, 88 description = "The celtix bus Endpoint port name") 89 public String getPortName() { 90 return getEndpointPortName(); 91 } 92 93 @ManagedAttribute(currencyTimeLimit = -1, 94 description = "The state of celtix bus Endpoint") 95 public String getState() { 96 if (endPoint.isPublished()) { 97 return "ACTIVED"; 98 } else { 99 return "DEACTIVED"; 100 } 101 } 102 103 @ManagedAttribute(currencyTimeLimit = 30, 104 description = "The celtix bus Registed Endpoints's handlerChains") 105 public String [] getHandlerChains() { 106 List <String > strList = new ArrayList <String >(); 107 List <Handler> handlers = endPoint.getServerBinding().getBinding().getHandlerChain(); 108 for (Handler h : handlers) { 109 String handler = h.getClass().getName(); 110 strList.add(handler); 111 } 112 String [] strings = new String [strList.size()]; 113 return strList.toArray(strings); 114 } 115 116 117 118 @ManagedOperation(currencyTimeLimit = 30, 119 description = "The operation to start the celtix bus Endpoint") 120 public void start() { 121 endPoint.start(); 122 } 123 124 @ManagedOperation(currencyTimeLimit = 30, 125 description = "The operation to stop the celtix bus Endpoint") 126 public void stop() { 127 endPoint.stop(); 128 } 129 130 } 131 | Popular Tags |