1 23 24 25 package com.sun.enterprise.management.util; 26 27 import com.sun.enterprise.management.agent.MEJBUtility; 28 import java.util.*; 29 import javax.management.ObjectName ; 30 31 public class J2EEModuleUtil { 32 33 public static String [] getjavaVMs() { 34 Set x = findNames("j2eeType=JVM"); 35 Iterator it = x.iterator(); 36 String vms[] = new String [x.size()]; 37 int i = 0; 38 while(it.hasNext()) 39 vms[i++] = ((ObjectName )it.next()).toString(); 40 return vms; 41 } 42 43 public static Set findNames(String keys) { 44 Set s = new HashSet(); 45 ObjectName namepattern = null; 46 try { 47 String pattern = getDomainName() + ":" + keys + ",*"; 48 namepattern = new ObjectName (pattern); 49 } 50 catch(Exception e) { 51 e.printStackTrace(); 52 } 53 if(namepattern != null) { 54 MEJBUtility mejb = MEJBUtility.getMEJBUtility(); 55 if(mejb != null) 56 try { 57 s = mejb.queryNames(namepattern, null); 58 } 59 catch(Exception e) { 60 e.printStackTrace(); 61 } 62 } 63 return s; 64 } 65 66 public static String getDomainName() { 67 return "com.sun.appserv"; 68 } 69 } | Popular Tags |