1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.deploy.auto;
16  
17  import com.liferay.portal.deploy.DeployUtil;
18  import com.liferay.portal.kernel.deploy.auto.AutoDeployException;
19  import com.liferay.portal.kernel.log.Log;
20  import com.liferay.portal.kernel.log.LogFactoryUtil;
21  import com.liferay.portal.kernel.util.PropsKeys;
22  import com.liferay.portal.kernel.util.ServerDetector;
23  import com.liferay.portal.kernel.util.StringPool;
24  import com.liferay.portal.tools.deploy.PortletDeployer;
25  import com.liferay.portal.util.PrefsPropsUtil;
26  import com.liferay.portal.util.PropsValues;
27  
28  import java.util.ArrayList;
29  import java.util.List;
30  
31  /**
32   * <a href="PortletAutoDeployer.java.html"><b><i>View Source</i></b></a>
33   *
34   * @author Ivica Cardic
35   * @author Brian Wing Shun Chan
36   */
37  public class PortletAutoDeployer
38      extends PortletDeployer implements AutoDeployer {
39  
40      public PortletAutoDeployer() {
41          try {
42              baseDir = PrefsPropsUtil.getString(
43                  PropsKeys.AUTO_DEPLOY_DEPLOY_DIR,
44                  PropsValues.AUTO_DEPLOY_DEPLOY_DIR);
45              destDir = DeployUtil.getAutoDeployDestDir();
46              appServerType = ServerDetector.getServerId();
47              auiTaglibDTD = DeployUtil.getResourcePath("liferay-aui.tld");
48              portletTaglibDTD = DeployUtil.getResourcePath(
49                  "liferay-portlet.tld");
50              portletExtTaglibDTD = DeployUtil.getResourcePath(
51                  "liferay-portlet-ext.tld");
52              securityTaglibDTD = DeployUtil.getResourcePath(
53                  "liferay-security.tld");
54              themeTaglibDTD = DeployUtil.getResourcePath("liferay-theme.tld");
55              uiTaglibDTD = DeployUtil.getResourcePath("liferay-ui.tld");
56              utilTaglibDTD = DeployUtil.getResourcePath("liferay-util.tld");
57              unpackWar = PrefsPropsUtil.getBoolean(
58                  PropsKeys.AUTO_DEPLOY_UNPACK_WAR,
59                  PropsValues.AUTO_DEPLOY_UNPACK_WAR);
60              filePattern = StringPool.BLANK;
61              jbossPrefix = PrefsPropsUtil.getString(
62                  PropsKeys.AUTO_DEPLOY_JBOSS_PREFIX,
63                  PropsValues.AUTO_DEPLOY_JBOSS_PREFIX);
64              tomcatLibDir = PrefsPropsUtil.getString(
65                  PropsKeys.AUTO_DEPLOY_TOMCAT_LIB_DIR,
66                  PropsValues.AUTO_DEPLOY_TOMCAT_LIB_DIR);
67  
68              List<String> jars = new ArrayList<String>();
69  
70              addExtJar(jars, "ext-util-bridges.jar");
71              addExtJar(jars, "ext-util-java.jar");
72              addExtJar(jars, "ext-util-taglib.jar");
73              addRequiredJar(jars, "util-bridges.jar");
74              addRequiredJar(jars, "util-java.jar");
75              addRequiredJar(jars, "util-taglib.jar");
76  
77              this.jars = jars;
78  
79              checkArguments();
80          }
81          catch (Exception e) {
82              _log.error(e);
83          }
84      }
85  
86      public void autoDeploy(String file) throws AutoDeployException {
87          List<String> wars = new ArrayList<String>();
88  
89          wars.add(file);
90  
91          this.wars = wars;
92  
93          try {
94              deploy();
95          }
96          catch (Exception e) {
97              throw new AutoDeployException(e);
98          }
99      }
100 
101     private static Log _log = LogFactoryUtil.getLog(PortletAutoDeployer.class);
102 
103 }