KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > kilim > tools > jmx > ComponentMBean


1 package org.objectweb.kilim.tools.jmx;
2
3 import java.lang.reflect.Constructor JavaDoc;
4 import java.lang.reflect.InvocationTargetException JavaDoc;
5 import java.lang.reflect.Method JavaDoc;
6 import java.util.Hashtable JavaDoc;
7 import java.util.Iterator JavaDoc;
8 import java.util.LinkedList JavaDoc;
9 import java.util.List JavaDoc;
10
11 import javax.management.Attribute JavaDoc;
12 import javax.management.AttributeList JavaDoc;
13 import javax.management.AttributeNotFoundException JavaDoc;
14 import javax.management.DynamicMBean JavaDoc;
15 import javax.management.InstanceAlreadyExistsException JavaDoc;
16 import javax.management.InstanceNotFoundException JavaDoc;
17 import javax.management.InvalidAttributeValueException JavaDoc;
18 import javax.management.JMRuntimeException JavaDoc;
19 import javax.management.MBeanAttributeInfo JavaDoc;
20 import javax.management.MBeanConstructorInfo JavaDoc;
21 import javax.management.MBeanException JavaDoc;
22 import javax.management.MBeanInfo JavaDoc;
23 import javax.management.MBeanNotificationInfo JavaDoc;
24 import javax.management.MBeanOperationInfo JavaDoc;
25 import javax.management.MBeanParameterInfo JavaDoc;
26 import javax.management.MBeanRegistration JavaDoc;
27 import javax.management.MBeanRegistrationException JavaDoc;
28 import javax.management.MBeanServer JavaDoc;
29 import javax.management.MalformedObjectNameException JavaDoc;
30 import javax.management.NotCompliantMBeanException JavaDoc;
31 import javax.management.ObjectInstance JavaDoc;
32 import javax.management.ObjectName JavaDoc;
33 import javax.management.ReflectionException JavaDoc;
34
35
36 import org.objectweb.kilim.KilimException;
37 import org.objectweb.kilim.description.KILIM;
38 import org.objectweb.kilim.description.Property;
39 import org.objectweb.kilim.description.Slot;
40 import org.objectweb.kilim.description.TemplateElementImpl;
41 import org.objectweb.kilim.helpers.KilimHelper;
42 import org.objectweb.kilim.model.Component;
43 import org.objectweb.kilim.model.ComponentInterface;
44 import org.objectweb.kilim.model.ComponentProperty;
45 import org.objectweb.kilim.model.ComponentSlot;
46 import org.objectweb.kilim.model.RtCollectionPort;
47 import org.objectweb.kilim.model.RtComponentInterface;
48 import org.objectweb.kilim.model.RtComponentProperty;
49 import org.objectweb.kilim.model.RtComponentSlot;
50 import org.objectweb.kilim.model.RtSingleValuePort;
51 import org.omg.CORBA.INTF_REPOS JavaDoc;
52
53 /**
54  * @author delpiano
55  *
56  * To change this generated comment edit the template variable "typecomment":
57  * Window>Preferences>Java>Templates.
58  * To enable and disable the creation of type comments go to
59  * Window>Preferences>Java>Code Generation.
60  */

61 public class ComponentMBean implements DynamicMBean JavaDoc, MBeanRegistration JavaDoc {
62     
63     private static final String JavaDoc JMX_META_DATA_NAME = "JMX";
64
65     private static MBeanServer JavaDoc mbeanserver;
66     
67     private MBeanInfo JavaDoc dMBeanInfo = null;
68     private Component component;
69     private String JavaDoc root_component_name;
70     private String JavaDoc root_domain_name;
71
72     public ComponentMBean(String JavaDoc template_name) {
73         super();
74         try {
75             component = KilimHelper.newComponent(template_name , this.getClass());
76         } catch (Exception JavaDoc e) {
77             e.printStackTrace();
78             throw new JMRuntimeException JavaDoc(e.getMessage());
79         }
80         buildDynamicMBeanInfo();
81     }
82
83     public ComponentMBean(Component component) {
84         super();
85         this.component = component;
86         buildDynamicMBeanInfo();
87     }
88     
89     private ComponentMBean(Component component , String JavaDoc root_component_name , String JavaDoc root_domain_name) {
90         this(component);
91         this.root_component_name = root_component_name;
92         this.root_domain_name = root_domain_name;
93     }
94     
95     public static void setDefaultMBeanServer(MBeanServer JavaDoc mbeanserver) {
96         ComponentMBean.mbeanserver = mbeanserver;
97     }
98
99     /**
100      * @see javax.management.DynamicMBean#getAttribute(String)
101      */

102     public Object JavaDoc getAttribute(String JavaDoc name)
103         throws AttributeNotFoundException JavaDoc, MBeanException JavaDoc, ReflectionException JavaDoc {
104             
105         if (name.equals("InterfacesNames")) { return getPortsNames(); }
106         if (name.equals("SlotsNames")) { return getSlotsNames(); }
107         
108         ComponentInterface rslt = null;
109         
110         try {
111             rslt = component.getInterface(denormalize(name));
112         } catch (KilimException e) {
113             throw new MBeanException JavaDoc(e);
114         }
115         
116         if (rslt == null) { throw new AttributeNotFoundException JavaDoc(); }
117         
118         Object JavaDoc value = null;
119         try {
120             value = rslt.getValue();
121         } catch (KilimException e) {
122             throw new MBeanException JavaDoc(e);
123         }
124         
125         return value;
126     }
127     
128     private String JavaDoc cached_ports_names;
129     
130     private Object JavaDoc getPortsNames() {
131     
132         if (cached_ports_names != null) { return cached_ports_names; }
133     
134         StringBuffer JavaDoc prtsnms_bffr = new StringBuffer JavaDoc();
135         boolean first = true;
136         
137         for (Iterator JavaDoc it = component.getInterfaces() ; it.hasNext() ;) {
138             ComponentInterface intf = (ComponentInterface) it.next();
139             if (intf.isSingleValuePort()) {
140                 if (first) { first = false; } else { prtsnms_bffr.append(" / "); }
141                 RtSingleValuePort port = (RtSingleValuePort) intf;
142                 prtsnms_bffr.append(port.getLocalName());
143             }
144         }
145         
146         cached_ports_names = prtsnms_bffr.toString();
147         
148         return cached_ports_names;
149     
150     }
151     
152     private String JavaDoc cached_slots_names;
153     
154     private Object JavaDoc getSlotsNames() {
155         
156         if (cached_slots_names != null) { return cached_slots_names; }
157         
158         StringBuffer JavaDoc slots_nms_bffr = new StringBuffer JavaDoc();
159         boolean first = true;
160         
161         for (Iterator JavaDoc it = component.getSlots() ; it.hasNext() ;) {
162             RtComponentSlot slt = (RtComponentSlot) it.next();
163             if (first) { first = false; } else { slots_nms_bffr.append(" / "); }
164             slots_nms_bffr.append(slt.getLocalName());
165         }
166         
167         cached_slots_names = slots_nms_bffr.toString();
168         
169         return cached_slots_names;
170         
171     }
172
173     /**
174      * @see javax.management.DynamicMBean#getAttributes(String[])
175      */

176     public AttributeList JavaDoc getAttributes(String JavaDoc[] names) {
177         
178         AttributeList JavaDoc rslt = new AttributeList JavaDoc();
179         
180         for (int i = 0 ; i < names.length ; i++) {
181
182             try {
183                 rslt.add(getAttribute(names[i]));
184             } catch (Exception JavaDoc e) {
185                 e.printStackTrace();
186                 continue;
187             }
188             
189         }
190         return rslt;
191     }
192
193     /**
194      * @see javax.management.DynamicMBean#getMBeanInfo()
195      */

196     public MBeanInfo JavaDoc getMBeanInfo() {
197         return dMBeanInfo;
198     }
199
200     /**
201      * @see javax.management.DynamicMBean#invoke(String, Object[], String[])
202      */

203     public Object JavaDoc invoke(String JavaDoc method_name, Object JavaDoc[] params, String JavaDoc[] signature)
204         throws MBeanException JavaDoc, ReflectionException JavaDoc {
205         
206         Class JavaDoc[] clsss = new Class JavaDoc[signature.length];
207         for (int i = 0 ; i < signature.length ; i++) {
208             try {
209                 clsss[i] = this.getClass().getClassLoader().loadClass(signature[i]);
210             } catch (ClassNotFoundException JavaDoc e) {
211                 throw new ReflectionException JavaDoc(e);
212             }
213         }
214         
215         Method JavaDoc method = null;
216         try {
217             method = this.getClass().getMethod(method_name , clsss);
218         } catch (NoSuchMethodException JavaDoc e) {
219             throw new ReflectionException JavaDoc(e);
220         }
221         
222         Object JavaDoc result = null;
223         try {
224             result = method.invoke(this , params);
225         } catch (InvocationTargetException JavaDoc e){
226             throw new ReflectionException JavaDoc(e);
227         } catch (IllegalAccessException JavaDoc e){
228             throw new ReflectionException JavaDoc(e);
229         }
230         
231         return result;
232
233     }
234
235     /**
236      * @see javax.management.DynamicMBean#setAttribute(Attribute)
237      */

238     public void setAttribute(Attribute JavaDoc att)
239         throws
240             AttributeNotFoundException JavaDoc,
241             InvalidAttributeValueException JavaDoc,
242             MBeanException JavaDoc,
243             ReflectionException JavaDoc {
244                 
245         String JavaDoc nm = denormalize(att.getName());
246         Object JavaDoc vl = att.getValue();
247         
248         ComponentInterface intf = null;
249         try {
250             intf = component.getInterface(nm);
251         } catch (KilimException e) {
252             throw new MBeanException JavaDoc(e);
253         }
254         
255         if (intf == null) { throw new AttributeNotFoundException JavaDoc(nm);}
256         
257         if (!(intf instanceof RtComponentProperty)) {
258             throw new AttributeNotFoundException JavaDoc(nm);
259         }
260         
261         RtComponentProperty prpt = (RtComponentProperty) intf;
262         
263         try {
264             prpt.setValue(vl);
265         } catch (KilimException e) {
266             throw new InvalidAttributeValueException JavaDoc(vl.toString() + "[" + vl.getClass().toString() + "]");
267         }
268         
269         //Quelle interface unbind/getValuer ???
270

271         
272     }
273
274     /**
275      * @see javax.management.DynamicMBean#setAttributes(AttributeList)
276      */

277     public AttributeList JavaDoc setAttributes(AttributeList JavaDoc attlist) {
278         
279         AttributeList JavaDoc rslt = new AttributeList JavaDoc();
280         
281         for (Iterator JavaDoc it = attlist.iterator() ; it.hasNext() ; ) {
282             Attribute JavaDoc crrnt_att = (Attribute JavaDoc) it.next();
283             
284             try {
285                 setAttribute(crrnt_att);
286             } catch (Exception JavaDoc e) {
287                 e.printStackTrace();
288                 continue;
289             }
290             
291             rslt.add(crrnt_att);
292             
293         }
294         
295         return rslt;
296
297     }
298     
299     //Specific monitoring methods -----------------------------------------
300

301     public String JavaDoc getValueOnInterface(String JavaDoc name) {
302         
303         ComponentInterface intrfc = null;
304         try {
305             
306             intrfc = component.getInterface(name);
307
308             if (intrfc != null) {
309                 return intrfc.getValue().toString();
310             }
311
312         } catch (KilimException e) {
313             e.printStackTrace();
314         }
315         
316         return null;
317     }
318     
319     public boolean rebindInterface(String JavaDoc name) {
320         
321         RtSingleValuePort intrfc = null;
322         
323         try {
324             
325             ComponentInterface retrieved = component.getInterface(name);
326              
327             if (!(retrieved instanceof RtSingleValuePort)) {
328                 return false;
329             }
330             
331             intrfc = (RtSingleValuePort) retrieved;
332
333             if (intrfc != null) {
334                 intrfc.update();
335                 return true;
336             }
337
338         } catch (KilimException e) {
339             e.printStackTrace();
340         }
341         
342         return false;
343     }
344     
345     public Component getComponent() {
346         return component;
347     }
348     
349     public boolean fork() {
350         
351         Component forked_component = null;
352         try {
353             forked_component = component.fork();
354         } catch (KilimException e) {
355             e.printStackTrace();
356             return false;
357         }
358         
359         
360         ComponentMBean forked_component_mbean = new ComponentMBean(forked_component);
361         
362         try {
363             mbeanserver.registerMBean(forked_component_mbean , null);
364         } catch (MBeanRegistrationException JavaDoc e) {
365             e.printStackTrace();
366             return false;
367         } catch (InstanceAlreadyExistsException JavaDoc e) {
368             e.printStackTrace();
369             return false;
370         } catch (NotCompliantMBeanException JavaDoc e) {
371             e.printStackTrace();
372             return false;
373         }
374             
375         return true;
376     }
377     
378     public boolean plugComponent(String JavaDoc slot_nm , ObjectName JavaDoc obj_nm) {
379         return plugAndUnplugComponent(true , slot_nm , obj_nm);
380     }
381     
382     public boolean unplugComponent(String JavaDoc slot_nm , ObjectName JavaDoc obj_nm) {
383         return plugAndUnplugComponent(false , slot_nm , obj_nm);
384     }
385     
386     public boolean plugAndUnplugComponent(boolean is_plug , String JavaDoc slot_nm , ObjectName JavaDoc obj_nm) {
387         
388         System.out.println("Plugging \"" + obj_nm + "\" in slot \"" + slot_nm + "\".");
389         
390          Component plug;
391          try {
392             plug = (Component) mbeanserver.invoke(obj_nm , "getComponent" , new Object JavaDoc[0] , new String JavaDoc[0]);
393          } catch (InstanceNotFoundException JavaDoc e) {
394             e.printStackTrace();
395             return false;
396          } catch (MBeanException JavaDoc e) {
397             e.printStackTrace();
398             return false;
399          } catch (ReflectionException JavaDoc e) {
400             e.printStackTrace();
401             return false;
402          }
403          
404          ComponentSlot slt = null;
405          try {
406             slt = component.getSlot(slot_nm);
407          } catch (KilimException e) {
408             e.printStackTrace();
409             return false;
410          }
411          
412          try {
413              if (is_plug) {
414                 slt.plug(plug);
415              } else {
416                 slt.unplug(plug);
417              }
418          } catch (KilimException e) {
419             e.printStackTrace();
420             return false;
421          }
422          
423          return true;
424     }
425     
426     /*
427      * -----------------------------------------------------
428      * PRIVATE METHODS
429      * -----------------------------------------------------
430      */

431   
432     /**
433      * Build the private dMBeanInfo field,
434      * which represents the management interface exposed by the MBean;
435      * that is, the set of attributes, constructors, operations and notifications
436      * which are available for management.
437      *
438      * A reference to the dMBeanInfo object is returned by the getMBeanInfo() method
439      * of the DynamicMBean interface. Note that, once constructed, an MBeanInfo object is immutable.
440      */

441     private void buildDynamicMBeanInfo() {
442
443     
444     LinkedList JavaDoc prprts = new LinkedList JavaDoc();
445
446     Iterator JavaDoc edtbl_prprts = getEditableProperties();
447     Iterator JavaDoc mntrd_intrfcs = getMonitoredInterfaces();
448     
449     LinkedList JavaDoc attributes_list = new LinkedList JavaDoc();
450     
451     attributes_list.add(new MBeanAttributeInfo JavaDoc("InterfacesNames" ,
452                         "java.lang.String",
453                         "Ports Names",
454                         true,
455                         false,
456                         false)
457                         );
458                         
459     attributes_list.add(new MBeanAttributeInfo JavaDoc("SlotsNames" ,
460                         "java.lang.String",
461                         "Slots Names",
462                         true,
463                         false,
464                         false)
465                         );
466                         
467     if (mntrd_intrfcs != null) {
468         for (; mntrd_intrfcs.hasNext() ;) {
469                 ComponentInterface crrnt = (ComponentInterface) mntrd_intrfcs.next();
470                 Class JavaDoc clss = String JavaDoc.class;
471                 try {
472                     clss = crrnt.getValue().getClass();
473                 } catch (KilimException exc) {}
474                 attributes_list.add(new MBeanAttributeInfo JavaDoc(normalize(crrnt.getLocalName()) ,
475                                     clss.getName(),
476                                     crrnt.getQualifiedName(),
477                                     true,
478                                     false,
479                                     false)
480                                     );
481         }
482     }
483     
484     if (edtbl_prprts != null) {
485         for (; edtbl_prprts.hasNext() ;) {
486                 ComponentProperty crrnt = (ComponentProperty) edtbl_prprts.next();
487                 Property property = (Property) crrnt.getElementDescription();
488                 Class JavaDoc type = property.getType();
489                 attributes_list.add(new MBeanAttributeInfo JavaDoc(normalize(crrnt.getLocalName()) ,
490                                     type.getName(),
491                                     crrnt.getQualifiedName(),
492                                     true,
493                                     true,
494                                     false)
495                                     );
496         }
497     }
498
499     //Registering all public properties of the component as attributes
500

501     MBeanAttributeInfo JavaDoc[] dAttributes = new MBeanAttributeInfo JavaDoc[attributes_list.size()];
502     attributes_list.toArray(dAttributes);
503         
504     Constructor JavaDoc[] constructors = this.getClass().getConstructors();
505     
506     MBeanConstructorInfo JavaDoc[] dConstructors = new MBeanConstructorInfo JavaDoc[1];
507     dConstructors[0] = new MBeanConstructorInfo JavaDoc("ComponentMBean(): Constructs a Component",
508                             constructors[0]);
509     
510     
511     MBeanOperationInfo JavaDoc[] dOperations = new MBeanOperationInfo JavaDoc[6];
512     
513     MBeanParameterInfo JavaDoc[] parameters_0 = new MBeanParameterInfo JavaDoc[1];
514     parameters_0[0] = new MBeanParameterInfo JavaDoc("Interface" , "java.lang.String" , "The name of the Interface to get the Value from.");
515     dOperations[0] = new MBeanOperationInfo JavaDoc("getValueOnInterface" , "Get the value of a given Interface, bind it if necessary." , parameters_0 , "java.lang.String" , MBeanOperationInfo.ACTION);
516
517     dOperations[1] = new MBeanOperationInfo JavaDoc("rebindInterface" , "Updates the state of a given Interface's Value." , parameters_0 , "java.lang.String" , MBeanOperationInfo.ACTION);
518     
519     Method JavaDoc meth = null;
520     try {
521         meth = this.getClass().getMethod("getComponent" , null);
522     } catch (NoSuchMethodException JavaDoc e) {
523         e.printStackTrace();
524     }
525     dOperations[2] = new MBeanOperationInfo JavaDoc("Get Component" ,meth);
526
527     meth = null;
528     try {
529         meth = this.getClass().getMethod("fork" , null);
530     } catch (NoSuchMethodException JavaDoc e) {
531         e.printStackTrace();
532     }
533     dOperations[3] = new MBeanOperationInfo JavaDoc("Fork Component" ,meth);
534     
535     MBeanParameterInfo JavaDoc[] parameters = new MBeanParameterInfo JavaDoc[2];
536     parameters[0] = new MBeanParameterInfo JavaDoc("Slot" , "java.lang.String" , "The Slot where the Component will be Plugged.");
537     parameters[1] = new MBeanParameterInfo JavaDoc("Component" , "javax.management.ObjectName" , "The Name of the Component to Plug.");
538     dOperations[4] = new MBeanOperationInfo JavaDoc("plugComponent" , "Plug Component into given Slot" , parameters , "java.lang.Boolean" , MBeanOperationInfo.ACTION);
539     
540     
541     parameters[0] = new MBeanParameterInfo JavaDoc("Slot" , "java.lang.String" , "The Slot from which the Component will be Unplugged.");
542     parameters[1] = new MBeanParameterInfo JavaDoc("Component" , "javax.management.ObjectName" , "The Name of the Component to Unplug.");
543     dOperations[5] = new MBeanOperationInfo JavaDoc("unplugComponent" , "Unplug Component from given Slot" , parameters , "java.lang.Boolean" , MBeanOperationInfo.ACTION);
544
545         
546     dMBeanInfo = new MBeanInfo JavaDoc(this.getClass().getName(),
547                    "JMX Supervision of Kilim Components",
548                    dAttributes,
549                    dConstructors,
550                    dOperations,
551                    new MBeanNotificationInfo JavaDoc[0]);
552     }
553     
554     private static final String JavaDoc normalize(String JavaDoc nm) {
555         return nm.replaceAll(" ","__");
556     }
557     
558         private static final String JavaDoc denormalize(String JavaDoc nm) {
559         return nm.replaceAll("__"," ");
560     }
561     
562     private Component getJMXDataContainer() {
563         return component.getSubComponent(JMX_META_DATA_NAME);
564     }
565     
566     private Iterator JavaDoc getMetaData(String JavaDoc well_known_name) {
567         
568         Component jmx_cntnr = getJMXDataContainer();
569         if (jmx_cntnr == null) { return null; }
570     
571         ComponentInterface intrfc = null;
572         try {
573          intrfc = jmx_cntnr.getInterface(well_known_name);
574         } catch (KilimException e) {
575             e.printStackTrace();
576         }
577         
578         if (intrfc == null) { return null; }
579         if (!(intrfc instanceof RtCollectionPort)) { return null; }
580         
581         Iterator JavaDoc rslt = ((RtCollectionPort) intrfc).getBoundProviders();
582         
583         return rslt;
584     }
585     
586     private Iterator JavaDoc getMonitoredInterfaces() { return getMetaData("visible"); }
587     private Iterator JavaDoc getEditableProperties() { return getMetaData("editable"); }
588        
589     private Iterator JavaDoc getMonitoredSubComponents() {
590         
591         Iterator JavaDoc cmpnnts = getMetaData("monitored sub-components");
592         if (cmpnnts == null) return null;
593         
594         LinkedList JavaDoc result = new LinkedList JavaDoc();
595         for (; cmpnnts.hasNext() ;) {
596             Object JavaDoc cmpnnt = null;
597             try {
598                 ComponentInterface intrfc = (ComponentInterface) cmpnnts.next();
599                 cmpnnt = intrfc.getValue();
600                 if (cmpnnt.equals("All")) {
601                     Iterator JavaDoc sb_cmpnnts = component.getSubComponents();
602                     return sb_cmpnnts;
603                 }
604             } catch (KilimException e) { e.printStackTrace(); }
605             result.add(cmpnnt);
606         }
607         
608         return result.iterator();
609     }
610
611     // --------- javax.management.MBeanRegistration Interface Implementation -------------------------------------
612

613     /**
614      * @see javax.management.MBeanRegistration#postDeregister()
615      */

616     public void postDeregister() {
617     }
618
619     /**
620      * @see javax.management.MBeanRegistration#postRegister(Boolean)
621      */

622     public void postRegister(Boolean JavaDoc arg0) {
623         
624         Iterator JavaDoc it = getMonitoredSubComponents();
625         if (it == null) { return; }
626         
627         for (; it.hasNext() ;) {
628             try {
629                 Component nxt = (Component) it.next();
630                 if (nxt.getLocalName().equals(JMX_META_DATA_NAME)) { continue; }
631                 ComponentMBean mbn = new ComponentMBean(nxt , root_component_name , root_domain_name);
632                 mbeanserver.registerMBean(mbn , null);
633             } catch (NotCompliantMBeanException JavaDoc e) {
634                 e.printStackTrace();
635                 continue;
636             } catch (MBeanRegistrationException JavaDoc e) {
637                 e.printStackTrace();
638                 continue;
639             } catch (InstanceAlreadyExistsException JavaDoc e) {
640                 e.printStackTrace();
641                 continue;
642             }
643         }
644     }
645
646     /**
647      * @see javax.management.MBeanRegistration#preDeregister()
648      */

649     public void preDeregister() throws Exception JavaDoc {
650     }
651
652     /**
653      * @see javax.management.MBeanRegistration#preRegister(MBeanServer, ObjectName)
654      */

655     public ObjectName JavaDoc preRegister(MBeanServer JavaDoc srvr, ObjectName JavaDoc obj_nm)
656         throws Exception JavaDoc {
657         
658         ObjectName JavaDoc trying_with_nm = null;
659         
660         if (root_component_name == null) {
661             
662             //This is a root component.
663

664             //Guarantee that the root name is unique
665

666             if (obj_nm == null) {
667                 obj_nm = new ObjectName JavaDoc("KilimComponent:name=FORKED");
668             }
669                 
670             trying_with_nm = obj_nm;
671         
672             ObjectInstance JavaDoc obj_instnc = null;
673             try {
674                 obj_instnc = srvr.getObjectInstance(trying_with_nm);
675             } catch (InstanceNotFoundException JavaDoc e) {}
676     
677             while (obj_instnc != null) {
678                 Hashtable JavaDoc nms = trying_with_nm.getKeyPropertyList();
679                 String JavaDoc new_nm = (String JavaDoc) nms.get("name");
680                 new_nm = new_nm + "_c";
681                 nms.put("name" , new_nm);
682                 trying_with_nm = new ObjectName JavaDoc(trying_with_nm.getDomain() , nms);
683                 
684                 try {
685                     obj_instnc = srvr.getObjectInstance(trying_with_nm);
686                 } catch (InstanceNotFoundException JavaDoc e) {
687                     obj_instnc = null;
688                 }
689             }
690         
691                 root_component_name = trying_with_nm.getKeyProperty("name");
692                 root_domain_name = trying_with_nm.getDomain();
693
694             
695             return trying_with_nm;
696         }
697         
698         //This is a sub-component
699

700         String JavaDoc nm = root_domain_name + ":name=" + root_component_name + "/" + component.getQualifiedName();
701         nm = nm.replaceAll(" " , "_");
702         trying_with_nm = new ObjectName JavaDoc(nm);
703
704         return trying_with_nm;
705
706     }
707
708 }
709
Popular Tags