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.LayoutTemplateDeployer;
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="LayoutTemplateAutoDeployer.java.html"><b><i>View Source</i></b></a>
33   *
34   * @author Ivica Cardic
35   * @author Brian Wing Shun Chan
36   */
37  public class LayoutTemplateAutoDeployer
38      extends LayoutTemplateDeployer implements AutoDeployer {
39  
40      public LayoutTemplateAutoDeployer() {
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              unpackWar = PrefsPropsUtil.getBoolean(
48                  PropsKeys.AUTO_DEPLOY_UNPACK_WAR,
49                  PropsValues.AUTO_DEPLOY_UNPACK_WAR);
50              filePattern = StringPool.BLANK;
51              jbossPrefix = PrefsPropsUtil.getString(
52                  PropsKeys.AUTO_DEPLOY_JBOSS_PREFIX,
53                  PropsValues.AUTO_DEPLOY_JBOSS_PREFIX);
54              unpackWar = PrefsPropsUtil.getBoolean(
55                  PropsKeys.AUTO_DEPLOY_UNPACK_WAR,
56                  PropsValues.AUTO_DEPLOY_UNPACK_WAR);
57  
58              List<String> jars = new ArrayList<String>();
59  
60              this.jars = jars;
61  
62              checkArguments();
63          }
64          catch (Exception e) {
65              _log.error(e);
66          }
67      }
68  
69      public void autoDeploy(String file) throws AutoDeployException {
70          List<String> wars = new ArrayList<String>();
71  
72          wars.add(file);
73  
74          this.wars = wars;
75  
76          try {
77              deploy();
78          }
79          catch (Exception e) {
80              throw new AutoDeployException(e);
81          }
82      }
83  
84      private static Log _log = LogFactoryUtil.getLog(
85          LayoutTemplateAutoDeployer.class);
86  
87  }