1 23 24 package com.sun.enterprise.admin.mbeans.custom; 25 26 import com.sun.enterprise.admin.mbeans.custom.loading.MBeanClassLoader; 27 import java.util.Map ; 28 import javax.management.MalformedObjectNameException ; 29 import javax.management.ObjectName ; 30 31 33 public class ObjectNameSelectionAlgorithm { 34 35 private ObjectNameSelectionAlgorithm() { 36 } 37 public static ObjectName select(final Map <String , String > params) throws RuntimeException { 38 ObjectName on = null; 39 try { 40 if (params.containsKey(CustomMBeanConstants.OBJECT_NAME_KEY)) 41 on = new ObjectName (params.get(CustomMBeanConstants.OBJECT_NAME_KEY)); 42 else { 43 49 on = MBeanValidator.formDefaultObjectName(params); 50 } 51 return ( on ); 52 } catch(final MalformedObjectNameException me) { 53 throw new RuntimeException (me); 54 } 55 } 56 57 public static boolean implementsMBeanRegistrationInterface(String className) throws RuntimeException { 58 boolean imri = false; 59 try { 60 ClassLoader mbcl = new MBeanClassLoader(); 62 Class mbc = Class.forName(className, false, mbcl); 63 final Class [] iifs = mbc.getInterfaces(); 64 for (Class c : iifs) { 65 if (javax.management.MBeanRegistration .class.equals(c)) { 66 imri = true; 67 mbc = null; mbcl = null; break; 69 } 70 } 71 } catch (final Exception e) { 72 throw new RuntimeException (e); 73 } 74 return ( imri ); 75 } 76 77 private static boolean implementsMBeanRegistrationInterface(final Map <String , String > params) throws RuntimeException { 78 return implementsMBeanRegistrationInterface(params.get(CustomMBeanConstants.IMPL_CLASS_NAME_KEY)); 79 } 80 } 81 | Popular Tags |