public AutoDeployController | createAutoDeployController(com.sun.enterprise.server.ServerContext context)create a instance of autodeploycontroller, depending upon the Servercontext passed
If autodeploy is enabled in domain.xml return a new instance else return null.
If autodeploydir is null/empty.-change to default with appropriate log message .
If autodeploydir is invalid(not a directory/not exit/not have read-write permission
available) continue the thread, with appropriate log message.
ALso both absolute and relative paths for autodeploy-dir are handled.
If autodeploy-polling-interval is null/empty/invalid/ less than AutoDeployConstants.DEFAULT_POLLING_INTERVAL
- change to default with appropriate log message
ConfigContext confContext = context.getConfigContext();
AutoDeployController autoDeployController = null;
String targetConfigurationName = null;
Domain domain = null;
String autoDeployDir=null ;
String sourcedir=null;
String strPollingInterval =null ;
long pollingInterval;
boolean verifyEnabled=false ;
boolean preJspCompilation=false ;
DasConfig dasConfig = null;
try {
//domain = (Domain)confContext.getRootConfigBean();
//Config config = ServerBeansFactory.getConfigBean(confContext);
//if(config != null)
// as = config.getAdminService();
dasConfig = ServerBeansFactory.getDasConfigBean(confContext);
}catch (Exception ce){
sLogger.log(Level.SEVERE, "enterprise.deployment.backend.autoDeploymentStartFailure");
throw new AutoDeploymentException("Failed to start autodeploy", ce);
}
// targetConfigurationName= getTargetConfigName(domain);
//read target configuration
/* if(targetConfigurationName !=null && !targetConfigurationName.trim().equals("")){
Config config = domain.getConfigs().getConfigByName(targetConfigurationName);
if(config !=null){
//get appconfig specific to targetConfigurationName
//ApplicationConfig appConfig= config.getApplicationConfig();
*/
if(dasConfig != null) {
boolean autodeployEnabled=dasConfig.isAutodeployEnabled();
if(autodeployEnabled){
autoDeployDir=dasConfig.getAutodeployDir() ;
if(autoDeployDir != null) {
try {
autoDeployDir = new PropertyResolver(confContext,
context.getInstanceName()).
resolve(autoDeployDir);
autoDeployDir=autoDeployDir.trim();
} catch (ConfigException ce) {
//log
autoDeployDir = null;
}
}
if(autoDeployDir == null || "".equals(autoDeployDir)) {
//empty path so putting default
autoDeployDir = AutoDeployConstants.DEFAULT_AUTODEPLOY_DIR;
sourcedir= context.getInstanceEnvironment().getAutoDeployDirPath()+File.separator+autoDeployDir;
String msg = localStrings.getString("enterprise.deployment.autodeploy.invalid_source_dir_shifting_to_default",sourcedir);
sLogger.log(Level.WARNING, msg);
} else if((new File(autoDeployDir)).isAbsolute()) {
//absolute path
sourcedir=autoDeployDir;
} else {
//relative path
sourcedir= context.getInstanceEnvironment().getAutoDeployDirPath()+File.separator+autoDeployDir;
}
strPollingInterval = dasConfig.getAutodeployPollingIntervalInSeconds();
verifyEnabled=dasConfig.isAutodeployVerifierEnabled() ;
preJspCompilation=dasConfig.isAutodeployJspPrecompilationEnabled() ;
try {
try {
pollingInterval= Long.parseLong(strPollingInterval) ;
if(pollingInterval < AutoDeployConstants.MIN_POOLING_INTERVAL) {
String msg = localStrings.getString("enterprise.deployment.autodeploy.invalid_pooling_interval_shifting_to_default",strPollingInterval,AutoDeployConstants.MIN_POOLING_INTERVAL+"",AutoDeployConstants.DEFAULT_POLLING_INTERVAL+"");
sLogger.log(Level.WARNING, msg);
pollingInterval = AutoDeployConstants.DEFAULT_POLLING_INTERVAL;
}
} catch (NumberFormatException ne) {
String msg = localStrings.getString("enterprise.deployment.autodeploy.invalid_pooling_interval_shifting_to_default",strPollingInterval,AutoDeployConstants.MIN_POOLING_INTERVAL+"",AutoDeployConstants.DEFAULT_POLLING_INTERVAL+"");
sLogger.log(Level.WARNING, msg);
// throw new AutoDeploymentException(ne);
pollingInterval = AutoDeployConstants.DEFAULT_POLLING_INTERVAL;
}
autoDeployController = new AutoDeployControllerImpl(sourcedir,pollingInterval);
autoDeployController.setVerify(verifyEnabled);
autoDeployController.setPreJspCompilation(preJspCompilation);
} catch(AutoDeploymentException ae) {
sLogger.log(Level.SEVERE, "enterprise.deployment.backend.autoDeploymentStartFailure");
throw ae;
}
// }
}//END if(config !=null)
}
return autoDeployController;
|