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 String getInstalledDir() throws Exception {
053 if (ServerDetector.isGlassfish()) {
054 File file = new File(
055 System.getProperty("catalina.home"), "applications");
056
057 return file.getAbsolutePath();
058 }
059 else {
060 return DeployUtil.getAutoDeployDestDir();
061 }
062 }
063
064 public PluginPackage getInstalledPluginPackage(String context) {
065 return PluginPackageUtil.getInstalledPluginPackage(context);
066 }
067
068 public List<PluginPackage> getInstalledPluginPackages() {
069 return PluginPackageUtil.getInstalledPluginPackages();
070 }
071
072 public boolean isDeployed(String context) {
073 return PluginPackageUtil.isInstalled(context);
074 }
075
076 public void redeploy(String context) throws Exception {
077 if (ServerDetector.isJetty()) {
078 DeployUtil.redeployJetty(context);
079 }
080 else if (ServerDetector.isTomcat()) {
081 DeployUtil.redeployTomcat(context);
082 }
083 }
084
085 public void undeploy(String context) throws Exception {
086 File deployDir = new File(getDeployDir(), context);
087
088 if (!deployDir.exists()) {
089 deployDir = new File(getDeployDir(), context + ".war");
090 }
091
092 DeployUtil.undeploy(ServerDetector.getServerId(), deployDir);
093 }
094
095 }