001    /**
002     * Copyright (c) 2000-2012 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.server.capabilities;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.kernel.util.ServerDetector;
020    
021    import javax.servlet.ServletContext;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     * @author Igor Spasic
026     */
027    public class ServerCapabilitiesUtil {
028    
029            public static void determineServerCapabilities(
030                    ServletContext servletContext) {
031    
032                    ServerCapabilities serverCapabilities = null;
033    
034                    if (ServerDetector.isGlassfish()) {
035                            serverCapabilities = new GlassfishServerCapabilities();
036                    }
037                    else if (ServerDetector.isJetty()) {
038                            serverCapabilities = new JettyServerCapabilities();
039                    }
040                    else if (ServerDetector.isTomcat()) {
041                            serverCapabilities = new TomcatServerCapabilities();
042                    }
043    
044                    if (serverCapabilities == null) {
045                            serverCapabilities = new DefaultServerCapabilities();
046                    }
047    
048                    if (_log.isInfoEnabled()) {
049                            Class<?> clazz = serverCapabilities.getClass();
050    
051                            _log.info("Using " + clazz.getName());
052                    }
053    
054                    try {
055                            serverCapabilities.determine(servletContext);
056                    }
057                    catch (Exception e) {
058                            _log.error("Unable to determine server capabilities", e);
059                    }
060    
061                    ServerDetector.setSupportsHotDeploy(
062                            serverCapabilities.isSupportsHotDeploy());
063            }
064    
065            private static Log _log = LogFactoryUtil.getLog(
066                    ServerCapabilitiesUtil.class);
067    
068    }