1 22 23 package org.jboss.mx.metadata.xb; 24 25 import java.util.ArrayList ; 26 import javax.management.Descriptor ; 27 import javax.management.modelmbean.DescriptorSupport ; 28 import javax.management.modelmbean.ModelMBeanNotificationInfo ; 29 import javax.xml.namespace.QName ; 30 31 import org.jboss.xb.binding.GenericValueContainer; 32 import org.jboss.logging.Logger; 33 import org.jboss.mx.modelmbean.ModelMBeanConstants; 34 35 40 public class ModelMBeanNotificationInfoContainer 41 implements GenericValueContainer 42 { 43 private static final Logger log = Logger.getLogger(ModelMBeanNotificationInfoContainer.class); 44 private String name; 45 private ArrayList types = new ArrayList (); 46 private String description; 47 private Descriptor descriptor; 48 49 public Descriptor getDescriptors() 50 { 51 return descriptor; 52 } 53 public void setDescriptors(Descriptor descriptor) 54 { 55 this.descriptor = descriptor; 56 } 57 58 public void addType(String type) 59 { 60 types.add(type); 61 } 62 public Object instantiate() 63 { 64 if (descriptor != null) 65 { 66 if (descriptor.getFieldValue(ModelMBeanConstants.NAME) == null) 67 { 68 descriptor.setField(ModelMBeanConstants.NAME, name); 69 } 70 if (descriptor.getFieldValue(ModelMBeanConstants.DESCRIPTOR_TYPE) == null) 71 { 72 descriptor.setField(ModelMBeanConstants.DESCRIPTOR_TYPE, ModelMBeanConstants.NOTIFICATION_DESCRIPTOR); 73 } 74 } 75 76 String [] ntypes = new String [types.size()]; 77 types.toArray(ntypes); 78 ModelMBeanNotificationInfo info = new ModelMBeanNotificationInfo ( 79 ntypes, name, description, descriptor); 80 return info; 81 } 82 83 public void addChild(QName name, Object value) 84 { 85 log.debug("addChild, " + name + "," + value); 86 if("name".equals(name.getLocalPart())) 87 { 88 this.name = (String ) value; 89 } 90 if("description".equals(name.getLocalPart())) 91 { 92 this.description = (String ) value; 93 } 94 } 95 public Class getTargetClass() 96 { 97 return ModelMBeanNotificationInfo .class; 98 } 99 100 } 101 | Popular Tags |