001    /**
002     * Copyright (c) 2000-2011 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.util.InitUtil;
019    
020    import java.io.File;
021    
022    import java.util.ArrayList;
023    import java.util.List;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class WebDeployer extends BaseDeployer {
029    
030            public static void main(String[] args) {
031                    InitUtil.initWithSpring();
032    
033                    List<String> wars = new ArrayList<String>();
034                    List<String> jars = new ArrayList<String>();
035    
036                    for (String arg : args) {
037                            if (arg.endsWith(".war")) {
038                                    wars.add(arg);
039                            }
040                            else if (arg.endsWith(".jar")) {
041                                    jars.add(arg);
042                            }
043                    }
044    
045                    new WebDeployer(wars, jars);
046            }
047    
048            protected WebDeployer() {
049            }
050    
051            protected WebDeployer(List<String> wars, List<String> jars) {
052                    super(wars, jars);
053            }
054    
055            protected String getExtraContent(
056                            double webXmlVersion, File srcFile, String displayName)
057                    throws Exception {
058    
059                    StringBundler sb = new StringBundler(6);
060    
061                    String extraContent = super.getExtraContent(
062                            webXmlVersion, srcFile, displayName);
063    
064                    sb.append(extraContent);
065    
066                    // WebContextListener
067    
068                    sb.append("<listener>");
069                    sb.append("<listener-class>");
070                    sb.append("com.liferay.portal.kernel.servlet.WebContextListener");
071                    sb.append("</listener-class>");
072                    sb.append("</listener>");
073    
074                    return sb.toString();
075            }
076    
077    }