01: package org.objectweb.celtix.bus.busimpl;
02:
03: import java.util.ArrayList;
04: import java.util.List;
05:
06: import org.objectweb.celtix.bus.management.jmx.export.annotation.ManagedAttribute;
07: import org.objectweb.celtix.bus.management.jmx.export.annotation.ManagedResource;
08: import org.objectweb.celtix.configuration.types.ClassNamespaceMappingListType;
09: import org.objectweb.celtix.configuration.types.ClassNamespaceMappingType;
10:
11: import org.objectweb.celtix.management.Instrumentation;
12:
13: @ManagedResource(componentName="CeltixBus",description="The Celtix bus managed component ",currencyTimeLimit=15,persistPolicy="OnUpdate")
14: public class CeltixBusInstrumentation implements Instrumentation {
15:
16: private static final String INSTRUMENTED_NAME = "Bus";
17: private String objectName;
18: private CeltixBus bus;
19: private String[] transportFactories;
20: private String[] bindingFactories;
21:
22: public CeltixBusInstrumentation(CeltixBus b) {
23: bus = b;
24: objectName = b.getBusID();
25: bindingFactories = getFactoriesInfor("bindingFactories");
26: transportFactories = getFactoriesInfor("transportFactories");
27: }
28:
29: public Object getComponent() {
30: return bus;
31: }
32:
33: public String getInstrumentationName() {
34: return INSTRUMENTED_NAME;
35: }
36:
37: public final String[] getFactoriesInfor(String cfgName) {
38: List<String> factoriesList = new ArrayList<String>();
39: Object obj = bus.getConfiguration().getObject(cfgName);
40: assert obj != null;
41: List<ClassNamespaceMappingType> factoryMappings = ((ClassNamespaceMappingListType) obj)
42: .getMap();
43: for (ClassNamespaceMappingType mapping : factoryMappings) {
44: String classname = mapping.getClassname();
45: List<String> namespaceList = mapping.getNamespace();
46: for (String namespace : namespaceList) {
47: String temp = "NameSpace: " + namespace
48: + "\n FactoryClass: " + classname;
49: factoriesList.add(temp);
50: }
51: }
52: String[] factories = new String[factoriesList.size()];
53: return factoriesList.toArray(factories);
54: }
55:
56: @ManagedAttribute(description="The celtix bus Transport factories information",persistPolicy="OnUpdate")
57: public String[] getTransportFactories() {
58: return transportFactories;
59: }
60:
61: @ManagedAttribute(description="The celtix bus binging factories information",persistPolicy="OnUpdate")
62: public String[] getBindingFactories() {
63: return bindingFactories;
64: }
65:
66: @ManagedAttribute(description="The celtix bus Serivce monitors counters",persistPolicy="OnUpdate")
67: public Boolean isServicesMonitoring() {
68: return bus.getConfiguration().getBoolean("servicesMonitoring");
69: }
70:
71: public void setServicesMonitoring(Boolean value) {
72: if (value != bus.getConfiguration().getBoolean(
73: "servicesMonitoring")) {
74: bus.getConfiguration().setObject("servicesMonitoring",
75: value);
76: }
77: }
78:
79: public String getUniqueInstrumentationName() {
80: return objectName;
81: }
82: }
|