001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.tools.deploy;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.model.Plugin;
019    import com.liferay.portal.util.InitUtil;
020    
021    import java.io.File;
022    
023    import java.util.ArrayList;
024    import java.util.List;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class LayoutTemplateDeployer extends BaseDeployer {
030    
031            public static void main(String[] args) {
032                    InitUtil.initWithSpring();
033    
034                    List<String> wars = new ArrayList<String>();
035                    List<String> jars = new ArrayList<String>();
036    
037                    for (String arg : args) {
038                            if (arg.endsWith(".war")) {
039                                    wars.add(arg);
040                            }
041                            else if (arg.endsWith(".jar")) {
042                                    jars.add(arg);
043                            }
044                    }
045    
046                    new LayoutTemplateDeployer(wars, jars);
047            }
048    
049            public LayoutTemplateDeployer() {
050            }
051    
052            public LayoutTemplateDeployer(List<String> wars, List<String> jars) {
053                    super(wars, jars);
054            }
055    
056            @Override
057            public String getExtraContent(
058                            double webXmlVersion, File srcFile, String displayName)
059                    throws Exception {
060    
061                    StringBundler sb = new StringBundler(7);
062    
063                    String extraContent = super.getExtraContent(
064                            webXmlVersion, srcFile, displayName);
065    
066                    sb.append(extraContent);
067    
068                    sb.append("<listener>");
069                    sb.append("<listener-class>");
070                    sb.append("com.liferay.portal.kernel.servlet.");
071                    sb.append("LayoutTemplateContextListener");
072                    sb.append("</listener-class>");
073                    sb.append("</listener>");
074    
075                    return sb.toString();
076            }
077    
078            @Override
079            public String getPluginType() {
080                    return Plugin.TYPE_LAYOUT_TEMPLATE;
081            }
082    
083    }