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(getSuccessMessage(file));
051 }
052
053 return code;
054 }
055
056 @Override
057 public boolean isDeployable(AutoDeploymentContext autoDeploymentContext)
058 throws AutoDeployException {
059
060 return isDeployable(autoDeploymentContext.getFile());
061 }
062
063 protected abstract AutoDeployer buildAutoDeployer()
064 throws AutoDeployException;
065
066 protected abstract String getPluginPathInfoMessage(File file);
067
068 protected abstract String getSuccessMessage(File file);
069
070 protected abstract boolean isDeployable(File file)
071 throws AutoDeployException;
072
073 private static final Log _log = LogFactoryUtil.getLog(
074 BaseAutoDeployListener.class);
075
076 }