1 22 package org.jboss.management.j2ee; 23 24 import javax.management.MalformedObjectNameException ; 25 import javax.management.ObjectName ; 26 import java.util.ArrayList ; 27 import java.util.List ; 28 29 37 public class J2EEServer extends J2EEManagedObject 38 implements J2EEServerMBean 39 { 40 42 44 private List deployedObjectNames = new ArrayList (); 46 47 private List resourceNames = new ArrayList (); 49 50 private List mJVMs = new ArrayList (); 52 53 private String mServerVendor = null; 54 55 private String mServerVersion = null; 56 57 59 61 public J2EEServer(String pName, ObjectName pDomain, String pServerVendor, 62 String pServerVersion) 63 throws 64 MalformedObjectNameException , 65 InvalidParentException 66 { 67 super(J2EETypeConstants.J2EEServer, pName, pDomain); 68 mServerVendor = pServerVendor; 69 mServerVersion = pServerVersion; 70 } 71 72 74 77 public String [] getdeployedObjects() 78 { 79 String [] deployedObjects = new String [deployedObjectNames.size()]; 80 deployedObjectNames.toArray(deployedObjects); 81 return deployedObjects; 82 } 83 84 87 public String getdeployedObject(int pIndex) 88 { 89 if (pIndex >= 0 && pIndex < deployedObjectNames.size()) 90 { 91 return (String ) deployedObjectNames.get(pIndex); 92 } 93 return null; 94 } 95 96 99 public String [] getresources() 100 { 101 String [] resources = new String [resourceNames.size()]; 102 resourceNames.toArray(resources); 103 return resources; 104 } 105 106 109 public String getresource(int pIndex) 110 { 111 if (pIndex >= 0 && pIndex < resourceNames.size()) 112 { 113 return (String ) resourceNames.get(pIndex); 114 } 115 return null; 116 } 117 118 121 public String [] getjavaVMs() 122 { 123 String [] jvms = new String [mJVMs.size()]; 124 mJVMs.toArray(jvms); 125 return jvms; 126 } 127 128 131 public String getjavaVM(int pIndex) 132 { 133 if (pIndex >= 0 && pIndex < mJVMs.size()) 134 { 135 return (String ) mJVMs.get(pIndex); 136 } 137 else 138 { 139 return null; 140 } 141 } 142 143 146 public String getserverVendor() 147 { 148 return mServerVendor; 149 } 150 151 154 public String getserverVersion() 155 { 156 return mServerVersion; 157 } 158 159 public void addChild(ObjectName pChild) 160 { 161 String lType = J2EEManagedObject.getType(pChild); 162 if (J2EETypeConstants.J2EEApplication.equals(lType) || 163 J2EETypeConstants.EJBModule.equals(lType) || 164 J2EETypeConstants.ResourceAdapterModule.equals(lType) || 165 J2EETypeConstants.WebModule.equals(lType) || 166 J2EETypeConstants.ServiceModule.equals(lType)) 167 { 168 deployedObjectNames.add(pChild.getCanonicalName()); 169 } 170 else if (J2EETypeConstants.JVM.equals(lType)) 171 { 172 mJVMs.add(pChild.getCanonicalName()); 173 } 174 else if (J2EETypeConstants.JNDIResource.equals(lType) || 175 J2EETypeConstants.JMSResource.equals(lType) || 176 J2EETypeConstants.URLResource.equals(lType) || 177 J2EETypeConstants.JTAResource.equals(lType) || 178 J2EETypeConstants.JavaMailResource.equals(lType) || 179 J2EETypeConstants.JDBCResource.equals(lType) || 180 J2EETypeConstants.RMI_IIOPResource.equals(lType) || 181 J2EETypeConstants.JCAResource.equals(lType)) 182 { 183 resourceNames.add(pChild.getCanonicalName()); 184 } 185 } 186 187 public void removeChild(ObjectName pChild) 188 { 189 String lType = J2EEManagedObject.getType(pChild); 190 if (J2EETypeConstants.J2EEApplication.equals(lType) || 191 J2EETypeConstants.EJBModule.equals(lType) || 192 J2EETypeConstants.ResourceAdapterModule.equals(lType) || 193 J2EETypeConstants.WebModule.equals(lType) || 194 J2EETypeConstants.ServiceModule.equals(lType)) 195 { 196 deployedObjectNames.remove(pChild.getCanonicalName()); 197 } 198 else if (J2EETypeConstants.JVM.equals(lType)) 199 { 200 mJVMs.remove(pChild.getCanonicalName()); 201 } 202 else if (J2EETypeConstants.JNDIResource.equals(lType) || 203 J2EETypeConstants.JMSResource.equals(lType) || 204 J2EETypeConstants.URLResource.equals(lType) || 205 J2EETypeConstants.JTAResource.equals(lType) || 206 J2EETypeConstants.JavaMailResource.equals(lType) || 207 J2EETypeConstants.JDBCResource.equals(lType) || 208 J2EETypeConstants.RMI_IIOPResource.equals(lType) || 209 J2EETypeConstants.JCAResource.equals(lType)) 210 { 211 resourceNames.remove(pChild.getCanonicalName()); 212 } 213 } 214 215 public String toString() 216 { 217 return "J2EEServer { " + super.toString() + " } [ " + 218 "depoyed objects: " + deployedObjectNames + 219 ", resources: " + resourceNames + 220 ", JVMs: " + mJVMs + 221 ", J2EE vendor: " + mServerVendor + 222 " ]"; 223 } 224 225 227 229 231 } 233 | Popular Tags |