001
014
015 package com.liferay.portal.kernel.deploy.auto;
016
017 import com.liferay.portal.kernel.deploy.auto.context.AutoDeploymentContext;
018 import com.liferay.portal.kernel.log.Log;
019 import com.liferay.portal.kernel.log.LogFactoryUtil;
020
021 import java.io.File;
022
023
029 public abstract class BaseAutoDeployListener implements AutoDeployListener {
030
031 @Override
032 public final int deploy(AutoDeploymentContext autoDeploymentContext)
033 throws AutoDeployException {
034
035 File file = autoDeploymentContext.getFile();
036
037 if (_log.isDebugEnabled()) {
038 _log.debug("Invoking deploy for " + file.getPath());
039 }
040
041 if (_log.isInfoEnabled()) {
042 _log.info(getPluginPathInfoMessage(file));
043 }
044
045 AutoDeployer autoDeployer = buildAutoDeployer();
046
047 int code = autoDeployer.autoDeploy(autoDeploymentContext);
048
049 if ((code == AutoDeployer.CODE_DEFAULT) && _log.isInfoEnabled()) {
050 _log.info(
051 getSuccessMessage(file) +
052 ". Deployment will start in a few seconds.");
053 }
054
055 return code;
056 }
057
058 @Override
059 public boolean isDeployable(AutoDeploymentContext autoDeploymentContext)
060 throws AutoDeployException {
061
062 return isDeployable(autoDeploymentContext.getFile());
063 }
064
065 protected abstract AutoDeployer buildAutoDeployer()
066 throws AutoDeployException;
067
068 protected abstract String getPluginPathInfoMessage(File file);
069
070 protected abstract String getSuccessMessage(File file);
071
072 protected abstract boolean isDeployable(File file)
073 throws AutoDeployException;
074
075 private static final Log _log = LogFactoryUtil.getLog(
076 BaseAutoDeployListener.class);
077
078 }