1 22 23 package org.jboss.mx.metadata.xb; 24 25 import java.util.ArrayList ; 26 27 import javax.management.Descriptor ; 28 import javax.management.MBeanParameterInfo ; 29 import javax.management.MBeanOperationInfo ; 30 import javax.management.modelmbean.ModelMBeanOperationInfo ; 31 import javax.xml.namespace.QName ; 32 33 import org.jboss.xb.binding.GenericValueContainer; 34 import org.jboss.logging.Logger; 35 import org.jboss.mx.modelmbean.ModelMBeanConstants; 36 37 42 public class ModelMBeanOperationInfoContainer 43 implements GenericValueContainer 44 { 45 private static final Logger log = Logger.getLogger(ModelMBeanOperationInfoContainer.class); 46 private String name; 47 private String returnType = "void"; 48 private String impact; 49 private String description; 50 private ArrayList params = new ArrayList (); 51 private Descriptor descriptor; 52 53 public String getName() 54 { 55 return name; 56 } 57 58 public void setName(String name) 59 { 60 this.name = name; 61 } 62 63 public String getReturnType() 64 { 65 return returnType; 66 } 67 68 public void setReturnType(String returnType) 69 { 70 this.returnType = returnType; 71 } 72 73 public String getImpact() 74 { 75 return impact; 76 } 77 78 public void setImpact(String impact) 79 { 80 this.impact = impact; 81 } 82 83 public String getDescription() 84 { 85 return description; 86 } 87 88 public void setDescription(String description) 89 { 90 this.description = description; 91 } 92 93 public Descriptor getDescriptors() 94 { 95 return descriptor; 96 } 97 public void setDescriptors(Descriptor descriptor) 98 { 99 this.descriptor = descriptor; 100 } 101 102 public void addParameter(MBeanParameterInfo param) 103 { 104 params.add(param); 105 } 106 107 public Object instantiate() 108 { 109 MBeanParameterInfo [] sig = new MBeanParameterInfo [params.size()]; 110 params.toArray(sig); 111 if( descriptor != null ) 112 { 113 if( descriptor.getFieldValue(ModelMBeanConstants.NAME) == null ) 114 descriptor.setField(ModelMBeanConstants.NAME, name); 115 if( descriptor.getFieldValue(ModelMBeanConstants.DESCRIPTOR_TYPE) == null ) 116 descriptor.setField(ModelMBeanConstants.DESCRIPTOR_TYPE, ModelMBeanConstants.OPERATION_DESCRIPTOR); 117 if( descriptor.getFieldValue(ModelMBeanConstants.ROLE) == null ) 118 descriptor.setField(ModelMBeanConstants.ROLE, ModelMBeanConstants.ROLE_OPERATION); 119 } 120 int operImpact = MBeanOperationInfo.ACTION_INFO; 121 122 if (impact != null) 123 { 124 if (impact.equals(ModelMBeanConstants.INFO)) 125 operImpact = MBeanOperationInfo.INFO; 126 else if (impact.equals(ModelMBeanConstants.ACTION)) 127 operImpact = MBeanOperationInfo.ACTION; 128 else if (impact.equals(ModelMBeanConstants.ACTION_INFO)) 129 operImpact = MBeanOperationInfo.ACTION_INFO; 130 } 131 132 ModelMBeanOperationInfo info = new ModelMBeanOperationInfo (name, 133 description, sig, returnType, operImpact, descriptor); 134 return info; 135 } 136 public void addChild(QName name, Object value) 137 { 138 ModelMBeanOperationInfoContainer.log.debug("addChild, " + name + "," + value); 139 if("name".equals(name.getLocalPart())) 140 { 141 this.name = (String ) value; 142 } 143 if("description".equals(name.getLocalPart())) 144 { 145 this.description = (String ) value; 146 } 147 } 148 public Class getTargetClass() 149 { 150 return ModelMBeanOperationInfo .class; 151 } 152 153 } 154 | Popular Tags |