FileDocCategorySizeDatePackage
ServerContextImpl.javaAPI DocGlassfish v2 API12736Fri May 04 22:35:42 BST 2007com.sun.enterprise.server

ServerContextImpl

public class ServerContextImpl extends Object implements ServerContext
ServerContext interface: the server-wide runtime environment created by ApplicationServer and shared by its subsystems such as the web container or EJB container.

Fields Summary
public final String
SERVER_XML
XXX: should move these to Config API
public final String
DEFAULT_DOMAIN_NAME
public final String
CONFIG_DIR
private String[]
cmdLineArgs
server command line arguments
private com.sun.enterprise.server.pluggable.PluggableFeatureFactory
featureFactory
Pluggable features factory
private String
installRoot
install root of this server instance
private String
instanceName
name of this server instance
private static com.sun.enterprise.util.i18n.StringManager
localStrings
local string manager for i18n
private static ClassLoader
commonClassLoader
common class loader i.e., $instance/lib classloader
private static ClassLoader
sharedClassLoader
shared class loader i.e., connector class loader
private ClassLoader
lifeCycleClassLoader
parent class loader for the life cycle modules
private com.sun.enterprise.config.ConfigContext
configContext
server config context
private com.sun.enterprise.config.serverbeans.Server
server
server config bean
private String
serverConfigPath
private String
serverConfigURL
private com.sun.enterprise.instance.InstanceEnvironment
instanceEnvironment
environment object for this server instance
Constructors Summary
public ServerContextImpl()
public constructor


           
      
      installRoot = System.getProperty(Constants.INSTALL_ROOT);
      instanceName = System.getProperty("com.sun.aas.instanceName");
      getInstanceEnvironment();
    
Methods Summary
public java.lang.String[]getCmdLineArgs()
Get the server command-line arguments

return
the server command-line arguments

        return cmdLineArgs;
    
public java.lang.ClassLoadergetCommonClassLoader()
Get the classloader that loads .jars in $instance/lib and classes in $instance/lib/classes.

return
the common class loader for this server instance

        return this.commonClassLoader;
    
public com.sun.enterprise.config.serverbeans.ServergetConfigBean()
Get the server configuration bean.

return
the server config bean

        if (server != null) {
            return server;
        }

        // create the Server config bean
        if (configContext != null) {
            server = ServerBeansFactory.getServerBean(configContext);
        } else {
            // perhaps uninitialized?
            String msg = localStrings.getString(
                            "serverContext.config_context_is_null");
            throw new ConfigException(msg);
        }
        return this.server;
    
public com.sun.enterprise.config.ConfigContextgetConfigContext()
Returns the config context for this server.

return
the config context

        return this.configContext;
    
public java.lang.StringgetConfigURL(java.lang.String configName)
Get a URL representation of any configuration file in server config path

        String configURI = instanceEnvironment.getConfigFilePath();

        // XXX: Config API Doesn't expect URLs
        return configURI;
        // if (isWindows())
            // return "file:/" + configURI;
        // else
            // return "file:" + configURI;
    
public java.lang.StringgetDefaultDomainName()
get the default domain name

return
String default domain name

        return DEFAULT_DOMAIN_NAME;
    
public javax.naming.InitialContextgetInitialContext()
Get the initial naming context.

        // XXX: cleanup static instance variables
        NamingManager mgr = Switch.getSwitch().getNamingManager();
        if (mgr == null) {
            return null;
        }
        return (InitialContext)(mgr.getInitialContext());
    
public java.lang.StringgetInstallRoot()
Get server installation root

return
the server installation root

        return this.installRoot;
    
public com.sun.enterprise.instance.InstanceEnvironmentgetInstanceEnvironment()
Returns the environment object for this server instance.

return
the environment object for this server instance

        if (this.instanceEnvironment == null) {
            this.instanceEnvironment =
                new InstanceEnvironment(this.instanceName);
        }
        return this.instanceEnvironment;
    
public java.lang.StringgetInstanceName()
Get the server instance name

return
the server instance name

        return instanceName;
    
public com.sun.enterprise.InvocationManagergetInvocationManager()
Get the J2EE Server invocation manager

return
InvocationManager

        return Switch.getSwitch().getInvocationManager();
    
public java.lang.ClassLoadergetLifecycleParentClassLoader()
Returns the parent class loader for the life cycle modules.

return
the parent class loader for the life cycle modules

        return this.lifeCycleClassLoader;
    
public com.sun.enterprise.admin.monitor.registry.MonitoringRegistrygetMonitoringRegistry()
Returns the MonitoringRegistry implementation used for registration of monitoring stats.

return
instance of MonitoringRegistry

        /* Get the class from appserv-rt.jar for now through
         * reflection */
        final String REG_IMPL_CLASS =
        "com.sun.enterprise.admin.monitor.registry.spi.MonitoringRegistrationHelper";
        final String METHOD = "getInstance";
        try {
            final Class c = Class.forName(REG_IMPL_CLASS);
            final java.lang.reflect.Method m = c.getMethod(METHOD, (Class[]) null);
            final MonitoringRegistry r = (MonitoringRegistry) m.invoke(c, (Object[]) null);
            return r;
        }
        catch(Throwable t) {
            throw new RuntimeException(t);
        }
    
public com.sun.enterprise.server.pluggable.PluggableFeatureFactorygetPluggableFeatureFactory()
Get a factory for obtaining implementation of pluggable features.

        return featureFactory;
    
public java.lang.StringgetServerConfigPath()
Get the path to the server configuration directory

        return instanceEnvironment.getConfigDirPath();
    
public java.lang.StringgetServerConfigURL()
Get a URL representation of server configuration

return
the URL to the server configuration

            return instanceEnvironment.getConfigFilePath();
    
public java.lang.ClassLoadergetSharedClassLoader()
Returns the shared class loader of the server instance.

return
the shared class loader

        return this.sharedClassLoader;
    
private booleanisWindows()
Are we running on Windows platform?

        return (File.separatorChar == '\\");
    
protected voidsetCmdLineArgs(java.lang.String[] cmdLineArgs)
Set the server command-line arguments

param
cmdLineArgs array of command-line arguments

        this.cmdLineArgs = cmdLineArgs;
    
protected voidsetCommonClassLoader(java.lang.ClassLoader cl)
Set the classloader that loads .jars in $instance/lib and classes in $instance/lib/classes. Only allow classes in this package to set this value.

        this.commonClassLoader = cl;
    
public voidsetConfigContext(com.sun.enterprise.config.ConfigContext config)
Sets the given config context. This method gets called from the AdminEventMulticaster to set the config context after event processing is complete.

param
config config context

        this.configContext = config;
    
protected voidsetInstallRoot(java.lang.String installRoot)
Install root of the server

param
installRoot server installation root

        this.installRoot = installRoot;
    
voidsetInstanceEnvironment(com.sun.enterprise.instance.InstanceEnvironment instanceEnv)
Sets the instance environment object for this server instance.

param
instanceEnv environment object for this server instance

        this.instanceEnvironment = instanceEnv;
    
protected voidsetInstanceName(java.lang.String instanceName)
Instace name

param
instanceName name of this application server instance

        this.instanceName = instanceName;
    
protected voidsetLifecycleParentClassLoader(java.lang.ClassLoader cl)
Sets the parent class loader for the life cycle module

param
cl the parent class loader for the life cycle module

        this.lifeCycleClassLoader = cl;
    
public voidsetPluggableFeatureFactory(com.sun.enterprise.server.pluggable.PluggableFeatureFactory obj)
Set pluggable features factory. Initialization of server context must be followed by a call to this method. An easy way to obtain a PluggableFeatureFactory is to call the static method getInstance() on com.sun.enterprise.server.pluggable PluggableFeatureFactoryImpl class.

        featureFactory = obj;
    
protected voidsetSharedClassLoader(java.lang.ClassLoader cl)
Sets the shared class loader for the instance. Only allow classes in this package to set this value.

param
cl shared class loader

        this.sharedClassLoader = cl;