001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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    }