001    /**
002     * Copyright (c) 2000-present 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.server.capabilities;
016    
017    import com.liferay.portal.server.DeepNamedValueScanner;
018    
019    import javax.servlet.ServletContext;
020    
021    /**
022     * @author Igor Spasic
023     */
024    public class JBossServerCapabilities implements ServerCapabilities {
025    
026            @Override
027            public void determine(ServletContext servletContext) throws Exception {
028                    determineSupportsHotDeploy(servletContext);
029            }
030    
031            @Override
032            public boolean isSupportsHotDeploy() {
033                    return _supportsHotDeploy;
034            }
035    
036            protected void determineSupportsHotDeploy(ServletContext servletContext)
037                    throws Exception {
038    
039                    DeepNamedValueScanner deepNamedValueScanner = new DeepNamedValueScanner(
040                            "scanEnabled", true);
041    
042                    deepNamedValueScanner.setExcludedClassNames(
043                            "ChainedInterceptorFactory", "TagAttributeInfo", ".jandex.",
044                            ".vfs.");
045                    deepNamedValueScanner.setExcludedNames("serialversion");
046                    deepNamedValueScanner.setIncludedClassNames(
047                            "org.apache.", "org.jboss.");
048                    deepNamedValueScanner.setVisitArrays(true);
049                    deepNamedValueScanner.setVisitMaps(true);
050    
051                    deepNamedValueScanner.scan(servletContext);
052    
053                    Boolean scanEnabledValue =
054                            (Boolean)deepNamedValueScanner.getMatchedValue();
055    
056                    if (scanEnabledValue == null) {
057                            _supportsHotDeploy = false;
058                    }
059                    else {
060                            _supportsHotDeploy = scanEnabledValue.booleanValue();
061                    }
062            }
063    
064            private boolean _supportsHotDeploy;
065    
066    }