FileDocCategorySizeDatePackage
InstanceEnvironment.javaAPI DocGlassfish v2 API64286Fri May 04 22:35:00 BST 2007com.sun.enterprise.instance

InstanceEnvironment

public final class InstanceEnvironment extends Object
The class that stores all environment of a iAS SE Server Instance with a given name. The name of the instance is the same as given by the (administrative) user. The class hides all the details of mapping between such a name and its location on disk. Note that this class is responsible for environment of a single Server Instance only. Upgraded it to the new file layout. Please refer to new file layout for the instance configuration. This class should be in unison with this document. Please note that there is a dependency on installer code. If you make any changes to this file, make sure that you visit installer code at com/iplanet/ias/installer/windows/actions
author
Kedar
version
1.1

Fields Summary
private static Object
lock
private static final boolean
TIMESTAMP_MECHANISM_ENABLED
enable/disable TimeStamp mechanism TOTALLY
private static final boolean
MIMETYPE_TIMESTAMP_MECHANISM_ENABLED
enable/disable TimeStamp mechinism for Mime.types. makes sense only if TIME_STAMP_MECHANISM_ENABLED is true;
private static final boolean
VIRTUAL_SERVER_TIMESTAMP_MECHANISM_ENABLED
private static final long
INVALID_TIME_STAMP
private static final long
UNINITIALIZED_TIME_STAMP
private static Logger
_logger
public static final String
kConfigDirName
folder where the configuration of this instance is stored
public static final String
kBackupDirName
folder where the configuration of this instance is backed up
private static final String
kRepositoryBackupDirName
public static final String
kGeneratedDirName
folder where all generated code like compiled jsps, stubs is stored
public static final String
kRepositoryDirName
default folder where deployed j2ee-apps are stored
public static final String
kApplicationDirName
public static final String
kModuleDirName
folder where deployed modules are stored
public static final String
kLifecycleModuleDirName
folder where all the deployed life cycle modules are stored
public static final String
kEJBStubDirName
folder where ejb related stuff is stored
public static final String
kConfigXMLFileName
New for 8.0 - domain.xml is config file name
public static final String
kServerXMLFileName
New for 8.0 - domain.xml is config file name
public static final String
kLibDirName
folder where the other required classes are stored
public static final String
kAutoDeployDirName
folder where the auto deploy monitor looks for new archives to deploy
public static final String
kLibClassesDirName
folder where the customer overridden classes are stored
public static final String
kCompileJspDirName
folder where the compiled JSP pages reside
public static final String
kGeneratedXMLDirName
folder where the modified xml files reside
public static final String
kSessionStoreDirName
folder where the session info or passivated ejbs are to be stored can be overridden in the server.xml
public static final String
kHttpSessionDirName
folder to persist the HTTP session data
public static final String
kDocRootDirName
folder for docroot
public static final String
kObjectFileName
object file name
public static final String
kInitFileName
init file name
public static final String
kSecurityPasswordsFileName
name of the iWS NSS passwords file
public static final String
kRealmsKeyFileName
name of the realms key file
public static final String
kInstallDirName
name of the install dir
public static final String
kTemplatesDirName
name of the templates dir
public static final String
kAclTemplate
ACL template name
public static final int
kOrbListenerPort
default orb-listener port
public static final int
kJmsProviderPort
default jms-service (imq) port
public static final String
kJavaWebStartDirName
directory where java-web-start related files are located
private String
instanceRoot
private String
mLogicalName
private String
mConfigFilePath
private String
mBackupConfigFilePath
private String
mApplicationRootPath
mApplicationRootPath points to the application root of the server. If this is unspecified, it will default to /applications. This is where J2EE applications, modules, life-cycle modules will be created.
private String
mApplicationRepositoryPath
mApplicationRepositoryPath is where the j2ee-apps are stored. It is possible that the applications running/deployed to an instance are located at different locations. This attribute denotes the "current" location where the j2ee-apps are to be stored at. Same is true for other application/module related paths. This does not refer to stubs or jsp pages.
private String
mApplicationBackupRepositoryPath
private String
mModuleRepositoryPath
private String
mModuleBackupRepositoryPath
private String
mApplicationStubRepositoryPath
private String
mModuleStubRepositoryPath
private String
mApplicationGeneratedXMLPath
private String
mModuleGeneratedXMLPath
private String
mLibPath
private String
mAutoDeployDirPath
private String
mLibClassesPath
private String
mApplicationPassivatedEjbPath
private String
mModulePassivatedEjbPath
private String
mApplicationCompiledJspPath
private String
mWebModuleCompiledJspPath
private String
mApplicationHttpSessionStorePath
private String
mModuleHttpSessionStorePath
private String
mDocRootPath
private String
mStopCommandPath
private String
mDefaultAccessLogPath
private String
mObjectFilePath
private String
mInitFilePath
private String
mBackupObjectFilePath
private String
mBackupInitFilePath
private String
mSecurityPasswordsFilePath
private String
mRealmsKeyFilePath
private String
mBackupRealmsKeyFilePath
private String
mAclFilePath
private String
mBackupAclFilePath
private String
kAclFilePrefix
private String
kBackupAclFilePrefix
private String
kAclFileSuffix
private String
mJavaWebStartDirPath
private boolean
mInited
private String
mInstancesRoot
private com.sun.enterprise.config.serverbeans.PropertyResolver
mPathResolver
Constructors Summary
public InstanceEnvironment(String instanceName)
Creates new InstanceEnvironment for Server Instance with given name. Name may not be null or empty String. Name may not begin with a digit.

It is essential to note that an instance with this name is created /indeed before creating object of this class.

param
instanceName String denoting the name of Server Instance.
throws
IllegalArgumentException if the name is null or empty String or does not begin with a letter (in both the variants) or the instance directory does not exist. Thus the examples of invalid values are "6ias"
see
com.sun.enterprise.config.ServerManager#createServerInstance

	
	                                                                                                                                                                                                                                     	
	
       
		this(System.getProperty(Constants.IAS_ROOT), 
		     instanceName);
    
public InstanceEnvironment(String instancesRoot, String instanceName)

        if (! StringUtils.ok(instanceName)) {
		  throw new IllegalArgumentException(Localizer.getValue(ExceptionType.NULL_ARG));
        }
        mLogicalName = instanceName;
		mInstancesRoot = instancesRoot;
        createConfigFilePath();
        //createBackupConfigFilePath();
    
Methods Summary
public voidapplyAclFileChanges()
overwrite the generated..acl file with the contents of the genwork..acl file

    
public voidapplyAllMimeFileChanges()
Overwrite all mime.types files for the instance. These are the files that are mime elements on the http-service element. Note, there is no transactional model.

throws
ConfigException if copy fails.

	
public voidapplyChangesFromBackup()
Apply the changes from all the files i.e. the other config files to the real one. This method simply copies the files over and there is no transaction model built into it. If the method throws any exception, there is a chance that the changes are not correctly applied. Note that the only UI from which the object file (obj.conf) and initialization file (init.conf) is changed is the admin cgis and some servlets. Most of the clients change the server.xml. This method will typically be called when the apply/reconfigure of clients is called.

    
public voidapplyChangesFromBackup(boolean overwrite)

    
public voidapplyInitFileChanges()
overwrite the "live" init.conf with the contents of the backup init.conf file

    
public voidapplyObjectFileChanges()
overwrite the "live" obj.conf with the contents of the backup obj.conf file

    
public voidapplyRealmsKeyFileChanges()
overwrite the "live" keyfile with the contents of the backup init.conf file

    
public voidapplyServerXmlChanges(boolean overwrite)
overwrite the "live" server.xml with the contents of the backup server.xml file

    
public voidapplyVirtualServersConfFileChanges(com.sun.enterprise.config.ConfigContext hotXmlCtx)

/*
        init();
            synchronized(lock) {
		ConfigContext context = ConfigFactory.createConfigContext(
                                    mBackupConfigFilePath);
		if (context == null) {
			// this is serious. ConfigContext for
			//this server instance should be created by now.
			
			throw new ConfigException(
                    Localizer.getValue(ExceptionType.NO_XML_BU));
		}
          //ROB: config changes
		//Server 		rootElement = ServerBeansFactory.getServerBean(context);
          Config rootElement = ServerBeansFactory.getConfigBean(context);
 
		HttpService httpService = rootElement.getHttpService();
		VirtualServerClass[] vsClasses = httpService.getVirtualServerClass();
		for(int i = 0 ; i < vsClasses.length ; i++) {
			VirtualServerClass vsClass = vsClasses[i];
            VirtualServer[] virtualServers = vsClass.getVirtualServer();
            for(int j = 0 ; j < virtualServers.length ; j++) {
                VirtualServer virtualServer = virtualServers[j];
                String  configFileName  = virtualServer.getConfigFile();
                File    srcFile         = null;
                if (configFileName != null) {
                    srcFile = new File(getBackupConfigDirPath(), 
                                       configFileName);
                }
                if ((srcFile == null) || (!srcFile.exists())) {
                    continue;
                }
                File destFile   = new File(getConfigDirPath(), configFileName);
                copyFile(srcFile, destFile);
                //Chown file
                if (isChownNeeded(null)) {
                    chownFile(destFile.getAbsolutePath());
                }
                if(VIRTUAL_SERVER_TIMESTAMP_MECHANISM_ENABLED) {
                    String tsFilePath = 
                            getTimeStampFileName(srcFile.getAbsolutePath());
                    saveTimeStamp(tsFilePath, destFile.getAbsolutePath());
                }
            }
               
            }
*/
        /* The following code deletes the config files from the config
         * directory. These config files correspond to the virtual servers
         * that would have been deleted from the backup xml.
         */
/*
            deleteVirtualServerConfigFiles(hotXmlCtx, context, true);
         }
*/
        
public booleancanReloadManualXmlChanges()
is used to findout if we can reload transparently i.e., reload configcontext To do this, we need to findout if xml has changed. If it has, then is backup in memory changed, i.e., has ConfigContext Changed ? return true if you can reload return false if hot has not changed or if you cannot reload

        return false;
    
private voidchownFile(java.lang.String filePath)

        /*installConfig is removed and we need better alternative */
        /*
        try {
            String error = new installConfig().chownFile(
                filePath, getInstanceUser());
            if (error != null) {
                throw new ConfigException(error);
            }
        } catch (IOException ioe) {
            throw new ConfigException(ioe.getMessage());
        }
        */
    
private voidcopyFile(java.io.File fromFile, java.io.File toFile)
Copies the offline file on real one.

throws
ConfigException in case copy fails for various reasons.
param
hot java.io.File that is real one (target).
param
cold java.io.File that is backup/offline (source).

        if(!fromFile.exists())
                throw new ConfigException(Localizer.getValue(ExceptionType.FROM_NOT_EXIST, fromFile.getPath()));

        if(fromFile.isDirectory())
                throw new ConfigException(Localizer.getValue(ExceptionType.FROM_IS_DIR, fromFile.getPath()));

        /** WBN March 14, 2002
         * There is a very strange problem -- Windows will sometimes return 0 for
         * the length of a file that is NOT zero-length.  I tested and proved beyond 
         * any doubt that length() is *wrong*.
         * This is probably a JVM bug.  So I've commented-out the following code.
        if(cold.length() <= 0)
        {
                throw new ConfigException(err + coldErr + "is zero length");
        }
        */

        if(toFile.isDirectory())
                throw new ConfigException(Localizer.getValue(ExceptionType.TO_IS_DIR, toFile.getPath()));

        if(toFile.exists() && !toFile.canWrite())
                throw new ConfigException(Localizer.getValue(ExceptionType.TO_READ_ONLY, toFile.getPath()));

        try
        {
                FileUtils.copy(fromFile, toFile);
        }
        catch(Exception e)
        {
			Object[] objs = new Object[] { fromFile.getPath(), toFile.getPath(), e.toString() };
            throw new ConfigException(Localizer.getValue(ExceptionType.FAILED_COPY, objs), e);
        }
    
private voidcreateAclFilePath()
Creates the path of acl file

        // aclFile is generated.<serverId>.acl
        String aclFileName = kAclFilePrefix + "." + getName() + "." + kAclFileSuffix;
        String[] fileNames = new String[] {mInstancesRoot,
            kConfigDirName, aclFileName};
        mAclFilePath = StringUtils.makeFilePath(fileNames, false);
    
private voidcreateApplicationBackupRepositoryPath()
Creates the path for backup repository of applications pertaining to this Instance -- directory-deployed apps

        String[] onlyFolderNames = new String[] {
										mApplicationRootPath,
										kRepositoryBackupDirName, 
										kApplicationDirName};
        mApplicationBackupRepositoryPath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voidcreateApplicationCompiledJspPath()
Creates the path for compiled JSP pages from a J2EE application

        String[] onlyFolderNames = new String[] {mInstancesRoot,
            kGeneratedDirName, kCompileJspDirName, kApplicationDirName};

        mApplicationCompiledJspPath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voidcreateApplicationGeneratedXMLPath()
Creates the path for generated xml for all applications deployed to this Instance.

        String[] onlyFolderNames = new String[] {mInstancesRoot, kGeneratedDirName,
                kGeneratedXMLDirName, kApplicationDirName};
        mApplicationGeneratedXMLPath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voidcreateApplicationRepositoryPath()
Creates the path for repository of applications pertaining to this Instance.

        String[] onlyFolderNames = new String[] {
										mApplicationRootPath,
										kApplicationDirName};
        mApplicationRepositoryPath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voidcreateApplicationRootPath()
Creates the ApplicationRootPath that is guaranteed to take into account the changes made to server.xml. Initializes the application root to a valid non-null String. Does not check whether this is a directory that can be written to.

		try {
			ConfigContext context = ConfigFactory.
				createConfigContext(mConfigFilePath);
			Domain domain = ServerBeansFactory.getDomainBean(context);
			mApplicationRootPath = domain.getApplicationRoot();
			if (mApplicationRootPath == null || mApplicationRootPath.length() <=0){
				createDefaultApplicationRootPath();
			}
            mApplicationRootPath = resolvePath(mApplicationRootPath);
		}
		catch (Exception e) {
			_logger.log(Level.WARNING, "InstanceEnv.createApplicationRootPath()", e);
		}
	
private voidcreateApplicationStubPath()
Creates the path for repository of EJB stubs for all applications deployed to this Instance.

        String[] onlyFolderNames = new String[] {mInstancesRoot, kGeneratedDirName,
                kEJBStubDirName, kApplicationDirName};
        mApplicationStubRepositoryPath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voidcreateAutoDeployDirPath()
Formulates the path to the instance auto deploy dir.

        String[] onlyFolderNames = 
            new String[] {mInstancesRoot, kAutoDeployDirName};
        mAutoDeployDirPath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voidcreateBackupAclFilePath()
Creates the path of backup of acl file

        // backupAclFile is genwork.<serverId>.acl
        String backupAclFileName = kBackupAclFilePrefix + "." + getName() + "." + kAclFileSuffix;
        String[] fileNames = new String[] {mInstancesRoot,
            kConfigDirName, backupAclFileName};
        mBackupAclFilePath = StringUtils.makeFilePath(fileNames, false);
    
private voidcreateBackupConfigFilePath()
Creates the path for backup server.xml pertaining to this Instance.

        String[] onlyFolderNames = new String[] {mInstancesRoot, 
                                         kConfigDirName, 
                                         kBackupDirName, 
                                         kConfigXMLFileName};
        mBackupConfigFilePath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voidcreateBackupInitFilePath()
Creates the path of backup initialization file

        String[] fileNames = new String[] {mInstancesRoot,
            kConfigDirName, kBackupDirName, kInitFileName};
        mBackupInitFilePath = StringUtils.makeFilePath(fileNames, false);
    
private voidcreateBackupObjectFilePath()
Creates the path of backup object file

        String[] fileNames = new String[] {mInstancesRoot,
            kConfigDirName, kBackupDirName, kObjectFileName};
        mBackupObjectFilePath = StringUtils.makeFilePath(fileNames, false);
    
private voidcreateBackupRealmsKeyFilePath()
Creates the path of backup Realms key file

        String[] fileNames = new String[] {mInstancesRoot,
            kConfigDirName, kBackupDirName, kRealmsKeyFileName};
        mBackupRealmsKeyFilePath = StringUtils.makeFilePath(fileNames, false);
    
private voidcreateConfigFilePath()
Creates the path for server.xml pertaining to this Instance.

        String[] onlyFolderNames = new String[] {mInstancesRoot, 
                                         kConfigDirName, 
                                         kConfigXMLFileName};
        mConfigFilePath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voidcreateDefaultAccessLogPath()
Creates the path of default access log file

        final String logDirName         = "logs";
        final String accessLogFileName  = "access";
        String[] fileNames              = new String[] {mInstancesRoot,
           logDirName, accessLogFileName}; 
        mDefaultAccessLogPath = StringUtils.makeFilePath(fileNames, false);
    
private voidcreateDefaultApplicationRootPath()
Initializes mApplicationRootPath = /applications.

        String[] onlyFolderNames = new String[] {
										mInstancesRoot,
										kRepositoryDirName};
        mApplicationRootPath = StringUtils.makeFilePath(onlyFolderNames, false);
	
private voidcreateDocRootPath()
Creates the Path for the docroot of this instance. With the new layout, the docroot is supposed to be in the folder for instance configuration by default.

        String[] onlyFolderNames = new String[] {mInstancesRoot,
            kDocRootDirName};

        mDocRootPath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voidcreateHttpSessionStorePaths()
Creates the paths for ejbs from both application and module. The paths are like this: httpsession-store-for-modules=/http/j2ee-modules httpsession-store-for-apps=/http/j2ee-apps

		try {
			ConfigContext context = ConfigFactory.createConfigContext(
				mConfigFilePath);
			EjbContainer ejbContainer = ServerBeansFactory.getConfigBean(context).getEjbContainer();
			String sessionStore = ejbContainer.getSessionStore();
			if (sessionStore == null || sessionStore.length() <= 0) {
				sessionStore = getDefaultSessionStorePath();
			}
            sessionStore = resolvePath(sessionStore);
			String[] onlyFolderNames = new String[] {
				sessionStore,
				kHttpSessionDirName,
				kApplicationDirName
			};
			mApplicationHttpSessionStorePath = StringUtils.makeFilePath(onlyFolderNames, false);
			onlyFolderNames[2] = kModuleDirName;
			mModuleHttpSessionStorePath	= StringUtils.makeFilePath(onlyFolderNames, false);
		}
		catch (Exception e) {
			_logger.log(Level.WARNING, "InstanceEnv.createApplicationRootPath()", e);
		}
	
private voidcreateInitFilePath()
Creates the path of initialization file

        String[] fileNames = new String[] {mInstancesRoot,
            kConfigDirName, kInitFileName};
        mInitFilePath = StringUtils.makeFilePath(fileNames, false);
    
private voidcreateJavaWebStartPath()
Creates the path to the java-web-start directory

        String[] fileNames = new String[] {mInstancesRoot,
            kJavaWebStartDirName};
        mJavaWebStartDirPath = StringUtils.makeFilePath(fileNames, false);
    
private voidcreateLibClassesPath()
Formulates the path to the instance lib classes directory. Any class files under this dir will be be included by the shared class loader.

        String[] onlyFolderNames = new String[] {mInstancesRoot, kLibDirName, 
        kLibClassesDirName};
        mLibClassesPath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voidcreateLibPath()
Formulates the path to the instance lib dir. Any jar files under this dir will be included by the shared class loader.

        String[] onlyFolderNames = new String[] {mInstancesRoot, kLibDirName};
        mLibPath = StringUtils.makeFilePath(onlyFolderNames, false);

    
private voidcreateMimeTSFiles()

     
private voidcreateModuleBackupRepositoryPath()
Creates the path for backup repository of modules pertaining to this Instance -- directory-deployed modules

        String[] onlyFolderNames = new String[] {
										mApplicationRootPath,
						                kRepositoryBackupDirName, 
										kModuleDirName};
        mModuleBackupRepositoryPath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voidcreateModuleGeneratedXMLPath()
Creates the path for generated xml for all standalone modules deployed to this Instance.

        String[] onlyFolderNames = new String[] {mInstancesRoot, kGeneratedDirName,
                kGeneratedXMLDirName, kModuleDirName};
        mModuleGeneratedXMLPath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voidcreateModuleRepositoryPath()
Creates the path for repository of standalone modules pertaining to this Instance.

        String[] onlyFolderNames = new String[] {
										mApplicationRootPath,
										kModuleDirName};
        mModuleRepositoryPath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voidcreateModuleStubPath()
Creates the path for repository of EJB stubs for all standalone modules deployed to this Instance.

        String[] onlyFolderNames = new String[] {mInstancesRoot, kGeneratedDirName,
                kEJBStubDirName, kModuleDirName};
        mModuleStubRepositoryPath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voidcreateObjectFilePath()
Creates the path of object file

        String[] fileNames = new String[] {mInstancesRoot,
            kConfigDirName, kObjectFileName};
        mObjectFilePath = StringUtils.makeFilePath(fileNames, false);
    
private voidcreatePassivatedEjbPaths()
Creates the paths for ejbs from both application and module. The paths are like this: passivated-beans-for-modules=/ejb/j2ee-modules passivated-beans-for-apps=/ejb/j2ee-apps

		try {
			ConfigContext context = ConfigFactory.createConfigContext(
				mConfigFilePath);
			EjbContainer ejbContainer = ServerBeansFactory.getConfigBean(context).getEjbContainer();
			String sessionStore = ejbContainer.getSessionStore();
			if (sessionStore == null || sessionStore.length() <= 0) {
				sessionStore = getDefaultSessionStorePath();
			}
            sessionStore = resolvePath(sessionStore);
			String[] onlyFolderNames = new String[] {
				sessionStore,
				kEJBStubDirName,
				kApplicationDirName
			};
			mApplicationPassivatedEjbPath = StringUtils.makeFilePath(onlyFolderNames, false);
			onlyFolderNames[2] = kModuleDirName;
			mModulePassivatedEjbPath	= StringUtils.makeFilePath(onlyFolderNames, false);
		}
		catch (Exception e) {
			_logger.log(Level.WARNING, "InstanceEnv.createApplicationRootPath()", e);
		}
	
private voidcreatePathResolver()

        try {
            mPathResolver = new PropertyResolver(
                ConfigFactory.createConfigContext(mConfigFilePath), 
                mLogicalName);
        } catch (Exception e) {
            //log it.
        }
    
private voidcreateRealmsKeyFilePath()
Creates the path of Realms key file

        String[] fileNames = new String[] {mInstancesRoot,
            kConfigDirName, kRealmsKeyFileName};
        mRealmsKeyFilePath = StringUtils.makeFilePath(fileNames, false);
    
private voidcreateSecurityPasswordsFilePath()
Creates the path of iWS NSS passwords file

        String[] fileNames = new String[] {mInstancesRoot,
            kConfigDirName, kSecurityPasswordsFileName};
        mSecurityPasswordsFilePath = StringUtils.makeFilePath(fileNames, false);
    
private voidcreateStopCommandPath()
Creates the stop command path for this instance.

        String[]    onlyFolderNames    = new String[] {mInstancesRoot};
        String      execName           = null; 
        if(OS.isWindows()) {
            execName = InstanceDefinition.WIN_STOP_COMMAND_NAME;
        }
        else {
            execName = InstanceDefinition.UNIX_STOP_COMMAND_NAME;
        }    
        mStopCommandPath = StringUtils.makeFilePath(onlyFolderNames, true)
                + execName;
    
private voidcreateTSFile(java.lang.String tsFileName, java.lang.String actualFile, java.lang.String backupFile)

         // if the file does not exist, 
         // create ts file
         File f = new File(tsFileName);
            if(!f.exists()) {
                saveTimeStamp(tsFileName, actualFile, backupFile);
            }
     
public voidcreateTimeStampFiles()
init to be called from constructor

        init();
        if(!TIMESTAMP_MECHANISM_ENABLED) return;
         synchronized(lock) {
         /* TOMCAT_BEGIN Ramakanth */
         createTSFile(getTimeStampFileName(mConfigFilePath), 
             mConfigFilePath, mConfigFilePath);
         createTSFile(getTimeStampFileName(mBackupRealmsKeyFilePath), 
             mRealmsKeyFilePath, mBackupRealmsKeyFilePath);
         /* TOMCAT_END Ramakanth */
         }
     
private voidcreateVirtualServersConfTSFiles()

/*
        if(!VIRTUAL_SERVER_TIMESTAMP_MECHANISM_ENABLED) return;
         
        try {
            ConfigContext context = ConfigFactory.
                createConfigContext(mConfigFilePath, true, false, false);
            if (context == null) {
                // this is serious. ConfigContext for
                // this server instance should be created by now.
                
                return;
            }
            //ROB: config changes
            //Server 		rootElement = ServerBeansFactory.getServerBean(context);
            Config rootElement = ServerBeansFactory.getConfigBean(context);

            HttpService httpService = rootElement.getHttpService();
            VirtualServerClass[] vsClasses = httpService.getVirtualServerClass();
            for(int i = 0 ; i < vsClasses.length ; i ++) {
                VirtualServerClass aClass = vsClasses[i];
                VirtualServer[] virtualServers = aClass.getVirtualServer();
                for(int j = 0 ; j < virtualServers.length ; j++) {
                    VirtualServer aServer = virtualServers[j];
                    String file = aServer.getConfigFile();
                    if ((file == null) || (file.length() == 0)) {
                        continue;
                    }
                    String backPath = getBackupConfigDirPath() + File.separator
                                        + file;
                    String hotPath = getConfigDirPath() + File.separator
                                        + file;
                    String tsFileName = getTimeStampFileName(backPath); 
                    File f = new File(tsFileName);
                    if(!f.exists()) {
                        saveTimeStamp(tsFileName, hotPath, backPath);
                    }
                }
            }
        } catch(Throwable t) {
            _logger.log(Level.WARNING,"core.create_mime_ts_file_exception",t);
            //ignore. go ahead.
        }
*/
    
private voidcreateWebModuleCompiledJspPath()
Creates the path for compiled JSP Pages from a standalone web app module.

        String[] onlyFolderNames = new String[] {mInstancesRoot,
            kGeneratedDirName, kCompileJspDirName, kModuleDirName};

        mWebModuleCompiledJspPath = StringUtils.makeFilePath(onlyFolderNames, false);
    
private voiddeleteVirtualServerConfigFiles(com.sun.enterprise.config.ConfigContext ctx, com.sun.enterprise.config.ConfigContext ctx2, boolean isHot)
This method iterates through the virtual-server elements foreach virtual-server-class element of the 'ctx' and checks if a corresponding virtual-server element exists in 'ctx2'. If not, it assumes that the virtual-server element has been deleted from ctx2 and deletes the corresponding config file from the config directory of 'ctx'. This method assumes that virtual-server ids are unique across virtual-server-class elements.

/*
          //ROB: config changes
 		//Server 		rootElement     = ServerBeansFactory.getServerBean(ctx);
          Config rootElement = ServerBeansFactory.getConfigBean(ctx);

		HttpService httpService     = rootElement.getHttpService();

          //ROB: config changes
          //Server      rootElement2    = ServerBeansFactory.getServerBean(ctx2);
          Config rootElement2 = ServerBeansFactory.getConfigBean(ctx2);

		HttpService httpService2    = rootElement2.getHttpService();

        VirtualServerClass[] vsClasses = 
                                httpService.getVirtualServerClass();
        for(int i = 0 ; i < vsClasses.length ; i++) {
            VirtualServerClass vsClass = vsClasses[i];
            String vsClassId = vsClass.getId();
            VirtualServerClass vsClass2 = 
                    httpService2.getVirtualServerClassById(vsClassId);
            boolean deleteAll = false;
            if (vsClass2 == null) {
                // This virtual-server-class was probably deleted 
                 // from ctx2. So delete the config files for all the
                 // virtual servers.
                
                deleteAll = true;
            }
            VirtualServer[] virtualServers = vsClass.getVirtualServer();
            for(int j = 0 ; j < virtualServers.length ; j++) {
               VirtualServer vs = virtualServers[j]; 
               String vsId = vs.getId();
               if ((deleteAll) || 
                   (vsClass2.getVirtualServerById(vsId) == null)) {
                   String configFileName = vs.getConfigFile();
                   if ((configFileName == null) || 
                       (configFileName.length() == 0)) {
                       continue;
                   }
                   String parent = (isHot) ? getConfigDirPath() : 
                                             getBackupConfigDirPath();
                   File confFile = new File(parent, configFileName);
                   if (confFile.exists()) {
                       confFile.delete();
                   }
                   if (!isHot) {
                       //Remove timestamp file
                       File tsFile = new File(parent, 
                                              configFileName + ".timestamp");
                       if (tsFile.exists()) {
                           tsFile.delete();
                       }
                   }
               }
            }
        }
*/

    
public java.lang.StringgetApplicationBackupRepositoryPath()
Returns the absolute path for location where all the backups of directory-deployed applications are stored for this Server Instance.

        init();
            return ( mApplicationBackupRepositoryPath );
    
public java.lang.StringgetApplicationCompileJspPath()
Returns the path for compiled JSP Pages from an J2EE application that is deployed on this instance. By default all such compiled JSPs should lie in the same folder.

        init();
        return ( mApplicationCompiledJspPath );
    
public ApplicationEnvironmentgetApplicationEnvironment(java.lang.String appName)


        init();
        if (appName == null) {
            throw new IllegalArgumentException();
        }
        return ( new ApplicationEnvironment(this, appName) );
    
public java.lang.StringgetApplicationGeneratedXMLPath()
Returns the absolute path for location where all generated xml for all applications are stored for this Server Instance.

        init();
            return ( mApplicationGeneratedXMLPath );
    
public java.lang.StringgetApplicationHttpSessionStorePath()

        init();
        return ( mApplicationHttpSessionStorePath );
    
public java.lang.StringgetApplicationPassivatedEjbPath()
Returns the path for the Session Store of where HTTP session data of the instance can be stored.

        init();
        return ( mApplicationPassivatedEjbPath );
    
public java.lang.StringgetApplicationRepositoryPath()
Returns the absolute path for location where all the deployed applications are stored for this Server Instance.

        init();
            return ( mApplicationRepositoryPath );
    
public java.lang.StringgetApplicationStubPath()
Returns the absolute path for location where all ejb stubs for all applications are stored for this Server Instance.

        init();
            return ( mApplicationStubRepositoryPath );
    
public java.lang.StringgetAutoDeployDirPath()
Returns the path to the instance's auto deploy directory.

return
the path to the instance's auto deploy directory

        init();
        return ( mAutoDeployDirPath );
    
public java.lang.StringgetBackupConfigDirPath()

	/*
        String[] folderNames = new String[] {mInstancesRoot,
            kConfigDirName, kBackupDirName};
        String backupConfigDirPath =
                StringUtils.makeFilePath(folderNames, false);
        return ( backupConfigDirPath );
	*/
	return getConfigDirPath();
    
public java.lang.StringgetBackupConfigFilePath()
Returns the absolute path for the backup config file pertaining to this Server Instance.

            return ( mConfigFilePath );
    
public java.lang.StringgetBackupInitFilePath()

        init();
        return ( mBackupInitFilePath );
    
public java.lang.StringgetBackupObjectFilePath()

        init();
        return ( mBackupObjectFilePath );
    
public java.lang.StringgetBackupRealmsKeyFilePath()

        init();
        return ( mRealmsKeyFilePath );
    
public java.lang.StringgetConfigDirPath()

        String[] folderNames = new String[] {mInstancesRoot,
            kConfigDirName};
        String configDirPath =
                StringUtils.makeFilePath(folderNames, false);
        return ( configDirPath );
    
public java.lang.StringgetConfigFilePath()
Returns the absolute path for the config file pertaining to this Server Instance.

            return ( mConfigFilePath );
    
private longgetConfigFileTimeStamp(java.lang.String configFile)

        //need to read xml and get the timestamp
        long ts = UNINITIALIZED_TIME_STAMP;
        try {
            File f = new File(configFile);
            ts = f.lastModified();
        } catch(Throwable t) {
            //ignore
        }
        return ts;
    
public java.lang.StringgetDefaultAccessLogPath()
Returns the default value of accesslog for the instance. Returns null in case of error. Note that this is only the default value which may be different than the actual value of any virtual server in this instance.

return
String representing default log file path for any virtual server in this instance.

        init();
        return ( mDefaultAccessLogPath );
    
private java.lang.StringgetDefaultSessionStorePath()
Path upto /session-store is returned

        String[] onlyFolderNames = new String[] {
				mInstancesRoot, 
				kSessionStoreDirName
		};
        return ( StringUtils.makeFilePath(onlyFolderNames, false) );
	
public java.lang.StringgetDocRootPath()
Returns the docroot path for this instance.

        init();
        return ( mDocRootPath );
    
public java.lang.StringgetInitFilePath()

        init();
        return ( mInitFilePath );
    
public java.lang.StringgetInstanceUser()

        init();
        return ServerManager.instance().getInstanceUser(this);
    
public java.lang.StringgetInstancesRoot()
Returns the path where entire data/config etc. of this instance is stored on the disk.

return
absolute path of the instance's home.

        return (mInstancesRoot);
    
public java.lang.StringgetJavaWebStartPath()

        init();
        return mJavaWebStartDirPath;
    
private longgetLastModifiedFromTSFile(java.lang.String tsFileName)

            long ts = INVALID_TIME_STAMP; //different from getXmlFileTimeStamp for a purpose
            
            FileReader fr = null;
            try {
                File f = new File(tsFileName);
		//_logger.log(Level.INFO,"ts file: " + ((f.exists())?"exists":"does not exist")); 
		
                
                fr = new FileReader(f);
                
                char[] cbuf = new char[13]; // should be sufficint
                fr.read(cbuf);
		String s = new String(cbuf);
		//_logger.log(Level.FINE,"String is:" + s +":");
                ts = (new Long(s)).longValue();
            } catch(Throwable t) {
				// _logger.log(Level.WARNING,"Exception caught in getting LastModified",t);
                //ignore ?
            } finally {
                try {
                    fr.close();
		    fr = null;
                } catch(Exception ex){}
            }
            return ts;
        
public java.lang.StringgetLibClassesPath()
Returns the path to the instance lib/classes directory.

return
the path to the instance lib/classes directory

        init();
        return ( mLibClassesPath );
    
public java.lang.StringgetLibPath()
Returns the path to the instance lib directory.

return
the path to the instance lib directory

        init();
        return ( mLibPath );
    
private longgetManualChangeTime()

        long ts = UNINITIALIZED_TIME_STAMP;
        long tsTmp = UNINITIALIZED_TIME_STAMP;
        
        try {
            ts = getConfigFileTimeStamp(mInitFilePath);
            tsTmp =  getConfigFileTimeStamp(mObjectFilePath);
            
            if(ts < tsTmp) ts = tsTmp;
            
            tsTmp = getConfigFileTimeStamp(mConfigFilePath);
            
            if(ts < tsTmp) ts = tsTmp;
            
/*
            ConfigContext context = ConfigFactory.
            createConfigContext(mConfigFilePath, true, false, false);
            if (context == null) {
                        // this is serious. ConfigContext for
                        //this server instance should be created by now.
                throw new ConfigException(Localizer.getValue(ExceptionType.NO_XML));
            }
            //ROB: config changes
            //Server 		rootElement = ServerBeansFactory.getServerBean(context);
            Config rootElement = ServerBeansFactory.getConfigBean(context);

            HttpService httpService = rootElement.getHttpService();
            Mime[] 		mimes		= httpService.getMime();
            for(int i = 0 ; i < mimes.length ; i ++) {
                Mime aMime = mimes[i];
                String file = aMime.getFile();
                String hotPath = getConfigDirPath() + File.separator
                + file;
                
                
                tsTmp = getConfigFileTimeStamp(hotPath);
                if(ts < tsTmp) ts = tsTmp;
                
            }
 
*/           
        } catch (Throwable t) {
            //ignore return ture;
        }
        return ts;    
    
public java.lang.StringgetModuleBackupRepositoryPath()
Returns the absolute path for location where all the deployed standalone module backups are stored for this Server Instance.

        init();
            return ( mModuleBackupRepositoryPath );

    
public ModuleEnvironmentgetModuleEnvironment(java.lang.String moduleName, com.sun.enterprise.deployment.backend.DeployableObjectType type)

        init();
        if (moduleName == null) {
                throw new IllegalArgumentException();
        }

        return ( new ModuleEnvironment(this, moduleName, type) );
    
public java.lang.StringgetModuleGeneratedXMLPath()
Returns the absolute path for location where all generated xml for all modules are stored for this Server Instance.

        init();
            return ( mModuleGeneratedXMLPath );
    
public java.lang.StringgetModuleHttpSessionStorePath()

        init();
        return ( mModuleHttpSessionStorePath );
    
public java.lang.StringgetModulePassivatedEjbPath()

        init();
        return ( mModulePassivatedEjbPath );
    
public java.lang.StringgetModuleRepositoryPath()
Returns the absolute path for location where all the deployed standalone modules are stored for this Server Instance.

        init();
            return ( mModuleRepositoryPath );

    
public java.lang.StringgetModuleStubPath()
Returns the absolute path for location where all ejb stubs for all modules are stored for this Server Instance.

        init();
            return ( mModuleStubRepositoryPath );
    
public java.lang.StringgetName()
A method that returns the logical name of this Server Instance.

            return ( mLogicalName );
    
public java.lang.StringgetObjectFilePath()

        init();
        return ( mObjectFilePath );
    
public java.lang.StringgetRealmsKeyFilePath()

        init();
        return ( mRealmsKeyFilePath );
    
public java.lang.StringgetSecurityPasswordsFilePath()

        init();
        return ( mSecurityPasswordsFilePath );
    
public java.lang.StringgetStopCommandPath()

        init();
        return ( mStopCommandPath );
    
public static java.lang.StringgetTemplatesDirPath()
Returns the path to the templates directory.

        final String installRoot = System.getProperty(Constants.INSTALL_ROOT);
        String[] dirs = new String[] {installRoot, kLibDirName, 
                                      kInstallDirName, kTemplatesDirName};
        return StringUtils.makeFilePath(dirs, false);
    
private java.lang.StringgetTimeStampFileName(java.lang.String fullName)

        return fullName + ".timestamp";
    
public java.lang.StringgetWebModuleCompileJspPath()
Returns the path for compiled JSP Pages from an Web application that is deployed standalone on this instance. By default all such compiled JSPs should lie in the same folder.

        init();
        return ( mWebModuleCompiledJspPath );
    
private booleanhasBakMimeChanged()

	return false;
    
public booleanhasBakupVirtualServerConfChanged()

    	return false;
    
public booleanhasCGIConfigFilesChanged()
Has any of config files managed by cgi scripts changed. The files managed by cgi scripts are init.conf, obj.conf and mime types files.

    	return false;
    
public booleanhasHotChanged()

        return false;
    
public booleanhasHotInitChanged()

    	return false;
    
public booleanhasHotMimeChanged()

    	return false;
    
public booleanhasHotObjectChanged()

    	return false;
    
public booleanhasHotRealmsKeyChanged()

    	return false;
    
public booleanhasHotVirtualServerConfChanged()

    	return false;
    
public booleanhasHotXmlChanged()

    	return false;
    
public booleanhasInitOrObjConfFileChanged()
Has init.conf or obj.conf file changed.

return
true if live init.conf or obj.conf has changed manually, or backup init.conf or obj.conf file timestamp is later than live

    	return false;
    
public booleanhasMimeConfFileChanged()
Has configured mime file(s) changed.

return
true if any of the live configured mime type file has been changed manually, or if any of the backup mime file timestamp is later than the timestamp for live files.

        return false;
    
private booleanhasOnlyHotXmlChanged()

    	return false;
    
public booleanhasRealmsKeyConfFileChanged()
Has Realms keyfile changed.

return
true if live keyfile has changed manually, or backup keyfile file timestamp is later than live

    	return false;
    
private booleanhasVirtualServerConfChanged(com.sun.enterprise.config.ConfigContext context, boolean isHot)

        return false;
    
public booleanhasVirtualServerConfFileChanged()

    	return false;
    
private voidinit()

        if (mInited) {
            return;
        }
        createPathResolver();
		createApplicationRootPath();
        createApplicationRepositoryPath();
        createApplicationBackupRepositoryPath();
        createModuleRepositoryPath();
        createModuleBackupRepositoryPath();
        createApplicationStubPath();
        createModuleStubPath();
        createApplicationGeneratedXMLPath();
        createModuleGeneratedXMLPath();
        createLibPath();
        createLibClassesPath();
        createAutoDeployDirPath();
        createPassivatedEjbPaths();
        createApplicationCompiledJspPath();
        createWebModuleCompiledJspPath();
        createHttpSessionStorePaths();
        createDocRootPath();
        createStopCommandPath();
        createDefaultAccessLogPath();
        createObjectFilePath();
        createInitFilePath();
        createSecurityPasswordsFilePath();
        createRealmsKeyFilePath();
        createAclFilePath();
        createJavaWebStartPath();
        mInited = true;
    
public booleanisChownNeeded(java.io.File f)
Ignoring the file parameter for now.

        init();
/**
        if (OS.isUnix() || OS.isLinux()) {
            try {
                final String installUser = 
                    ServerManager.instance().getInstanceUser(
                            new InstanceEnvironment("admin-server"));
                final String instanceUser = 
                    ServerManager.instance().getInstanceUser(this);
                if (installUser.equals("root") && 
                    !instanceUser.equals(installUser)) {
                    return true;
                }
            } catch (IOException ioe) {
                _logger.warning(ioe.getMessage());
            }
        }
*/
        return false;
    
public final booleanisIASOwned(java.lang.String filename)
return true if the given file is located somewhere in the instance's file tree

            return isIASOwned(new File(filename));
    
public final booleanisIASOwned(java.io.File file)
return true if the given file is located somewhere in the instance's file tree

        init();
        try
        {
            // get the names and standardize them for comparison
            String iasPath			= getInstancesRoot();
            assert StringUtils.ok(iasPath);

            iasPath			= FileUtils.safeGetCanonicalPath(new File(iasPath));
            String filename	= FileUtils.safeGetCanonicalPath(file);

            if(!StringUtils.ok(iasPath))
                    return false;

            if(!StringUtils.ok(filename))
                    return false;

            if(filename.startsWith(iasPath))
                    return true;

            return false;
        }
        catch(Exception e)
        {
                return false;
        }
    
private java.lang.StringresolvePath(java.lang.String unresolved)

        if (mPathResolver != null) {
            return mPathResolver.resolve(unresolved);
        }
        return unresolved;
    
public booleanrestartRequired()

        init();
        //is instance stopped, return false;
        //is instance restarted after changes, return false;
        // return true;
        synchronized(lock) {
        try {
            RMIClient rc = AdminChannel.getRMIClient(this.mLogicalName);
            if(!rc.isAlive()) return false;
            if(rc.hasRestartedSince(getManualChangeTime())) return false;
            
            return true;
        } catch (Exception e) {
            //ignore
        }
        }
        return false;
    
private voidsaveTimeStamp(java.lang.String tsFileName, java.lang.String actualFile, java.lang.String backupFile)
saves timestamp and resets backup dir to the value of ts

            if(!TIMESTAMP_MECHANISM_ENABLED) return;
	    long ts = saveTimeStamp(tsFileName, actualFile);
	    new File(backupFile).setLastModified(ts);
	
private longsaveTimeStamp(java.lang.String tsFileName, java.lang.String actualFile)
set the value of timestamp in a new file the name of timestamp file is name of this xml + .timestamp always create this file even if readonly

            if(!TIMESTAMP_MECHANISM_ENABLED) return INVALID_TIME_STAMP;
            
            long timestamp = getConfigFileTimeStamp(actualFile);
		//_logger.log(Level.FINE,"writing TS file");
            File f = null;
            FileWriter fw = null;
            try {
                f = new File(tsFileName);
                fw = new FileWriter(f);
                fw.write("" + timestamp);
            } catch(Throwable t) {
			 _logger.log(Level.WARNING,"core.file_io_exception",t);
                //ignore
            } finally {
                try {
                    fw.close();
                } catch(Throwable ex){}
            }
            return timestamp;  
        
public java.lang.StringtoString()

        init();
            return ObjectAnalyzer.toString(this);
    
private voiduseManualAllMimeFileChanges()

    
public voiduseManualConfigChanges()

    
private voiduseManualInitFileChanges()

    
private voiduseManualObjectFileChanges()

    
private voiduseManualRealmsKeyFileChanges()

    
public voiduseManualServerXmlChanges()

    
private voiduseManualVirtualServerConfFileChanges(com.sun.enterprise.config.ConfigContext bakXmlCtx)

/*
		ConfigContext context = ConfigFactory.
			createConfigContext(getConfigFilePath(), true, false, false);
		if (context == null) {
			// this is serious. ConfigContext for
			// this server instance should be created by now.
			
			throw new ConfigException(Localizer.getValue(ExceptionType.NO_XML));
		}
          //ROB: config changes
		//Server 		rootElement = ServerBeansFactory.getServerBean(context);
          Config rootElement = ServerBeansFactory.getConfigBean(context);

		HttpService httpService = rootElement.getHttpService();
		VirtualServerClass[] vsClasses= httpService.getVirtualServerClass();
		for(int i = 0 ; i < vsClasses.length ; i++) {
			VirtualServerClass aClass = vsClasses[i];
            VirtualServer[] virtualServers = aClass.getVirtualServer();
            for(int j = 0 ; j < virtualServers.length ; j++) {
                VirtualServer aServer = virtualServers[j];
                String file = aServer.getConfigFile();
                if ((file == null) || (file.length() == 0)) {
                    continue;
                }
                String destPath = getBackupConfigDirPath() + File.separator
                                    + file;
                String srcPath  = getConfigDirPath() + File.separator
                                    + file;
                copyFile(new File(srcPath), new File(destPath));
                //Chown file
                if (isChownNeeded(null)) {
                    chownFile(destPath);
                }
                if(VIRTUAL_SERVER_TIMESTAMP_MECHANISM_ENABLED) {
                    String tsFilePath = getTimeStampFileName(destPath); 
                    saveTimeStamp(tsFilePath, srcPath);
                }
            }
		}
*/
        /* The following code deletes the config files from the backup
         * directory. These config files correspond to the virtual servers
         * that would have been deleted from the hot xml.
         */
/*
        deleteVirtualServerConfigFiles(bakXmlCtx, context, false);
*/
    
public java.lang.Stringverify()

            // return a String with the error, in English, if the required 
            // directories aren't there or have a problem.
            // return null if all is OK
            return null;