001    /**
002     * Copyright (c) 2000-2013 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.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    }