1 22 23 package org.jboss.mx.metadata.xb; 24 25 import java.util.ArrayList ; 26 import javax.management.modelmbean.ModelMBeanOperationInfo ; 27 import javax.management.modelmbean.ModelMBeanAttributeInfo ; 28 import javax.management.modelmbean.ModelMBeanConstructorInfo ; 29 import javax.management.modelmbean.ModelMBeanNotificationInfo ; 30 import javax.management.modelmbean.ModelMBeanInfo ; 31 import javax.management.modelmbean.ModelMBeanInfoSupport ; 32 import javax.management.Descriptor ; 33 34 import org.jboss.logging.Logger; 35 import org.jboss.mx.modelmbean.ModelMBeanConstants; 36 37 42 public class ModelMBeanInfoSupportWrapper 43 { 44 private static final Logger log = Logger.getLogger(ModelMBeanInfoSupportWrapper.class); 45 private String mmbClassName = "org.jboss.mx.modelmbean.XMBean"; 46 47 private String description; 48 private ArrayList operInfo = new ArrayList (); 49 private ArrayList attrInfo = new ArrayList (); 50 private ArrayList constrInfo = new ArrayList (); 51 private ArrayList notifInfo = new ArrayList (); 52 private Descriptor descriptor; 53 54 public String getClassName() 55 { 56 return mmbClassName; 57 } 58 59 public void setClassName(String mmbClassName) 60 { 61 this.mmbClassName = mmbClassName; 62 } 63 64 public String getDescription() 65 { 66 return description; 67 } 68 public void setDescription(String description) 69 { 70 this.description = description; 71 } 72 public Descriptor getDescriptors() 73 { 74 return descriptor; 75 } 76 public void setDescriptors(Descriptor descriptor) 77 { 78 this.descriptor = descriptor; 79 } 80 81 public void addConstructor(ModelMBeanConstructorInfo info) 82 { 83 this.constrInfo.add(info); 84 } 85 public void addAttribute(ModelMBeanAttributeInfo info) 86 { 87 this.attrInfo.add(info); 88 } 89 public void addOperation(ModelMBeanOperationInfo info) 90 { 91 this.operInfo.add(info); 92 } 93 public void addNotification(ModelMBeanNotificationInfo info) 94 { 95 this.notifInfo.add(info); 96 } 97 98 public Object instantiate() 99 { 100 ModelMBeanOperationInfo [] ops = new ModelMBeanOperationInfo [operInfo.size()]; 101 operInfo.toArray(ops); 102 ModelMBeanAttributeInfo [] attrs = new ModelMBeanAttributeInfo [attrInfo.size()]; 103 attrInfo.toArray(attrs); 104 ModelMBeanConstructorInfo [] ctors = new ModelMBeanConstructorInfo [constrInfo.size()]; 105 constrInfo.toArray(ctors); 106 ModelMBeanNotificationInfo [] msgs = new ModelMBeanNotificationInfo [notifInfo.size()]; 107 notifInfo.toArray(msgs); 108 if( descriptor != null ) 110 { 111 if( descriptor.getFieldValue(ModelMBeanConstants.NAME) == null ) 112 descriptor.setField(ModelMBeanConstants.NAME, getClassName()); 113 if( descriptor.getFieldValue(ModelMBeanConstants.DESCRIPTOR_TYPE) == null ) 114 descriptor.setField(ModelMBeanConstants.DESCRIPTOR_TYPE, ModelMBeanConstants.MBEAN_DESCRIPTOR); 115 } 116 ModelMBeanInfo info = new ModelMBeanInfoSupport ( 117 mmbClassName, description, attrs, ctors, 118 ops, msgs, descriptor); 119 return info; 120 } 121 122 public ModelMBeanInfo getMBeanInfo() 123 { 124 return (ModelMBeanInfo ) instantiate(); 125 } 126 } 127 | Popular Tags |