1 23 package com.sun.enterprise.admin.jmx; 24 25 import javax.management.ObjectName ; 27 28 import com.sun.enterprise.admin.meta.MBeanDescriptor; 29 import com.sun.enterprise.admin.meta.MBeanRegistry; 30 31 45 46 50 import java.util.logging.Level ; 51 import java.util.logging.Logger ; 52 import java.util.Set ; 53 import java.util.List ; 54 55 import javax.management.modelmbean.ModelMBean ; 56 import javax.management.MBeanServer ; 57 import javax.management.MBeanServerFactory ; 58 59 import javax.management.modelmbean.ModelMBeanInfo ; 60 import javax.management.Descriptor ; 61 62 66 import com.sun.enterprise.admin.meta.MBeanRegistry; 67 68 import java.io.InputStream ; 69 import java.net.URL ; 70 71 74 75 80 81 public class MBeanManufacturer 82 { 83 private static MBeanRegistry registry = null; 84 191 192 static void findPersistent(ObjectName name) { 193 System.out.println("Find persistant for "+name); 194 org.apache.commons.modeler.Registry rr; 195 if(registry == null) createRegistry(); 197 try { 198 199 MBeanServer server = (MBeanServer )MBeanServerFactory.findMBeanServer(null).get(0); 200 201 Set result = server.queryMBeans(name, null); 203 if(result != null && result.size() !=0) return; 204 205 ModelMBean mm = MBeanDescriptor.instantiateMBean(name, null); 207 208 System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> info from Model mbean <<<<<<<<<<<<<<<<<<<<<<<<<"); 210 ModelMBeanInfo inf = (ModelMBeanInfo )mm.getMBeanInfo(); 211 System.out.println(">>info="+ inf); 212 Descriptor md = inf.getMBeanDescriptor(); 213 System.out.println(">>mbdescr="+ md); 214 System.out.println(">>location="+ md.getFieldValue("persistLocation")); 215 System.out.println(">>>>>>>description="+ inf.getDescription()); 216 217 221 223 225 } catch(Exception e) { 226 e.printStackTrace(); 227 } 228 } 229 230 233 private static void createRegistry() { 234 235 System.out.println("Create configuration registry ..."); 236 try { 237 URL url = MBeanManufacturer.class.getResource 238 ("/mbeans-descriptors.xml"); 239 InputStream stream = url.openStream(); 240 registry = new MBeanRegistry(); 241 registry.loadMBeanRegistry(stream); 242 stream.close(); 243 } catch (Throwable t) { 244 t.printStackTrace(System.out); 245 System.exit(1); 246 } 247 248 } 249 250 } 251 | Popular Tags |