FileDocCategorySizeDatePackage
PersistenceChecker.javaAPI DocGlassfish v2 API8045Fri May 04 22:33:54 BST 2007com.sun.enterprise.admin.server.core.jmx.storage

PersistenceChecker

public class PersistenceChecker extends Object
A class that acts as the bridge between persistent store and MBean Repository. Uses the conversion between ObjectName and identification into Config API and carries out the search.

Fields Summary
private static final Logger
_logger
private com.sun.enterprise.admin.AdminContext
mAdminContext
Constructors Summary
public PersistenceChecker()
Creates new PersistenceChecker


        
       
    
        //for future use.
    
Methods Summary
public java.lang.ObjectfindElement(javax.management.ObjectName objectName)

        Object      match   = null;
        
        match= findElement_8_0(objectName);
        if(match!=null)
            return match;
        
        //Now try the old 7.0 namespace
        // which's still alive 
        String type         = ObjectNameHelper.getType(objectName);
        String instanceName = ObjectNameHelper.getServerInstanceName(objectName);
        
        if (type != null)
        {
            if (type.equals(ObjectNames.kController))
            {
                match = new ServerController();
            }
            else if (type.equals(ObjectNames.kGenericConfigurator))
            {
                match = new GenericConfigurator();
            }
            else if (type.equals(ObjectNames.kServerInstance))
            {
                match = findServerInstance(instanceName);
                if(match==null)
                    throw new InstanceNotFoundException(objectName.toString());
            }
            else  if (type.equals(ObjectNames.kDeployment))
            {
               match = findServerInstance(instanceName);
               if(match==null)
                   throw new InstanceNotFoundException(objectName.toString());
            }
            else
            {
                /* Ordinary Config Mbean - use ConfigMBeanNaming */
                match = findGenericConfigBean(objectName, instanceName);
            }
        }
        else
        {
            /* unknown type */
            _logger.log(Level.FINE, "mbean.config.admin.unknown_mbean_type", objectName.toString() );
        }
        return ( match );
    
private java.lang.ObjectfindElement_8_0(javax.management.ObjectName objectName)

        try
        {
            MBeanRegistry registry  = MBeanRegistryFactory.getAdminMBeanRegistry();
            return (Object)registry.findMBeanRegistryEntry(objectName);
        }
        catch(Exception e)
        {
            return null;
        }
    
private java.lang.ObjectfindGenericConfigBean(javax.management.ObjectName objectName, java.lang.String instanceName)

        /* Ordinary Config Mbean - use ConfigMBeanNaming */
        Object bean = null;
        ConfigMBeanNamingInfo mbeanInfo = null;
        try
        {
            mbeanInfo = new ConfigMBeanNamingInfo(objectName);
        }
        catch (MBeanConfigException mce)
        {
            _logger.log(Level.FINE, "mbean.config.admin.naming_not_found", 
                        new Object[]{objectName.toString(), mce.getLocalizedMessage()} );
        }
        if(mbeanInfo!=null)
        {
            String xPath = mbeanInfo.getXPath();
            try
            {
                ConfigContext ctx = getConfigContext(instanceName);
                bean = ConfigBeansFactory.getConfigBeanByXPath(ctx, xPath);                
            }
            catch(Exception e)
            {
                _logger.log(Level.FINE, "mbean.config.admin.config_bean_not_found", 
                            new Object[]{xPath, e.getLocalizedMessage()} );
            }
        }
        return bean;
    
private java.lang.ObjectfindServerInstance(java.lang.String instanceName)

        ServerManager sm = ServerManager.instance();
	Server serverInstance = null;
/*        boolean isAdminServer = instanceName.equals(
                                    ServerManager.ADMINSERVER_ID); */
        if (! sm.instanceExists(instanceName) /*&& !isAdminServer*/)
        {
            return null;
        }

        try
        {
            ConfigContext cc = getConfigContext(instanceName);
            serverInstance = ServerBeansFactory.getServerBean(cc);
        }
        catch(Exception e)
        {
            e.printStackTrace(); //no harm in squelching
        }
        return ( serverInstance );
    
private com.sun.enterprise.config.ConfigContextgetConfigContext(java.lang.String instanceName)

        if (mAdminContext != null) {
            return mAdminContext.getAdminConfigContext();
        } else {
            String backupServerXmlPath = new InstanceEnvironment(instanceName).getBackupConfigFilePath();
            return (ConfigFactory.createConfigContext(backupServerXmlPath) );
        }
    
public voidsetAdminContext(com.sun.enterprise.admin.AdminContext ctx)

        mAdminContext = ctx;