Fields Summary |
---|
private static Object | lock |
private static final boolean | TIMESTAMP_MECHANISM_ENABLEDenable/disable TimeStamp mechanism TOTALLY |
private static final boolean | MIMETYPE_TIMESTAMP_MECHANISM_ENABLEDenable/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 | kConfigDirNamefolder where the configuration of this instance is stored |
public static final String | kBackupDirNamefolder where the configuration of this instance is backed up |
private static final String | kRepositoryBackupDirName |
public static final String | kGeneratedDirNamefolder where all generated code like compiled jsps, stubs is stored |
public static final String | kRepositoryDirNamedefault folder where deployed j2ee-apps are stored |
public static final String | kApplicationDirName |
public static final String | kModuleDirNamefolder where deployed modules are stored |
public static final String | kLifecycleModuleDirNamefolder where all the deployed life cycle modules are stored |
public static final String | kEJBStubDirNamefolder where ejb related stuff is stored |
public static final String | kConfigXMLFileNameNew for 8.0 - domain.xml is config file name |
public static final String | kServerXMLFileNameNew for 8.0 - domain.xml is config file name |
public static final String | kLibDirNamefolder where the other required classes are stored |
public static final String | kAutoDeployDirNamefolder where the auto deploy monitor looks for new archives to deploy |
public static final String | kLibClassesDirNamefolder where the customer overridden classes are stored |
public static final String | kCompileJspDirNamefolder where the compiled JSP pages reside |
public static final String | kGeneratedXMLDirNamefolder where the modified xml files reside |
public static final String | kSessionStoreDirNamefolder where the session info or passivated ejbs are to be stored
can be overridden in the server.xml |
public static final String | kHttpSessionDirNamefolder to persist the HTTP session data |
public static final String | kDocRootDirNamefolder for docroot |
public static final String | kObjectFileNameobject file name |
public static final String | kInitFileNameinit file name |
public static final String | kSecurityPasswordsFileNamename of the iWS NSS passwords file |
public static final String | kRealmsKeyFileNamename of the realms key file |
public static final String | kInstallDirNamename of the install dir |
public static final String | kTemplatesDirNamename of the templates dir |
public static final String | kAclTemplateACL template name |
public static final int | kOrbListenerPortdefault orb-listener port |
public static final int | kJmsProviderPortdefault jms-service (imq) port |
public static final String | kJavaWebStartDirNamedirectory where java-web-start related files are located |
private String | instanceRoot |
private String | mLogicalName |
private String | mConfigFilePath |
private String | mBackupConfigFilePath |
private String | mApplicationRootPathmApplicationRootPath 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 | mApplicationRepositoryPathmApplicationRepositoryPath 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 |
Methods Summary |
---|
public void | applyAclFileChanges()overwrite the generated..acl file with the contents of the
genwork..acl file
|
public void | applyAllMimeFileChanges()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.
|
public void | applyChangesFromBackup()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 void | applyChangesFromBackup(boolean overwrite)
|
public void | applyInitFileChanges()overwrite the "live" init.conf with the contents of the
backup init.conf file
|
public void | applyObjectFileChanges()overwrite the "live" obj.conf with the contents of the
backup obj.conf file
|
public void | applyRealmsKeyFileChanges()overwrite the "live" keyfile with the contents of the
backup init.conf file
|
public void | applyServerXmlChanges(boolean overwrite)overwrite the "live" server.xml with the contents of the
backup server.xml file
|
public void | applyVirtualServersConfFileChanges(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 boolean | canReloadManualXmlChanges()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 void | chownFile(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 void | copyFile(java.io.File fromFile, java.io.File toFile)Copies the offline file on real one.
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 void | createAclFilePath()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 void | createApplicationBackupRepositoryPath()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 void | createApplicationCompiledJspPath()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 void | createApplicationGeneratedXMLPath()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 void | createApplicationRepositoryPath()Creates the path for repository of applications
pertaining to this Instance.
String[] onlyFolderNames = new String[] {
mApplicationRootPath,
kApplicationDirName};
mApplicationRepositoryPath = StringUtils.makeFilePath(onlyFolderNames, false);
|
private void | createApplicationRootPath()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 void | createApplicationStubPath()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 void | createAutoDeployDirPath()Formulates the path to the instance auto deploy dir.
String[] onlyFolderNames =
new String[] {mInstancesRoot, kAutoDeployDirName};
mAutoDeployDirPath = StringUtils.makeFilePath(onlyFolderNames, false);
|
private void | createBackupAclFilePath()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 void | createBackupConfigFilePath()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 void | createBackupInitFilePath()Creates the path of backup initialization file
String[] fileNames = new String[] {mInstancesRoot,
kConfigDirName, kBackupDirName, kInitFileName};
mBackupInitFilePath = StringUtils.makeFilePath(fileNames, false);
|
private void | createBackupObjectFilePath()Creates the path of backup object file
String[] fileNames = new String[] {mInstancesRoot,
kConfigDirName, kBackupDirName, kObjectFileName};
mBackupObjectFilePath = StringUtils.makeFilePath(fileNames, false);
|
private void | createBackupRealmsKeyFilePath()Creates the path of backup Realms key file
String[] fileNames = new String[] {mInstancesRoot,
kConfigDirName, kBackupDirName, kRealmsKeyFileName};
mBackupRealmsKeyFilePath = StringUtils.makeFilePath(fileNames, false);
|
private void | createConfigFilePath()Creates the path for server.xml pertaining to this Instance.
String[] onlyFolderNames = new String[] {mInstancesRoot,
kConfigDirName,
kConfigXMLFileName};
mConfigFilePath = StringUtils.makeFilePath(onlyFolderNames, false);
|
private void | createDefaultAccessLogPath()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 void | createDefaultApplicationRootPath()Initializes mApplicationRootPath = /applications.
String[] onlyFolderNames = new String[] {
mInstancesRoot,
kRepositoryDirName};
mApplicationRootPath = StringUtils.makeFilePath(onlyFolderNames, false);
|
private void | createDocRootPath()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 void | createHttpSessionStorePaths()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 void | createInitFilePath()Creates the path of initialization file
String[] fileNames = new String[] {mInstancesRoot,
kConfigDirName, kInitFileName};
mInitFilePath = StringUtils.makeFilePath(fileNames, false);
|
private void | createJavaWebStartPath()Creates the path to the java-web-start directory
String[] fileNames = new String[] {mInstancesRoot,
kJavaWebStartDirName};
mJavaWebStartDirPath = StringUtils.makeFilePath(fileNames, false);
|
private void | createLibClassesPath()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 void | createLibPath()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 void | createMimeTSFiles()
|
private void | createModuleBackupRepositoryPath()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 void | createModuleGeneratedXMLPath()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 void | createModuleRepositoryPath()Creates the path for repository of standalone modules
pertaining to this Instance.
String[] onlyFolderNames = new String[] {
mApplicationRootPath,
kModuleDirName};
mModuleRepositoryPath = StringUtils.makeFilePath(onlyFolderNames, false);
|
private void | createModuleStubPath()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 void | createObjectFilePath()Creates the path of object file
String[] fileNames = new String[] {mInstancesRoot,
kConfigDirName, kObjectFileName};
mObjectFilePath = StringUtils.makeFilePath(fileNames, false);
|
private void | createPassivatedEjbPaths()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 void | createPathResolver()
try {
mPathResolver = new PropertyResolver(
ConfigFactory.createConfigContext(mConfigFilePath),
mLogicalName);
} catch (Exception e) {
//log it.
}
|
private void | createRealmsKeyFilePath()Creates the path of Realms key file
String[] fileNames = new String[] {mInstancesRoot,
kConfigDirName, kRealmsKeyFileName};
mRealmsKeyFilePath = StringUtils.makeFilePath(fileNames, false);
|
private void | createSecurityPasswordsFilePath()Creates the path of iWS NSS passwords file
String[] fileNames = new String[] {mInstancesRoot,
kConfigDirName, kSecurityPasswordsFileName};
mSecurityPasswordsFilePath = StringUtils.makeFilePath(fileNames, false);
|
private void | createStopCommandPath()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 void | createTSFile(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 void | createTimeStampFiles()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 void | createVirtualServersConfTSFiles()
/*
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 void | createWebModuleCompiledJspPath()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 void | deleteVirtualServerConfigFiles(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.String | getApplicationBackupRepositoryPath()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.String | getApplicationCompileJspPath()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 ApplicationEnvironment | getApplicationEnvironment(java.lang.String appName)
init();
if (appName == null) {
throw new IllegalArgumentException();
}
return ( new ApplicationEnvironment(this, appName) );
|
public java.lang.String | getApplicationGeneratedXMLPath()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.String | getApplicationHttpSessionStorePath()
init();
return ( mApplicationHttpSessionStorePath );
|
public java.lang.String | getApplicationPassivatedEjbPath()Returns the path for the Session Store of where HTTP
session data of the instance can be stored.
init();
return ( mApplicationPassivatedEjbPath );
|
public java.lang.String | getApplicationRepositoryPath()Returns the absolute path for location where all the deployed
applications are stored for this Server Instance.
init();
return ( mApplicationRepositoryPath );
|
public java.lang.String | getApplicationStubPath()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.String | getAutoDeployDirPath()Returns the path to the instance's auto deploy directory.
init();
return ( mAutoDeployDirPath );
|
public java.lang.String | getBackupConfigDirPath()
/*
String[] folderNames = new String[] {mInstancesRoot,
kConfigDirName, kBackupDirName};
String backupConfigDirPath =
StringUtils.makeFilePath(folderNames, false);
return ( backupConfigDirPath );
*/
return getConfigDirPath();
|
public java.lang.String | getBackupConfigFilePath()Returns the absolute path for the backup config file pertaining
to this Server Instance.
return ( mConfigFilePath );
|
public java.lang.String | getBackupInitFilePath()
init();
return ( mBackupInitFilePath );
|
public java.lang.String | getBackupObjectFilePath()
init();
return ( mBackupObjectFilePath );
|
public java.lang.String | getBackupRealmsKeyFilePath()
init();
return ( mRealmsKeyFilePath );
|
public java.lang.String | getConfigDirPath()
String[] folderNames = new String[] {mInstancesRoot,
kConfigDirName};
String configDirPath =
StringUtils.makeFilePath(folderNames, false);
return ( configDirPath );
|
public java.lang.String | getConfigFilePath()Returns the absolute path for the config file pertaining
to this Server Instance.
return ( mConfigFilePath );
|
private long | getConfigFileTimeStamp(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.String | getDefaultAccessLogPath()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.
init();
return ( mDefaultAccessLogPath );
|
private java.lang.String | getDefaultSessionStorePath()Path upto /session-store is returned
String[] onlyFolderNames = new String[] {
mInstancesRoot,
kSessionStoreDirName
};
return ( StringUtils.makeFilePath(onlyFolderNames, false) );
|
public java.lang.String | getDocRootPath()Returns the docroot path for this instance.
init();
return ( mDocRootPath );
|
public java.lang.String | getInitFilePath()
init();
return ( mInitFilePath );
|
public java.lang.String | getInstanceUser()
init();
return ServerManager.instance().getInstanceUser(this);
|
public java.lang.String | getInstancesRoot()Returns the path where entire data/config etc. of this instance
is stored on the disk.
return (mInstancesRoot);
|
public java.lang.String | getJavaWebStartPath()
init();
return mJavaWebStartDirPath;
|
private long | getLastModifiedFromTSFile(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.String | getLibClassesPath()Returns the path to the instance lib/classes directory.
init();
return ( mLibClassesPath );
|
public java.lang.String | getLibPath()Returns the path to the instance lib directory.
init();
return ( mLibPath );
|
private long | getManualChangeTime()
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.String | getModuleBackupRepositoryPath()Returns the absolute path for location where all the deployed
standalone module backups are stored for this Server Instance.
init();
return ( mModuleBackupRepositoryPath );
|
public ModuleEnvironment | getModuleEnvironment(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.String | getModuleGeneratedXMLPath()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.String | getModuleHttpSessionStorePath()
init();
return ( mModuleHttpSessionStorePath );
|
public java.lang.String | getModulePassivatedEjbPath()
init();
return ( mModulePassivatedEjbPath );
|
public java.lang.String | getModuleRepositoryPath()Returns the absolute path for location where all the deployed
standalone modules are stored for this Server Instance.
init();
return ( mModuleRepositoryPath );
|
public java.lang.String | getModuleStubPath()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.String | getName()A method that returns the logical name of this Server Instance.
return ( mLogicalName );
|
public java.lang.String | getObjectFilePath()
init();
return ( mObjectFilePath );
|
public java.lang.String | getRealmsKeyFilePath()
init();
return ( mRealmsKeyFilePath );
|
public java.lang.String | getSecurityPasswordsFilePath()
init();
return ( mSecurityPasswordsFilePath );
|
public java.lang.String | getStopCommandPath()
init();
return ( mStopCommandPath );
|
public static java.lang.String | getTemplatesDirPath()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.String | getTimeStampFileName(java.lang.String fullName)
return fullName + ".timestamp";
|
public java.lang.String | getWebModuleCompileJspPath()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 boolean | hasBakMimeChanged()
return false;
|
public boolean | hasBakupVirtualServerConfChanged()
return false;
|
public boolean | hasCGIConfigFilesChanged()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 boolean | hasHotChanged()
return false;
|
public boolean | hasHotInitChanged()
return false;
|
public boolean | hasHotMimeChanged()
return false;
|
public boolean | hasHotObjectChanged()
return false;
|
public boolean | hasHotRealmsKeyChanged()
return false;
|
public boolean | hasHotVirtualServerConfChanged()
return false;
|
public boolean | hasHotXmlChanged()
return false;
|
public boolean | hasInitOrObjConfFileChanged()Has init.conf or obj.conf file changed.
return false;
|
public boolean | hasMimeConfFileChanged()Has configured mime file(s) changed.
return false;
|
private boolean | hasOnlyHotXmlChanged()
return false;
|
public boolean | hasRealmsKeyConfFileChanged()Has Realms keyfile changed.
return false;
|
private boolean | hasVirtualServerConfChanged(com.sun.enterprise.config.ConfigContext context, boolean isHot)
return false;
|
public boolean | hasVirtualServerConfFileChanged()
return false;
|
private void | init()
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 boolean | isChownNeeded(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 boolean | isIASOwned(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 boolean | isIASOwned(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.String | resolvePath(java.lang.String unresolved)
if (mPathResolver != null) {
return mPathResolver.resolve(unresolved);
}
return unresolved;
|
public boolean | restartRequired()
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 void | saveTimeStamp(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 long | saveTimeStamp(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.String | toString()
init();
return ObjectAnalyzer.toString(this);
|
private void | useManualAllMimeFileChanges()
|
public void | useManualConfigChanges()
|
private void | useManualInitFileChanges()
|
private void | useManualObjectFileChanges()
|
private void | useManualRealmsKeyFileChanges()
|
public void | useManualServerXmlChanges()
|
private void | useManualVirtualServerConfFileChanges(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.String | verify()
// 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;
|