1 23 24 27 28 package com.sun.enterprise.deployment.autodeploy; 29 30 import java.util.logging.Logger ; 31 import java.util.logging.Level ; 32 import com.sun.enterprise.util.i18n.StringManager; 33 import com.sun.enterprise.admin.common.constant.AdminConstants; 34 import java.io.File ; 35 36 import com.sun.enterprise.config.serverbeans.Server; 37 import com.sun.enterprise.config.serverbeans.Domain; 38 import com.sun.enterprise.config.serverbeans.Configs; 39 import com.sun.enterprise.config.serverbeans.Servers; 40 import com.sun.enterprise.config.serverbeans.Config; 42 import com.sun.enterprise.server.ServerContext; 44 import com.sun.enterprise.config.ConfigContext; 45 import com.sun.enterprise.config.ConfigException; 46 import com.sun.enterprise.instance.InstanceEnvironment; 47 import com.sun.enterprise.config.serverbeans.AdminService; 48 import com.sun.enterprise.config.serverbeans.DasConfig; 49 import com.sun.enterprise.config.serverbeans.ServerBeansFactory; 50 import com.sun.enterprise.config.serverbeans.PropertyResolver; 51 52 59 public class AutoDeployControllerFactroyImpl implements AutoDeployControllerFactroy { 60 61 private static final Logger sLogger=AutoDeployControllerImpl.sLogger; 62 private static StringManager localStrings = 63 StringManager.getManager( AutoDeployControllerFactroyImpl.class ); 64 65 66 77 public AutoDeployController createAutoDeployController(ServerContext context) throws AutoDeploymentException { 78 79 ConfigContext confContext = context.getConfigContext(); 80 AutoDeployController autoDeployController = null; 81 String targetConfigurationName = null; 82 Domain domain = null; 83 84 String autoDeployDir=null ; 85 String sourcedir=null; 86 String strPollingInterval =null ; 87 long pollingInterval; 88 boolean verifyEnabled=false ; 89 boolean preJspCompilation=false ; 90 91 DasConfig dasConfig = null; 92 try { 93 dasConfig = ServerBeansFactory.getDasConfigBean(confContext); 98 }catch (Exception ce){ 99 sLogger.log(Level.SEVERE, "enterprise.deployment.backend.autoDeploymentStartFailure"); 100 throw new AutoDeploymentException("Failed to start autodeploy", ce); 101 } 102 103 111 112 113 if(dasConfig != null) { 114 boolean autodeployEnabled=dasConfig.isAutodeployEnabled(); 115 if(autodeployEnabled){ 116 autoDeployDir=dasConfig.getAutodeployDir() ; 117 if(autoDeployDir != null) { 118 try { 119 autoDeployDir = new PropertyResolver(confContext, 120 context.getInstanceName()). 121 resolve(autoDeployDir); 122 autoDeployDir=autoDeployDir.trim(); 123 } catch (ConfigException ce) { 124 autoDeployDir = null; 126 } 127 } 128 if(autoDeployDir == null || "".equals(autoDeployDir)) { 129 autoDeployDir = AutoDeployConstants.DEFAULT_AUTODEPLOY_DIR; 131 sourcedir= context.getInstanceEnvironment().getAutoDeployDirPath()+File.separator+autoDeployDir; 132 String msg = localStrings.getString("enterprise.deployment.autodeploy.invalid_source_dir_shifting_to_default",sourcedir); 133 sLogger.log(Level.WARNING, msg); 134 } else if((new File (autoDeployDir)).isAbsolute()) { 135 sourcedir=autoDeployDir; 137 } else { 138 sourcedir= context.getInstanceEnvironment().getAutoDeployDirPath()+File.separator+autoDeployDir; 140 } 141 strPollingInterval = dasConfig.getAutodeployPollingIntervalInSeconds(); 142 verifyEnabled=dasConfig.isAutodeployVerifierEnabled() ; 143 preJspCompilation=dasConfig.isAutodeployJspPrecompilationEnabled() ; 144 try { 145 try { 146 pollingInterval= Long.parseLong(strPollingInterval) ; 147 if(pollingInterval < AutoDeployConstants.MIN_POOLING_INTERVAL) { 148 String msg = localStrings.getString("enterprise.deployment.autodeploy.invalid_pooling_interval_shifting_to_default",strPollingInterval,AutoDeployConstants.MIN_POOLING_INTERVAL+"",AutoDeployConstants.DEFAULT_POLLING_INTERVAL+""); 149 sLogger.log(Level.WARNING, msg); 150 pollingInterval = AutoDeployConstants.DEFAULT_POLLING_INTERVAL; 151 } 152 } catch (NumberFormatException ne) { 153 String msg = localStrings.getString("enterprise.deployment.autodeploy.invalid_pooling_interval_shifting_to_default",strPollingInterval,AutoDeployConstants.MIN_POOLING_INTERVAL+"",AutoDeployConstants.DEFAULT_POLLING_INTERVAL+""); 154 sLogger.log(Level.WARNING, msg); 155 pollingInterval = AutoDeployConstants.DEFAULT_POLLING_INTERVAL; 157 } 158 autoDeployController = new AutoDeployControllerImpl(sourcedir,pollingInterval); 159 autoDeployController.setVerify(verifyEnabled); 160 autoDeployController.setPreJspCompilation(preJspCompilation); 161 } catch(AutoDeploymentException ae) { 162 sLogger.log(Level.SEVERE, "enterprise.deployment.backend.autoDeploymentStartFailure"); 163 throw ae; 164 165 } 166 } } 169 170 return autoDeployController; 171 172 } 173 174 217 218 } 219 | Popular Tags |