FileDocCategorySizeDatePackage
JndiMBeanManager.javaAPI DocGlassfish v2 API5015Fri May 04 22:24:20 BST 2007com.sun.enterprise.admin.monitor.jndi

JndiMBeanManager

public class JndiMBeanManager extends Object
The JndiMBeanManager is responsible for registering and unregistering the JndiMBean.
author
Rob Ruyak

Fields Summary
private MBeanServer
server
MBeanServer for registering/unregistering JndiMBean
private static final Logger
logger
private static final com.sun.enterprise.util.i18n.StringManager
sm
Constructors Summary
public JndiMBeanManager()
Creates a new instance of JndiMBeanManager

    
           
      
        server = this.getMBeanServer();
    
Methods Summary
javax.management.MBeanServergetMBeanServer()
Gets the MBeanServer for use within the JndiMBeanManager.

return
The MBeanServer used to register the mbean.

        MBeanServer server = null;
        java.util.ArrayList servers = MBeanServerFactory.findMBeanServer(null);
        if(!servers.isEmpty()){
            server = (MBeanServer)servers.get(0);
        }
        return server;
    
public voidregisterMBean(javax.management.ObjectName objectName)
Registers the JndiMBean.

param
objectName The objectName of the JndiMBean.

        try {
            if (server.isRegistered(objectName)) {
                logger.fine(sm.getString("monitor.jndi.already_registered", 
                    new Object[] {objectName.toString()}));
                return;
            }            
            server.registerMBean(new JndiMBeanImpl(), objectName);
            logger.finer(sm.getString("monitor.jndi.registered", 
                    new Object[]{objectName.toString()}));
        } catch(Exception e) {
            logger.fine(sm.getString("monitor.jndi.register_exception", 
                    new Object[]{objectName}));
            logger.throwing(JndiMBeanManager.class.getName(),
                    "registerMBean()", e);
        }
    
public voidunregisterMBean(javax.management.ObjectName objectName)
Unegisters the JndiMBean.

param
objectName The objectName of the JndiMBean.

        try {
            if (server.isRegistered(objectName)) {
                server.unregisterMBean(objectName);
                logger.fine(sm.getString("monitor.jndi.unregistered",
                        new Object[]{objectName.toString()}));
            } else {
                logger.fine(sm.getString("monitor.jndi.never_registered",
                        new Object[]{objectName.toString()}));
            } 
        } catch(Exception e) {
            logger.fine(sm.getString("monitor.jndi.register_failed", 
                    new Object[]{objectName.toString()}));
        }