1 23 24 package com.sun.enterprise.management.model; 25 26 import javax.management.*; 27 import java.util.Set ; 28 import java.util.HashSet ; 29 import javax.management.j2ee.Management ; 30 import javax.management.j2ee.ManagementHome ; 31 import javax.naming.*; 33 import java.security.AccessController ; 34 import java.security.PrivilegedAction ; 35 36 import com.sun.enterprise.management.agent.MBSUtility; 37 38 43 public abstract class J2EEManagedObjectMdl { 44 private String name; 46 private boolean stateManageable; 47 private boolean statisticsProvider; 48 private boolean eventProvider; 49 50 J2EEManagedObjectMdl(String name,boolean state, boolean statistics, boolean events) { 51 this.name = name; 52 stateManageable = state; 53 statisticsProvider = statistics; 54 eventProvider = events; 55 } 56 57 MBeanServer getMBeanServer() { 60 java.util.ArrayList servers = 61 (java.util.ArrayList ) AccessController.doPrivileged(new PrivilegedAction () { 62 public java.lang.Object run() { 63 return MBeanServerFactory.findMBeanServer(null); 64 } 65 }); 66 if (servers.isEmpty()) { 67 return (MBeanServer) AccessController.doPrivileged(new PrivilegedAction () { 68 public java.lang.Object run() { 69 return MBeanServerFactory.createMBeanServer(); 70 } 71 }); 72 } else { 73 return (MBeanServer)servers.get(0); 74 } 75 } 76 77 MBSUtility getMBSUtility(){ 78 return MBSUtility.getMBSUtility(); 81 } 82 98 99 public Set findNames(String keys) { 100 Set s = new HashSet (); 101 ObjectName namepattern = null; 102 try { 103 String pattern = J2EEDomainMdl.DOMAINNAME + ":" + keys + ",*"; 104 namepattern = new ObjectName(pattern); 105 } catch (Exception e) { 106 e.printStackTrace(); 107 } 108 if (namepattern != null) { 109 MBSUtility mejb = getMBSUtility(); 110 if (mejb != null) { 111 try { 112 s = getMBSUtility().queryNames(namepattern, null); 113 } catch (Exception e) { 114 e.printStackTrace(); 115 } 116 } 117 } 118 return s; 119 } 120 121 122 126 public abstract String getj2eeType(); 127 128 132 public abstract String getobjectName(); 133 134 138 public boolean isstateManageable() { 139 return stateManageable; 140 } 141 142 146 public boolean isstatisticsProvider() { 147 return statisticsProvider; 148 } 149 150 155 public boolean iseventProvider() { 156 return eventProvider; 157 } 158 159 160 public String getJ2EEServer() { 161 return "j2ee100"; 162 163 } 167 168 public String getname(){ 169 return this.name; 170 } 171 } 172 | Popular Tags |