FileDocCategorySizeDatePackage
AdminContextImpl.javaAPI DocGlassfish v2 API9796Fri May 04 22:33:46 BST 2007com.sun.enterprise.admin.server.core

AdminContextImpl

public class AdminContextImpl extends Object implements com.sun.enterprise.admin.AdminContext

Fields Summary
private com.sun.enterprise.server.ServerContextImpl
serverContext
private com.sun.enterprise.config.ConfigContext
runtimeConfigContext
private com.sun.enterprise.config.ConfigContext
adminConfigContext
private MBeanServer
mbeanServer
private String
domainName
private String
serverName
private Logger
adminLogger
private com.sun.enterprise.admin.util.proxy.Interceptor
configInterceptor
private URL
adminMBeanRegistryURL
private URL
runtimeMBeanRegistryURL
private static final String
ADMIN_DESCRIPTORS_FILENAME
private static final String
RUNTIME_DESCRIPTORS_FILENAME
Constructors Summary
public AdminContextImpl()
Creates a new instance of AdminContextImpl


               
      
        String loggerName = System.getProperty("com.sun.aas.admin.logger.name");
        if (loggerName != null) {
            adminLogger = Logger.getLogger(loggerName);
        } else {
            adminLogger = Logger.getAnonymousLogger();
        }
        //default PE settings 
        domainName = "com.sun.appserv";
        //notify MBeanRegistryFactory
        MBeanRegistryFactory.setAdminContext(this);
    
public AdminContextImpl(com.sun.enterprise.server.ServerContextImpl srvCtx)

        this();
        setServerContext(srvCtx);
    
Methods Summary
public com.sun.enterprise.config.ConfigContextgetAdminConfigContext()

        return adminConfigContext;
    
private com.sun.enterprise.config.pluggable.ConfigEnvironmentgetAdminConfigEnvironment(java.lang.String configFileName)

        ConfigEnvironment ce = EnvironmentFactory.getEnvironmentFactory().
                                getConfigEnvironment();
        ce.setUrl(configFileName);
        ce.setReadOnly(false);
        ce.setCachingEnabled(false);
        ce.setRootClass("com.sun.enterprise.config.serverbeans.Domain");
        ce.setHandler("com.sun.enterprise.config.serverbeans.ServerValidationHandler");
        ce.getConfigBeanInterceptor().setResolvingPaths(false);
        return ce;
    
public java.util.logging.LoggergetAdminLogger()

        return adminLogger;
    
public java.net.URLgetAdminMBeanRegistryURL()

        if(adminMBeanRegistryURL==null) {
            try { 
                //PE standard 
                adminMBeanRegistryURL  = MBeanRegistry.class.getResource(ADMIN_DESCRIPTORS_FILENAME);
            } catch (Throwable t) {
                adminLogger.log(Level.WARNING, "core.adminconfig_adminregistry_not_found",
                       ADMIN_DESCRIPTORS_FILENAME);
            }
        }
        return adminMBeanRegistryURL;
    
public java.lang.StringgetDomainName()

        return domainName;
    
public java.lang.StringgetDottedNameMBeanImplClassName()

        return  "com.sun.enterprise.admin.mbeans.DottedNameGetSetMBeanImpl";
    
public javax.management.MBeanServergetMBeanServer()

        return mbeanServer;
    
public com.sun.enterprise.admin.util.proxy.InterceptorgetMBeanServerInterceptor()

        if (configInterceptor == null) {
            configInterceptor = new ConfigInterceptor(this);
        }
        return configInterceptor;
    
public com.sun.enterprise.config.ConfigContextgetRuntimeConfigContext()

        return runtimeConfigContext;
    
public java.net.URLgetRuntimeMBeanRegistryURL()

        if(runtimeMBeanRegistryURL==null) {
            try { 
                //PE standard 
                runtimeMBeanRegistryURL  = MBeanRegistry.class.getResource(RUNTIME_DESCRIPTORS_FILENAME);
            } catch (Throwable t) {
                adminLogger.log(Level.WARNING, "core.adminconfig_runtimeregistry_not_found",
                       RUNTIME_DESCRIPTORS_FILENAME);
            }
        }
        return runtimeMBeanRegistryURL;
    
public java.lang.StringgetServerName()

        return serverName;
    
protected voidregisterConfigAdjustmentListener()

	
        // Added mechanism to avoid unadjusted domain.xml.<->MBeans<->dotted_names
             adminConfigContext.addConfigContextEventListener((ConfigContextEventListener)(new AdminConfigEventListener()));
    
protected voidregisterValidator()

	
        // Added reflection mechanism to avoid compile time error
	try {
             Class cl = Class.forName("com.sun.enterprise.config.serverbeans.validation.DomainMgr");
             adminConfigContext.addConfigContextEventListener((ConfigContextEventListener)cl.newInstance());
        } catch (Exception ex) {
             adminLogger.log(Level.WARNING, "core.admin_validator_not_registered", "Error registering validator, config validator will not be available");
             adminLogger.log(Level.FINE, "core.admin_validator_register_error", ex.getMessage());
        }
    
public voidsetAdminConfigContext(com.sun.enterprise.config.ConfigContext ctx)

    
public voidsetAdminLogger(java.util.logging.Logger logger)

        adminLogger = logger;
    
public voidsetAdminMBeanRegistryURL(java.net.URL url)

        adminMBeanRegistryURL = url;
    
public voidsetDomainName(java.lang.String name)

//        domainName = name;
    
public voidsetMBeanServer(javax.management.MBeanServer mbs)

        mbeanServer = mbs;
    
public voidsetMBeanServerInterceptor(com.sun.enterprise.admin.util.proxy.Interceptor interceptor)

    
public voidsetRuntimeConfigContext(com.sun.enterprise.config.ConfigContext ctx)

        if (serverContext != null) {
            serverContext.setConfigContext(ctx);
        }
    
public voidsetRuntimeMBeanRegistryURL(java.net.URL url)

        runtimeMBeanRegistryURL = url;
    
public voidsetServerContext(com.sun.enterprise.server.ServerContextImpl srvCtx)

        serverContext = srvCtx;
        runtimeConfigContext = serverContext.getConfigContext();
        String configFileName = serverContext.getServerConfigURL();
        try {
            adminConfigContext = ConfigContextFactory.createConfigContext(
                    getAdminConfigEnvironment(configFileName));
            this.setServerName(srvCtx.getInstanceName());
            // Registering the config validator
            if (ServerHelper.isDAS(srvCtx.getConfigContext(), srvCtx.getInstanceName())) {
                registerValidator();
                registerConfigAdjustmentListener();
            }
        } catch (ConfigException ce) {
            adminLogger.log(Level.SEVERE, "core.determining_server_instance_failed",
                   ce);
        } catch (RuntimeException ce) {
            adminLogger.log(Level.SEVERE, "core.admin_config_read_error",
                   ce.getMessage());
            adminLogger.log(Level.WARNING, "core.admin_config_read_error_trace",
                   ce);
            throw ce;
        }
              
        adminLogger.log(Level.FINEST, "core.log_config_id_runtime",
                new Long(runtimeConfigContext.hashCode()));
        adminLogger.log(Level.FINEST, "core.log_config_is_admin",
                new Long(adminConfigContext.hashCode()));
        serverName = serverContext.getInstanceName();
    
public voidsetServerName(java.lang.String serverName)

        this.serverName = serverName;