KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > bus > jaxws > EndpointInstrumentation


1 package org.objectweb.celtix.bus.jaxws;
2
3
4 import java.util.ArrayList JavaDoc;
5 import java.util.List JavaDoc;
6
7 import javax.wsdl.Port;
8 import javax.wsdl.WSDLException;
9 import javax.xml.namespace.QName JavaDoc;
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 JavaDoc INSTRUMENTED_NAME = "Bus.Endpoint";
23     private String JavaDoc objectName;
24     private EndpointImpl endPoint;
25     
26     public EndpointInstrumentation(EndpointImpl ep) {
27         endPoint = ep;
28         // setup the port name
29
objectName = ",Bus.Service=\""
30             + getEndpointServiceName() + "\""
31             + ",Bus.Port=" + getEndpointPortName()
32             + ",name=Endpoint";
33     }
34     
35     public String JavaDoc getInstrumentationName() {
36         return INSTRUMENTED_NAME;
37     }
38
39     public Object JavaDoc getComponent() {
40         return endPoint;
41     }
42     
43     public String JavaDoc getUniqueInstrumentationName() {
44         return objectName;
45     }
46     
47     private String JavaDoc getEndpointServiceName() {
48         QName JavaDoc serviceName = EndpointReferenceUtils.getServiceName(endPoint.getEndpointReferenceType());
49         if (serviceName != null) {
50             return serviceName.toString();
51         } else {
52             return "";
53         }
54         
55     }
56     
57     private String JavaDoc getEndpointPortName() {
58         Port port;
59         String JavaDoc 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             // wsdlexception
72
// Now do nothing here
73
}
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 JavaDoc getServiceName() {
84         return getEndpointServiceName();
85     }
86     
87     @ManagedAttribute(currencyTimeLimit = 30,
88                       description = "The celtix bus Endpoint port name")
89     public String JavaDoc getPortName() {
90         return getEndpointPortName();
91     }
92     
93     @ManagedAttribute(currencyTimeLimit = -1,
94                       description = "The state of celtix bus Endpoint")
95     public String JavaDoc 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 JavaDoc[] getHandlerChains() {
106         List JavaDoc<String JavaDoc> strList = new ArrayList JavaDoc<String JavaDoc>();
107         List JavaDoc<Handler> handlers = endPoint.getServerBinding().getBinding().getHandlerChain();
108         for (Handler h : handlers) {
109             String JavaDoc handler = h.getClass().getName();
110             strList.add(handler);
111         }
112         String JavaDoc[] strings = new String JavaDoc[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