FileDocCategorySizeDatePackage
ObjectNameSelectionAlgorithm.javaAPI DocGlassfish v2 API4430Fri May 04 22:24:10 BST 2007com.sun.enterprise.admin.mbeans.custom

ObjectNameSelectionAlgorithm

public class ObjectNameSelectionAlgorithm extends Object
Implements an algorithm to select the ObjectName given the various parameters. See Design Document for details.

Fields Summary
Constructors Summary
private ObjectNameSelectionAlgorithm()

    
Methods Summary
public static booleanimplementsMBeanRegistrationInterface(java.lang.String className)

        boolean imri = false;
        try {
            //Note that the bits of the class need to be loaded dynamically and hence we need MBeanClassLoader
            ClassLoader mbcl        = new MBeanClassLoader();
            Class mbc               = Class.forName(className, false, mbcl);
            final Class[] iifs      = mbc.getInterfaces();
            for (Class c : iifs) {
                if (javax.management.MBeanRegistration.class.equals(c)) {
                    imri = true;
                    mbc = null; mbcl = null; // make them garbage-collectible  asap :), purpose served
                    break;
                }
            }
        } catch (final Exception e) {
            throw new RuntimeException (e);
        }
        return ( imri );
    
private static booleanimplementsMBeanRegistrationInterface(java.util.Map params)

        return implementsMBeanRegistrationInterface(params.get(CustomMBeanConstants.IMPL_CLASS_NAME_KEY));
    
public static javax.management.ObjectNameselect(java.util.Map params)

        ObjectName on = null;
        try {
            if (params.containsKey(CustomMBeanConstants.OBJECT_NAME_KEY))
                on = new ObjectName(params.get(CustomMBeanConstants.OBJECT_NAME_KEY));
            else { 
                /* WBN 
                 * note that we always form an ON.  For a CMB that implements 
                 * MBeanRegistration -- it may use that name or it may create its
                 * own name.  If it creates its own name, we'll see it soon and then use
                 * that name in preference to this one...
                 */
                on = MBeanValidator.formDefaultObjectName(params);
            }
            return ( on );
        } catch(final MalformedObjectNameException me) {
            throw new RuntimeException(me);
        }