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

BasicCustomMBeanConfigQueries

public class BasicCustomMBeanConfigQueries extends Object implements CustomMBeanConfigQueries

Fields Summary
protected final com.sun.enterprise.config.ConfigContext
acc
Constructors Summary
public BasicCustomMBeanConfigQueries()
Creates a new instance of BasicCustomMBeanConfigQueries

        this.acc = MBeanRegistryFactory.getAdminContext().getAdminConfigContext();
    
Methods Summary
public booleanexistsMBean(java.lang.String target, java.lang.String name)

        final List<String> names = this.listMBeanNames(target);
        boolean exists = false;
        for (String aName : names) {
            if (aName.equals(name)) {
                exists = true;
                break;
            }
        }
        return ( exists );
    
public booleanisMBeanEnabled(java.lang.String target, java.lang.String name)

        boolean enabled = false;
        if (!existsMBean(target, name)) {
            final String msg = CMBStrings.get("MBeanNotFound", name, target);
            throw new CustomMBeanException(msg);
        }
        final List<ObjectName> ons      = this.listMBeanConfigObjectNames(target);
        //get the attribute called "enabled" on these ObjectNames.
        try {
            final MBeanServerConnection mbsc        = MBeanServerFactory.getMBeanServer(); // best to be prepared toward remoteness
            final String noe                        = ServerTags.ENABLED;
            for (ObjectName on : ons) {
                final String s = (String) mbsc.getAttribute(on, noe);
                if (Boolean.valueOf(s).booleanValue()) {
                    enabled = true;
                    break;
                }
            }
            return ( enabled );
        } catch (final Exception e) {
            throw new CustomMBeanException (e);
        }
    
public java.util.ListlistMBeanConfigObjectNames(java.lang.String target)

        Target t = null;
        try {
            t = TargetBuilder.INSTANCE.createTarget(target, this.acc);
        } catch (final Exception e) {
            throw new CustomMBeanException(e);
        }
        return ( this.listMBeanConfigObjectNamesForServer(t.getName()) );
    
public java.util.ListlistMBeanConfigObjectNames(java.lang.String target, int type, boolean state)

        throw new UnsupportedOperationException(CMBStrings.get("NYI", "com.sun.enterprise.admin.mbeans.custom.BasicCustomMBeanConfigQueries.listMBeanConfigObjectNames"));
    
protected java.util.ListlistMBeanConfigObjectNamesForServer(java.lang.String s)
Method to get the ObjectNames of the Config MBeans that correspond to custom-mbean-definitions that are referenced from a server instance. This method does bulk of the work in this class.

        //when here, assume that the server exists, with the name "s"
        try {
            final List<Mbean> refdMbeans    = ServerBeansFactory.getReferencedMBeans(acc, s);
            return ( this.mbeans2ConfigMBeanObjectNames(refdMbeans) );
        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
    
public java.util.ListlistMBeanNames(java.lang.String target)

        final List<ObjectName> ons      = this.listMBeanConfigObjectNames(target);
        final List<String> names        = new ArrayList<String> ();
        //get the attribute called "name" on these ObjectNames.
        try {
            final MBeanServerConnection mbsc        = MBeanServerFactory.getMBeanServer(); // best to be prepared toward remoteness
            final String noa                        = ServerTags.NAME;
            for (ObjectName on : ons) {
                final String voa                        = (String) mbsc.getAttribute(on, noa);
                names.add(voa);
            }
            return ( names );
        } catch(final Exception e) {
            throw new CustomMBeanException(e);
        }
    
protected java.util.Listmbeans2ConfigMBeanObjectNames(java.util.List mbeans)

        try {
            final List<ObjectName> ons = new ArrayList<ObjectName> ();
            for (Mbean m : mbeans) {
                final String domain = AdminService.PRIVATE_MBEAN_DOMAIN_NAME;
                final ObjectName on = MBeanRegistryFactory.getAdminMBeanRegistry().getObjectNameForConfigBean(m, domain);
                ons.add(on);
            }
            return ( ons ) ;
        } catch (final Exception e) {
            throw new RuntimeException(e);
        }