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.util;
016    
017    import java.util.Arrays;
018    
019    /**
020     * @author Shuyang Zhou
021     */
022    public class ThreadLocalDistributorRegistry {
023    
024            public static ThreadLocalDistributor[] getThreadLocalDistributors() {
025                    return _threadLocalDistributors;
026            }
027    
028            protected static int addThreadLocalDistributor(
029                    ThreadLocalDistributor threadLocalDistributor) {
030    
031                    int newLength = _threadLocalDistributors.length + 1;
032    
033                    ThreadLocalDistributor[] threadLocalDistributors = Arrays.copyOf(
034                            _threadLocalDistributors, newLength);
035    
036                    threadLocalDistributors[newLength - 1] = threadLocalDistributor;
037    
038                    _threadLocalDistributors = threadLocalDistributors;
039    
040                    return newLength - 1;
041            }
042    
043            protected static ThreadLocalDistributor getThreadLocalDistributor(
044                    int index) {
045    
046                    return _threadLocalDistributors[index];
047            }
048    
049            private static ThreadLocalDistributor[] _threadLocalDistributors =
050                    new ThreadLocalDistributor[0];
051    
052    }