Class AutoDeployer
- java.lang.Object
-
- org.glassfish.deployment.autodeploy.AutoDeployer
-
public class AutoDeployer extends Object
Handles the logic of deploying the module/app to the required destination. The destination is specified on the constructor and can be modified by calling setTarget(). The specific directory scanner can be set using setDirectoryScanner, default is AutoDeployDirectoryScanner- Author:
- vikas, tjquinn
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AutoDeployer.AutodeploymentStatus
-
Field Summary
Fields Modifier and Type Field Description static Logger
deplLogger
protected static int
DEPLOY_FAILURE
protected static int
DEPLOY_PENDING
protected static int
DEPLOY_SUCCESS
-
Constructor Summary
Constructors Constructor Description AutoDeployer(String target, String directoryPath, String virtualServer, boolean jspPrecompilationEnabled, boolean verifierEnabled, boolean renameOnSuccess, boolean forceDeploy, boolean enabled, org.glassfish.hk2.api.ServiceLocator serviceLocator)
Creates a new instance of AutoDeployerAutoDeployer(String target, String directoryPath, String virtualServer, boolean jspPrecompilationEnabled, boolean verifierEnabled, org.glassfish.hk2.api.ServiceLocator serviceLocator)
AutoDeployer(String target, String directoryPath, String virtualServer, org.glassfish.hk2.api.ServiceLocator serviceLocator)
Creates a new autodeployer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancel(boolean value)
Set cancel flag, which will ensure that only if there is any current deployment is in process, it will be completed but the deployer will not do any more deployment.protected AutoDeployer.AutodeploymentStatus
deploy(File deployablefile, File autodeployDir)
Deploy any type of module.void
disableRenameOnSuccess()
If an archive is successfully autodeployed, file will not be renamed to archive_deployedvoid
enableRenameOnSuccess()
If an archive is successfully autodeployed will be renamed to archive_deployedstatic String
getNameFromFilePath(File autodeployDir, File filePath)
boolean
isCancelled()
get cancel flag valuevoid
run()
Run through the auto-deployment procedure.void
run(boolean includeSubdir)
void
setDirectory(String directoryPath)
Sets the directory to be scanned by the autodeployer.void
setDirectoryScanner(DirectoryScanner directoryScanner)
set DirectoryScanner which will be used for filtering out deployeble componentvoid
setJspPreCompilation(boolean jspPreCompilation)
Set whether this AutoDeployer should precompile JSPs or not.void
setJspPrecompilationEnabled(boolean setting)
Sets whether or not the precompileJSP option should be requested during autodeployments.void
setServiceLocator(org.glassfish.hk2.api.ServiceLocator serviceLocator)
Sets the serviceLocator for use in creating DeployCommand and UndeployCommand instances.void
setTarget(String target)
set target server where the autual deployment will be donevoid
setVerifierEnabled(boolean verify)
Sets whether descriptor verification should be requested during autodeployments.void
setVerify(boolean verify)
Set whether this AutoDeployer should verify or not.void
undeployAll(File autoDeployDir, boolean includeSubdir)
do undeployment for all deleted applications in autoDeployDir dir.void
waitUntilIdle()
-
-
-
Field Detail
-
deplLogger
public static final Logger deplLogger
-
DEPLOY_SUCCESS
protected static final int DEPLOY_SUCCESS
- See Also:
- Constant Field Values
-
DEPLOY_FAILURE
protected static final int DEPLOY_FAILURE
- See Also:
- Constant Field Values
-
DEPLOY_PENDING
protected static final int DEPLOY_PENDING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AutoDeployer
public AutoDeployer(String target, String directoryPath, String virtualServer, org.glassfish.hk2.api.ServiceLocator serviceLocator) throws AutoDeploymentException
Creates a new autodeployer.- Parameters:
target
- deployment target for autodeployed applicationsdirectoryPath
- directory to be scanned for changesvirtualServer
- the virtual server to which to deploy apps toserviceLocator
- hk2 habitat for injection support- Throws:
AutoDeploymentException
-
AutoDeployer
public AutoDeployer(String target, String directoryPath, String virtualServer, boolean jspPrecompilationEnabled, boolean verifierEnabled, boolean renameOnSuccess, boolean forceDeploy, boolean enabled, org.glassfish.hk2.api.ServiceLocator serviceLocator) throws AutoDeploymentException
Creates a new instance of AutoDeployer- Parameters:
target
- the deployment target for autodeployed applicationsdirectoryPath
- the directory to scanvirtualServer
- the virtual server to deploy tojspPrecompilationEnabled
- whether to precompile JSPsverifierEnabled
- whether to verify applications during deploymentrenameOnSuccess
- rename the file if deployment is successfulforceDeploy
- request that forced deployment occur if the app is already deployedenabled
- whether apps should be enabled upon auto-deploymentserviceLocator
- HK2 serviceLocator for use in instantiating properly-init'd DeployCommand and UndeployCommand- Throws:
AutoDeploymentException
-
AutoDeployer
public AutoDeployer(String target, String directoryPath, String virtualServer, boolean jspPrecompilationEnabled, boolean verifierEnabled, org.glassfish.hk2.api.ServiceLocator serviceLocator) throws AutoDeploymentException
- Throws:
AutoDeploymentException
-
-
Method Detail
-
setServiceLocator
public void setServiceLocator(org.glassfish.hk2.api.ServiceLocator serviceLocator)
Sets the serviceLocator for use in creating DeployCommand and UndeployCommand instances.- Parameters:
serviceLocator
-
-
setJspPrecompilationEnabled
public void setJspPrecompilationEnabled(boolean setting)
Sets whether or not the precompileJSP option should be requested during autodeployments.- Parameters:
setting
- true if JSPs should be precompiled during autodeployments
-
setDirectory
public void setDirectory(String directoryPath) throws AutoDeploymentException
Sets the directory to be scanned by the autodeployer.- Parameters:
directoryPath
- the directory path to scan- Throws:
AutoDeploymentException
-
setVerifierEnabled
public void setVerifierEnabled(boolean verify)
Sets whether descriptor verification should be requested during autodeployments.- Parameters:
verify
- true if verification should occur during autodeployments
-
setDirectoryScanner
public void setDirectoryScanner(DirectoryScanner directoryScanner)
set DirectoryScanner which will be used for filtering out deployeble component- Parameters:
directoryScanner
- the new directory scanner to use
-
setTarget
public void setTarget(String target)
set target server where the autual deployment will be done- Parameters:
target
-
-
disableRenameOnSuccess
public void disableRenameOnSuccess()
If an archive is successfully autodeployed, file will not be renamed to archive_deployed
-
enableRenameOnSuccess
public void enableRenameOnSuccess()
If an archive is successfully autodeployed will be renamed to archive_deployed
-
setVerify
public void setVerify(boolean verify)
Set whether this AutoDeployer should verify or not.- Parameters:
verify
- whether to verify the app during deployment
-
setJspPreCompilation
public void setJspPreCompilation(boolean jspPreCompilation)
Set whether this AutoDeployer should precompile JSPs or not.- Parameters:
jspPreCompilation
- precompilation setting
-
run
public void run()
Run through the auto-deployment procedure.Clients should invoke this method to execute the auto-deployer once with the current configurable settings.
-
run
public void run(boolean includeSubdir)
-
waitUntilIdle
public void waitUntilIdle() throws InterruptedException
- Throws:
InterruptedException
-
undeployAll
public void undeployAll(File autoDeployDir, boolean includeSubdir) throws AutoDeploymentException
do undeployment for all deleted applications in autoDeployDir dir.- Parameters:
autoDeployDir
- the directory to scan for deleted filesincludeSubdir
-- Throws:
AutoDeploymentException
-
cancel
public void cancel(boolean value)
Set cancel flag, which will ensure that only if there is any current deployment is in process, it will be completed but the deployer will not do any more deployment.- Parameters:
value
- the cancel setting
-
isCancelled
public boolean isCancelled()
get cancel flag value- Returns:
-
deploy
protected AutoDeployer.AutodeploymentStatus deploy(File deployablefile, File autodeployDir) throws AutoDeploymentException
Deploy any type of module.- Parameters:
deployablefile
- the file to be deployedautodeployDir
- the directory where the file resides (holdover from earlier impl)- Returns:
- status of the deployment attempt: DEPLOY_SUCCESS, DEPLOY_FAILURE, or DEPLOY_PENDING
- Throws:
AutoDeploymentException
- if any invoked method throws an exception
-
-