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.deploy.auto.context.AutoDeploymentContext;
021 import com.liferay.portal.kernel.plugin.PluginPackage;
022 import com.liferay.portal.kernel.util.ServerDetector;
023 import com.liferay.portal.plugin.PluginPackageUtil;
024
025 import java.io.File;
026
027 import java.util.List;
028 import java.util.Properties;
029
030
035 public class DeployManagerImpl implements DeployManager {
036
037 public void deploy(AutoDeploymentContext autoDeploymentContext)
038 throws Exception {
039
040 List<AutoDeployListener> autoDeployListeners =
041 GlobalStartupAction.getAutoDeployListeners();
042
043 for (AutoDeployListener autoDeployListener : autoDeployListeners) {
044 autoDeployListener.deploy(autoDeploymentContext);
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("com.sun.aas.instanceRoot"), "autodeploy");
056
057 return file.getAbsolutePath();
058 }
059
060 return DeployUtil.getAutoDeployDestDir();
061 }
062
063 public PluginPackage getInstalledPluginPackage(String context) {
064 return PluginPackageUtil.getInstalledPluginPackage(context);
065 }
066
067 public List<PluginPackage> getInstalledPluginPackages() {
068 return PluginPackageUtil.getInstalledPluginPackages();
069 }
070
071 public boolean isDeployed(String context) {
072 return PluginPackageUtil.isInstalled(context);
073 }
074
075 public PluginPackage readPluginPackageProperties(
076 String displayName, Properties properties) {
077
078 return PluginPackageUtil.readPluginPackageProperties(
079 displayName, properties);
080 }
081
082 public PluginPackage readPluginPackageXml(String xml) throws Exception {
083 return PluginPackageUtil.readPluginPackageXml(xml);
084 }
085
086 public void redeploy(String context) throws Exception {
087 if (ServerDetector.isJetty()) {
088 DeployUtil.redeployJetty(context);
089 }
090 else if (ServerDetector.isTomcat()) {
091 DeployUtil.redeployTomcat(context);
092 }
093 }
094
095 public void undeploy(String context) throws Exception {
096 File deployDir = new File(getDeployDir(), context);
097
098 if (!deployDir.exists()) {
099 deployDir = new File(getDeployDir(), context + ".war");
100 }
101
102 DeployUtil.undeploy(ServerDetector.getServerId(), deployDir);
103 }
104
105 }