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 import com.liferay.portal.security.lang.PortalSecurityManagerThreadLocal;
025
026 import java.io.File;
027
028 import java.util.List;
029 import java.util.Properties;
030
031
036 public class DeployManagerImpl implements DeployManager {
037
038 public void deploy(AutoDeploymentContext autoDeploymentContext)
039 throws Exception {
040
041 List<AutoDeployListener> autoDeployListeners =
042 GlobalStartupAction.getAutoDeployListeners();
043
044 for (AutoDeployListener autoDeployListener : autoDeployListeners) {
045 autoDeployListener.deploy(autoDeploymentContext);
046 }
047 }
048
049 public String getDeployDir() throws Exception {
050 return DeployUtil.getAutoDeployDestDir();
051 }
052
053 public String getInstalledDir() throws Exception {
054 if (ServerDetector.isGlassfish()) {
055 File file = new File(
056 System.getProperty("com.sun.aas.instanceRoot"), "autodeploy");
057
058 return file.getAbsolutePath();
059 }
060
061 boolean enabled = PortalSecurityManagerThreadLocal.isEnabled();
062
063 try {
064 PortalSecurityManagerThreadLocal.setEnabled(false);
065
066 return DeployUtil.getAutoDeployDestDir();
067 }
068 finally {
069 PortalSecurityManagerThreadLocal.setEnabled(enabled);
070 }
071 }
072
073 public PluginPackage getInstalledPluginPackage(String context) {
074 return PluginPackageUtil.getInstalledPluginPackage(context);
075 }
076
077 public List<PluginPackage> getInstalledPluginPackages() {
078 return PluginPackageUtil.getInstalledPluginPackages();
079 }
080
081 public boolean isDeployed(String context) {
082 return PluginPackageUtil.isInstalled(context);
083 }
084
085 public PluginPackage readPluginPackageProperties(
086 String displayName, Properties properties) {
087
088 return PluginPackageUtil.readPluginPackageProperties(
089 displayName, properties);
090 }
091
092 public PluginPackage readPluginPackageXml(String xml) throws Exception {
093 return PluginPackageUtil.readPluginPackageXml(xml);
094 }
095
096 public void redeploy(String context) throws Exception {
097 if (ServerDetector.isJetty()) {
098 DeployUtil.redeployJetty(context);
099 }
100 else if (ServerDetector.isTomcat()) {
101 DeployUtil.redeployTomcat(context);
102 }
103 }
104
105 public void undeploy(String context) throws Exception {
106 File deployDir = new File(getDeployDir(), context);
107
108 DeployUtil.undeploy(ServerDetector.getServerId(), deployDir);
109 }
110
111 }