001
014
015 package com.liferay.portal.deploy;
016
017 import com.liferay.portal.events.GlobalStartupAction;
018 import com.liferay.portal.kernel.deploy.DeployManager;
019 import com.liferay.portal.kernel.deploy.auto.AutoDeployListener;
020 import com.liferay.portal.kernel.plugin.PluginPackage;
021 import com.liferay.portal.kernel.util.ServerDetector;
022 import com.liferay.portal.plugin.PluginPackageUtil;
023
024 import java.io.File;
025
026 import java.util.List;
027
028
033 public class DeployManagerImpl implements DeployManager {
034
035 public void deploy(File file) throws Exception {
036 deploy(file, null);
037 }
038
039 public void deploy(File file, String context) throws Exception {
040 List<AutoDeployListener> autoDeployListeners =
041 GlobalStartupAction.getAutoDeployListeners();
042
043 for (AutoDeployListener autoDeployListener : autoDeployListeners) {
044 autoDeployListener.deploy(file, context);
045 }
046 }
047
048 public String getDeployDir() throws Exception {
049 return DeployUtil.getAutoDeployDestDir();
050 }
051
052 public PluginPackage getInstalledPluginPackage(String context) {
053 return PluginPackageUtil.getInstalledPluginPackage(context);
054 }
055
056 public List<PluginPackage> getInstalledPluginPackages() {
057 return PluginPackageUtil.getInstalledPluginPackages();
058 }
059
060 public boolean isDeployed(String context) {
061 return PluginPackageUtil.isInstalled(context);
062 }
063
064 public void redeploy(String context) throws Exception {
065 if (ServerDetector.isJetty()) {
066 DeployUtil.redeployJetty(context);
067 }
068 else if (ServerDetector.isTomcat()) {
069 DeployUtil.redeployTomcat(context);
070 }
071 }
072
073 public void undeploy(String context) throws Exception {
074 File deployDir = new File(getDeployDir(), context);
075
076 if (!deployDir.exists()) {
077 deployDir = new File(getDeployDir(), context + ".war");
078 }
079
080 DeployUtil.undeploy(ServerDetector.getServerId(), deployDir);
081 }
082
083 }