KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mx > metadata > JBossXMBean10


1 /*
2  * JBoss, Home of Professional Open Source
3  * Copyright 2005, JBoss Inc., and individual contributors as indicated
4  * by the @authors tag. See the copyright.txt in the distribution for a
5  * full listing of individual contributors.
6  *
7  * This is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2.1 of
10  * the License, or (at your option) any later version.
11  *
12  * This software is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this software; if not, write to the Free
19  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21  */

22 package org.jboss.mx.metadata;
23
24 import java.beans.IntrospectionException JavaDoc;
25 import java.beans.PropertyEditor JavaDoc;
26 import java.beans.PropertyEditorManager JavaDoc;
27 import java.util.ArrayList JavaDoc;
28 import java.util.Iterator JavaDoc;
29 import java.util.List JavaDoc;
30 import java.util.Map JavaDoc;
31
32 import javax.management.Descriptor JavaDoc;
33 import javax.management.MBeanInfo JavaDoc;
34 import javax.management.MBeanOperationInfo JavaDoc;
35 import javax.management.MBeanParameterInfo JavaDoc;
36 import javax.management.NotCompliantMBeanException JavaDoc;
37 import javax.management.modelmbean.DescriptorSupport JavaDoc;
38 import javax.management.modelmbean.ModelMBeanAttributeInfo JavaDoc;
39 import javax.management.modelmbean.ModelMBeanConstructorInfo JavaDoc;
40 import javax.management.modelmbean.ModelMBeanInfo JavaDoc;
41 import javax.management.modelmbean.ModelMBeanInfoSupport JavaDoc;
42 import javax.management.modelmbean.ModelMBeanNotificationInfo JavaDoc;
43 import javax.management.modelmbean.ModelMBeanOperationInfo JavaDoc;
44
45 import org.dom4j.Attribute;
46 import org.dom4j.Element;
47 import org.jboss.logging.Logger;
48 import org.jboss.mx.modelmbean.XMBeanConstants;
49 import org.jboss.mx.util.JBossNotCompliantMBeanException;
50 import org.jboss.util.Classes;
51 import org.jboss.util.StringPropertyReplacer;
52 import org.jboss.util.propertyeditor.PropertyEditors;
53 import org.w3c.dom.Node JavaDoc;
54 import org.w3c.dom.NodeList JavaDoc;
55
56 /**
57  * The JBoss 1.0 model mbean descriptor parser class.
58  *
59  * @author Matt Munz
60  * @author Scott.Stark@jboss.org
61  * @author Dimitris.Andreadis@jboss.org
62  * @version $Revision: 40362 $
63  */

64 public class JBossXMBean10 extends AbstractBuilder
65    implements XMBeanConstants
66 {
67    private static Logger log = Logger.getLogger(JBossXMBean10.class);
68
69    // Attributes ----------------------------------------------------
70

71    private Element element;
72
73    /**
74     * The class name of the Model MBean implementation class.
75     */

76    private String JavaDoc mmbClassName = null;
77    
78    /**
79     * The class name of the resource object represented by this Model MBean.
80     */

81    private String JavaDoc resourceClassName = null;
82
83   
84    // Constructors --------------------------------------------------
85

86    public JBossXMBean10(String JavaDoc mmbClassName, String JavaDoc resourceClassName, Element element, Map JavaDoc properties)
87    {
88       super();
89       this.mmbClassName = mmbClassName;
90       this.resourceClassName = resourceClassName;
91       this.element = element;
92       setProperties(properties);
93    }
94
95    // MetaDataBuilder implementation --------------------------------
96

97    public MBeanInfo JavaDoc build() throws NotCompliantMBeanException JavaDoc
98    {
99       try
100       {
101          if (element == null)
102          {
103             throw new JBossNotCompliantMBeanException("No xml configuration supplied!");
104          }
105          String JavaDoc description = element.elementTextTrim("description");
106
107          if (resourceClassName == null)
108          {
109             resourceClassName = element.elementTextTrim("class");
110          }
111          
112          List JavaDoc constructors = element.elements("constructor");
113          List JavaDoc operations = element.elements("operation");
114          List JavaDoc attributes = element.elements("attribute");
115          List JavaDoc notifications = element.elements("notification");
116
117          Descriptor JavaDoc descr = getDescriptor(element, mmbClassName, MBEAN_DESCRIPTOR);
118
119          ModelMBeanInfo JavaDoc info = buildMBeanMetaData(
120             description, constructors, operations,
121             attributes, notifications, descr
122          );
123
124          return (MBeanInfo JavaDoc) info;
125       }
126       catch (Throwable JavaDoc t)
127       {
128          throw new JBossNotCompliantMBeanException("Error parsing the XML file: ", t);
129       }
130    }
131
132    
133    // Protected -----------------------------------------------------
134

135    protected Descriptor JavaDoc getDescriptor(final Element parent, final String JavaDoc infoName, final String JavaDoc type)
136            throws NotCompliantMBeanException JavaDoc
137    {
138       Descriptor JavaDoc descr = new DescriptorSupport JavaDoc();
139       descr.setField(NAME, infoName);
140       descr.setField(DISPLAY_NAME, infoName);
141       descr.setField(DESCRIPTOR_TYPE, type);
142
143       Element descriptors = parent.element("descriptors");
144       if (descriptors == null)
145       {
146          return descr;
147       }
148
149       for (Iterator JavaDoc i = descriptors.elementIterator(); i.hasNext();)
150       {
151          Element descriptor = (Element)i.next();
152          String JavaDoc name = descriptor.getName();
153          if (name.equals("persistence"))
154          {
155             String JavaDoc persistPolicy = descriptor.attributeValue(PERSIST_POLICY);
156             String JavaDoc persistPeriod = descriptor.attributeValue(PERSIST_PERIOD);
157             String JavaDoc persistLocation = descriptor.attributeValue(PERSIST_LOCATION);
158             String JavaDoc persistName = descriptor.attributeValue(PERSIST_NAME);
159             if (persistPolicy != null)
160             {
161                validate(persistPolicy, PERSIST_POLICIES);
162                descr.setField(PERSIST_POLICY, persistPolicy);
163             }
164             if (persistPeriod != null)
165             {
166                descr.setField(PERSIST_PERIOD, persistPeriod);
167             }
168             if (persistLocation != null)
169             {
170                descr.setField(PERSIST_LOCATION, persistLocation);
171             }
172             if (persistName != null)
173             {
174                descr.setField(PERSIST_NAME, persistName);
175             }
176          }
177          else if (name.equals(CURRENCY_TIME_LIMIT))
178          {
179             descr.setField(CURRENCY_TIME_LIMIT, descriptor.attributeValue("value"));
180          }
181          else if (name.equals(DEFAULT))
182          {
183             String JavaDoc value = descriptor.attributeValue("value");
184             descr.setField(DEFAULT, value);
185          }
186          else if (name.equals("display-name"))//DISPLAY_NAME is displayname
187
{
188             String JavaDoc value = descriptor.attributeValue("value");
189             descr.setField(DISPLAY_NAME, value);
190          }
191          else if (name.equals(CACHED_VALUE))
192          {
193             String JavaDoc value = descriptor.attributeValue("value");
194             descr.setField(CACHED_VALUE, value);
195          }
196          else if (name.equals(PERSISTENCE_MANAGER))
197          {
198             descr.setField(PERSISTENCE_MANAGER, descriptor.attributeValue("value"));
199          }
200          else if (name.equals(DESCRIPTOR))
201          {
202             descr.setField(descriptor.attributeValue("name"), descriptor.attributeValue("value"));
203          }
204          else if (name.equals("injection"))
205          {
206             descr.setField(descriptor.attributeValue("id"), descriptor.attributeValue("setMethod"));
207          }
208          else if(name.equals(INTERCEPTORS))
209          {
210             Descriptor JavaDoc[] interceptorDescriptors = buildInterceptors(descriptor);
211             descr.setField(INTERCEPTORS, interceptorDescriptors);
212          }
213       } // end of for ()
214

215       return descr;
216    }
217
218    private void validate(String JavaDoc value, String JavaDoc[] valid) throws NotCompliantMBeanException JavaDoc
219    {
220       for (int i = 0; i< valid.length; i++)
221       {
222          if (valid[i].equalsIgnoreCase(value))
223          {
224             return;
225          } // end of if ()
226
} // end of for ()
227
throw new JBossNotCompliantMBeanException("Unknown descriptor value: " + value);
228    }
229
230
231    // builder methods
232

233    protected ModelMBeanInfo JavaDoc buildMBeanMetaData(String JavaDoc description,
234                                                List JavaDoc constructors, List JavaDoc operations, List JavaDoc attributes,
235                                                List JavaDoc notifications, Descriptor JavaDoc descr)
236       throws NotCompliantMBeanException JavaDoc
237    {
238
239       ModelMBeanOperationInfo JavaDoc[] operInfo =
240          buildOperationInfo(operations);
241       ModelMBeanAttributeInfo JavaDoc[] attrInfo =
242          buildAttributeInfo(attributes);
243       ModelMBeanConstructorInfo JavaDoc[] constrInfo =
244          buildConstructorInfo(constructors);
245       ModelMBeanNotificationInfo JavaDoc[] notifInfo =
246          buildNotificationInfo(notifications);
247
248       ModelMBeanInfo JavaDoc info = new ModelMBeanInfoSupport JavaDoc(
249          mmbClassName, description, attrInfo, constrInfo,
250          operInfo, notifInfo, descr
251       );
252
253       return info;
254    }
255
256
257    protected ModelMBeanConstructorInfo JavaDoc[] buildConstructorInfo(List JavaDoc constructors)
258       throws NotCompliantMBeanException JavaDoc
259    {
260
261       List JavaDoc infos = new ArrayList JavaDoc();
262
263       for (Iterator JavaDoc it = constructors.iterator(); it.hasNext();)
264       {
265          Element constr = (Element) it.next();
266          String JavaDoc name = constr.elementTextTrim("name");
267          String JavaDoc description = constr.elementTextTrim("description");
268          List JavaDoc params = constr.elements("parameter");
269
270          MBeanParameterInfo JavaDoc[] paramInfo =
271             buildParameterInfo(params);
272
273          Descriptor JavaDoc descr = getDescriptor(constr, name, OPERATION_DESCRIPTOR);
274          descr.setField(ROLE, ROLE_CONSTRUCTOR);
275
276          ModelMBeanConstructorInfo JavaDoc info =
277             new ModelMBeanConstructorInfo JavaDoc(name, description, paramInfo, descr);
278
279          infos.add(info);
280       }
281
282       return (ModelMBeanConstructorInfo JavaDoc[]) infos.toArray(
283          new ModelMBeanConstructorInfo JavaDoc[0]);
284    }
285
286    protected ModelMBeanOperationInfo JavaDoc[] buildOperationInfo(List JavaDoc operations)
287       throws NotCompliantMBeanException JavaDoc
288    {
289       List JavaDoc infos = new ArrayList JavaDoc();
290
291       for (Iterator JavaDoc it = operations.iterator(); it.hasNext(); )
292       {
293          Element oper = (Element) it.next();
294          String JavaDoc name = oper.elementTextTrim("name");
295          String JavaDoc description = oper.elementTextTrim("description");
296          String JavaDoc type = oper.elementTextTrim("return-type");
297          String JavaDoc impact = oper.attributeValue("impact");
298          List JavaDoc params = oper.elements("parameter");
299
300          MBeanParameterInfo JavaDoc[] paramInfo =
301             buildParameterInfo(params);
302
303          Descriptor JavaDoc descr = getDescriptor(oper, name, OPERATION_DESCRIPTOR);
304          descr.setField(ROLE, ROLE_OPERATION);
305
306          // defaults to ACTION_INFO
307
int operImpact = MBeanOperationInfo.ACTION_INFO;
308
309          if (impact != null)
310          {
311             if (impact.equals(INFO))
312                operImpact = MBeanOperationInfo.INFO;
313             else if (impact.equals(ACTION))
314                operImpact = MBeanOperationInfo.ACTION;
315             else if (impact.equals(ACTION_INFO))
316                operImpact = MBeanOperationInfo.ACTION_INFO;
317          }
318
319          // default return-type is void
320
if (type == null)
321             type = "void";
322
323          ModelMBeanOperationInfo JavaDoc info = new ModelMBeanOperationInfo JavaDoc(
324             name, description, paramInfo, type, operImpact, descr);
325
326          infos.add(info);
327       }
328
329       return (ModelMBeanOperationInfo JavaDoc[]) infos.toArray(
330          new ModelMBeanOperationInfo JavaDoc[0]);
331    }
332
333
334    protected ModelMBeanNotificationInfo JavaDoc[] buildNotificationInfo(List JavaDoc notifications)
335       throws NotCompliantMBeanException JavaDoc
336    {
337
338       List JavaDoc infos = new ArrayList JavaDoc();
339
340       for (Iterator JavaDoc it = notifications.iterator(); it.hasNext();)
341       {
342          Element notif = (Element) it.next();
343          String JavaDoc name = notif.elementTextTrim("name");
344          String JavaDoc description = notif.elementTextTrim("description");
345          List JavaDoc notifTypes = notif.elements("notification-type");
346          Descriptor JavaDoc descr = getDescriptor(notif, name, NOTIFICATION_DESCRIPTOR);
347
348          List JavaDoc types = new ArrayList JavaDoc();
349
350          for (Iterator JavaDoc iterator = notifTypes.iterator(); iterator.hasNext();)
351          {
352             Element type = (Element) iterator.next();
353             types.add(type.getTextTrim());
354          }
355
356          ModelMBeanNotificationInfo JavaDoc info = new ModelMBeanNotificationInfo JavaDoc(
357             (String JavaDoc[]) types.toArray(new String JavaDoc[types.size()]), name, description, descr);
358
359          infos.add(info);
360       }
361
362       return (ModelMBeanNotificationInfo JavaDoc[]) infos.toArray(
363          new ModelMBeanNotificationInfo JavaDoc[infos.size()]
364       );
365    }
366
367    protected ModelMBeanAttributeInfo JavaDoc[] buildAttributeInfo(List JavaDoc attributes)
368       throws NotCompliantMBeanException JavaDoc
369    {
370
371       List JavaDoc infos = new ArrayList JavaDoc();
372
373       for (Iterator JavaDoc it = attributes.iterator(); it.hasNext();)
374       {
375          Element attr = (Element) it.next();
376          String JavaDoc name = attr.elementTextTrim("name");
377          String JavaDoc description = attr.elementTextTrim("description");
378          String JavaDoc type = attr.elementTextTrim("type");
379          String JavaDoc access = attr.attributeValue("access");
380          String JavaDoc getMethod = attr.attributeValue("getMethod");
381          String JavaDoc setMethod = attr.attributeValue("setMethod");
382          Descriptor JavaDoc descr = getDescriptor(attr, name, ATTRIBUTE_DESCRIPTOR);
383          //Convert types here from string to specified type
384
String JavaDoc unconvertedValue = (String JavaDoc)descr.getFieldValue(CACHED_VALUE);
385          if (unconvertedValue != null && !"java.lang.String".equals(type))
386          {
387             descr.setField(CACHED_VALUE, convertValue(unconvertedValue, type));
388          }
389          else
390          {
391             // if <value value="xxx"/> is absent
392
// try new syntax for VALUE initialization
393
// e.g <value><nested-element/></value>
394
Object JavaDoc value = getAttributeValue(attr, type, CACHED_VALUE);
395             if (value != null)
396                descr.setField(CACHED_VALUE, value);
397          }
398          String JavaDoc unconvertedDefault = (String JavaDoc)descr.getFieldValue(DEFAULT);
399          if (unconvertedDefault != null && !"java.lang.String".equals(type))
400          {
401             descr.setField(DEFAULT, convertValue(unconvertedDefault, type));
402          }
403          else
404          {
405             // if <defaul value="xxx"/> is absent
406
// try new syntax for DEFAULT initialization
407
// e.g <default><nested-element/></default>
408
Object JavaDoc value = getAttributeValue(attr, type, DEFAULT);
409             if (value != null)
410                descr.setField(DEFAULT, value);
411          }
412          if (getMethod != null)
413          {
414             descr.setField(GET_METHOD, getMethod);
415          } // end of if ()
416

417          if (setMethod != null)
418          {
419             descr.setField(SET_METHOD, setMethod);
420          } // end of if ()
421

422
423          // defaults read-write
424
boolean isReadable = true;
425          boolean isWritable = true;
426
427          if (access.equalsIgnoreCase("read-only"))
428             isWritable = false;
429
430          else if (access.equalsIgnoreCase("write-only"))
431             isReadable = false;
432
433
434          ModelMBeanAttributeInfo JavaDoc info = new ModelMBeanAttributeInfo JavaDoc(
435             name, type, description, isReadable, isWritable, false, descr
436          );
437
438
439          infos.add(info);
440       }
441
442       return (ModelMBeanAttributeInfo JavaDoc[]) infos.toArray(
443          new ModelMBeanAttributeInfo JavaDoc[0]
444       );
445    }
446
447    /**
448     * Get the value for the attribute descriptor "value" or "default"
449     * the same way we would do for mbean attribute overrides
450     */

451    protected Object JavaDoc getAttributeValue(Element attribute, String JavaDoc typeName, String JavaDoc which)
452       throws NotCompliantMBeanException JavaDoc
453    {
454       Object JavaDoc value = null;
455       
456       Element descriptors = attribute.element("descriptors");
457       if (descriptors != null)
458       {
459          for (Iterator JavaDoc i = descriptors.elementIterator(); i.hasNext();)
460          {
461             // looking for 'which', i.e. "value" or "default"
462
Element descriptor = (Element)i.next();
463             String JavaDoc name = descriptor.getName();
464             if (name.equals(which) && descriptor.hasContent())
465             {
466                // at this point "value" attribute does not exist
467
// plus the descriptor has content so we know the
468
// new syntax is used.
469
//
470
// Convert to org.w3c.dom.Element so that the code
471
// from ServiceConfigurator can be applied, plus
472
// if attribute type is org.w3c.dom.Element we need
473
// to make the conversion anyway.
474

475                // descriptor(org.dom4j.Element) -> element (org.w3c.dom.Element)
476
try
477                {
478                   org.w3c.dom.Element JavaDoc element = toW3CElement(descriptor);
479                   
480                   boolean replace = true;
481                   boolean trim = true;
482                   
483                   String JavaDoc replaceAttr = element.getAttribute("replace");
484                   if( replaceAttr.length() > 0 )
485                      replace = Boolean.valueOf(replaceAttr).booleanValue();
486                   String JavaDoc trimAttr = element.getAttribute("trim");
487                   if( trimAttr.length() > 0 )
488                      trim = Boolean.valueOf(trimAttr).booleanValue();
489                   
490                   // Get the classloader for loading attribute classes.
491
ClassLoader JavaDoc cl = Thread.currentThread().getContextClassLoader();
492                   
493                   // see if it is a primitive type first
494
Class JavaDoc typeClass = Classes.getPrimitiveTypeForName(typeName);
495                   if (typeClass == null)
496                   {
497                      // nope try look up
498
try
499                      {
500                         typeClass = cl.loadClass(typeName);
501                      }
502                      catch (ClassNotFoundException JavaDoc e)
503                      {
504                         throw new JBossNotCompliantMBeanException
505                            ("Class not found '" + typeName + "'", e);
506                      }
507                   }
508
509                   /* Attributes of type Element are passed as is after optionally
510                   performing system property replacement
511                   */

512                   if (typeClass.equals(org.w3c.dom.Element JavaDoc.class))
513                   {
514                      // Use the first child Element of this element as the value
515
NodeList JavaDoc nl = element.getChildNodes();
516                      for (int j=0; j < nl.getLength(); j++)
517                      {
518                         Node JavaDoc n = nl.item(j);
519                         if (n.getNodeType() == Node.ELEMENT_NODE)
520                         {
521                            value = n;
522                            break;
523                         }
524                      }
525                      // Replace any ${x} references in the element text
526
if( replace )
527                      {
528                         PropertyEditor JavaDoc editor = PropertyEditorManager.findEditor(typeClass);
529                         if( editor == null )
530                         {
531                            log.warn("Cannot perform property replace on Element");
532                         }
533                         else
534                         {
535                            editor.setValue(value);
536                            String JavaDoc text = editor.getAsText();
537                            text = StringPropertyReplacer.replaceProperties(text);
538                            editor.setAsText(text);
539                            value = editor.getValue();
540                         }
541                      }
542                   }
543
544                   if (value == null)
545                   {
546                      PropertyEditor JavaDoc editor = PropertyEditorManager.findEditor(typeClass);
547                      if (editor == null)
548                      {
549                         throw new JBossNotCompliantMBeanException
550                            ("No property editor for type '" + typeName + "'");
551                      }
552                      // Get the attribute value
553
String JavaDoc attributeText = getElementContent(element, trim, replace);
554                      editor.setAsText(attributeText);
555                      value = editor.getValue();
556                   }
557                }
558                catch (org.dom4j.DocumentException e)
559                {
560                   throw new JBossNotCompliantMBeanException(
561                         "cannot convert '" + which + "' descriptor to org.w3c.dom.Element", e);
562                }
563
564                // stop processing
565
break;
566             }
567          }
568       }
569       return value;
570    }
571
572    /**
573     * Convert org.dom4j.Element->org.w3c.dom.Element
574     */

575    private org.w3c.dom.Element JavaDoc toW3CElement(org.dom4j.Element d4element)
576       throws org.dom4j.DocumentException
577    {
578       // prepare
579
org.dom4j.Document d4doc = org.dom4j.DocumentFactory.getInstance().createDocument();
580       org.dom4j.io.DOMWriter d4Writer = new org.dom4j.io.DOMWriter();
581       // copy
582
d4doc.setRootElement(d4element.createCopy());
583       // convert
584
org.w3c.dom.Document JavaDoc doc = d4Writer.write(d4doc);
585       // return root Element - should I copy again?
586
return doc.getDocumentElement();
587    }
588    
589    /**
590     * Copied from ServiceConfigurator
591     */

592    private String JavaDoc getElementContent(org.w3c.dom.Element JavaDoc element, boolean trim, boolean replace)
593    {
594       NodeList JavaDoc nl = element.getChildNodes();
595       String JavaDoc attributeText = "";
596       for (int i = 0; i < nl.getLength(); i++)
597       {
598          Node JavaDoc n = nl.item(i);
599          if( n instanceof org.w3c.dom.Text JavaDoc )
600          {
601             attributeText += ((org.w3c.dom.Text JavaDoc)n).getData();
602          }
603       } // end of for ()
604
if( trim )
605          attributeText = attributeText.trim();
606       if (replace)
607          attributeText = StringPropertyReplacer.replaceProperties(attributeText);
608       return attributeText;
609    }
610    
611    /**
612     * Describe <code>convertType</code> method here.
613     * Copied from ServiceConfigurator, without Element support.
614     *
615     * @param unconverted a <code>String</code> value
616     * @param typeName a <code>String</code> value
617     * @return an <code>Object</code> value
618     * @exception NotCompliantMBeanException if an error occurs
619     */

620    protected Object JavaDoc convertValue(String JavaDoc unconverted, String JavaDoc typeName)
621       throws NotCompliantMBeanException JavaDoc
622    {
623       Object JavaDoc value = null;
624       try
625       {
626          value = PropertyEditors.convertValue(unconverted, typeName);
627       }
628       catch (ClassNotFoundException JavaDoc e)
629       {
630          log.debug("Failed to load type class", e);
631          throw new NotCompliantMBeanException JavaDoc
632                ("Class not found for type: " + typeName);
633       }
634       catch(IntrospectionException JavaDoc e)
635       {
636          throw new NotCompliantMBeanException JavaDoc
637                ("No property editor for type=" + typeName);
638       }
639       return value;
640    }
641
642    protected MBeanParameterInfo JavaDoc[] buildParameterInfo(List JavaDoc parameters)
643    {
644       Iterator JavaDoc it = parameters.iterator();
645       List JavaDoc infos = new ArrayList JavaDoc();
646
647       while (it.hasNext())
648       {
649          Element param = (Element) it.next();
650          String JavaDoc name = param.elementTextTrim("name");
651          String JavaDoc type = param.elementTextTrim("type");
652          String JavaDoc descr = param.elementTextTrim("description");
653
654          MBeanParameterInfo JavaDoc info = new MBeanParameterInfo JavaDoc(name, type, descr);
655
656          infos.add(info);
657       }
658       
659       return (MBeanParameterInfo JavaDoc[]) infos.toArray(new MBeanParameterInfo JavaDoc[0]);
660    }
661
662    protected Descriptor JavaDoc[] buildInterceptors(Element descriptor)
663    {
664       List JavaDoc interceptors = descriptor.elements("interceptor");
665       ArrayList JavaDoc tmp = new ArrayList JavaDoc();
666       for(int i = 0; i < interceptors.size(); i ++)
667       {
668          Element interceptor = (Element) interceptors.get(i);
669          String JavaDoc code = interceptor.attributeValue("code");
670          DescriptorSupport JavaDoc interceptorDescr = new DescriptorSupport JavaDoc();
671          interceptorDescr.setField("code", code);
672          List JavaDoc attributes = interceptor.attributes();
673          for(int a = 0; a < attributes.size(); a ++)
674          {
675             Attribute attr = (Attribute) attributes.get(a);
676             String JavaDoc name = attr.getName();
677             String JavaDoc value = attr.getValue();
678             value = StringPropertyReplacer.replaceProperties(value);
679             interceptorDescr.setField(name, value);
680          }
681          tmp.add(interceptorDescr);
682       }
683       Descriptor JavaDoc[] descriptors = new Descriptor JavaDoc[tmp.size()];
684       tmp.toArray(descriptors);
685       return descriptors;
686    }
687
688 }
689
Popular Tags