001    /**
002     * Copyright (c) 2000-2013 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.kernel.deploy.hot;
016    
017    import com.liferay.portal.kernel.util.AutoResetThreadLocal;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.PropsKeys;
020    import com.liferay.portal.kernel.util.PropsUtil;
021    
022    /**
023     * @author Miguel Pastor
024     * @author Raymond Aug??
025     */
026    public class DependencyManagementThreadLocal {
027    
028            public static Boolean isEnabled() {
029                    return _enabled.get();
030            }
031    
032            public static void setEnabled(boolean enabled) {
033                    _enabled.set(enabled);
034            }
035    
036            private static ThreadLocal<Boolean> _enabled;
037    
038            static {
039                    if (GetterUtil.getBoolean(
040                                    PropsUtil.get(
041                                            PropsKeys.HOT_DEPLOY_DEPENDENCY_MANAGEMENT_ENABLED),
042                                    true)) {
043    
044                            _enabled = new AutoResetThreadLocal<Boolean>(
045                                    DependencyManagementThreadLocal.class + ".enabled", true);
046                    }
047                    else {
048                            _enabled = new ThreadLocal<Boolean>() {
049    
050                                    @Override
051                                    public Boolean get() {
052                                            return Boolean.FALSE;
053                                    }
054    
055                            };
056                    }
057            }
058    
059    }