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.kernel.search;
016    
017    import com.liferay.portal.kernel.util.ProxyFactory;
018    
019    import java.util.Set;
020    
021    /**
022     * @author Raymond Aug??
023     */
024    public class IndexerRegistryUtil {
025    
026            public static <T> Indexer<T> getIndexer(Class<T> clazz) {
027                    return getIndexerRegistry().getIndexer(clazz);
028            }
029    
030            public static <T> Indexer<T> getIndexer(String className) {
031                    return getIndexerRegistry().getIndexer(className);
032            }
033    
034            public static IndexerRegistry getIndexerRegistry() {
035                    return _indexerRegistry;
036            }
037    
038            public static Set<Indexer<?>> getIndexers() {
039                    return getIndexerRegistry().getIndexers();
040            }
041    
042            public static <T> Indexer<T> nullSafeGetIndexer(Class<T> clazz) {
043                    return getIndexerRegistry().nullSafeGetIndexer(clazz);
044            }
045    
046            public static <T> Indexer<T> nullSafeGetIndexer(String className) {
047                    return getIndexerRegistry().nullSafeGetIndexer(className);
048            }
049    
050            public static void register(Indexer<?> indexer) {
051                    getIndexerRegistry().register(indexer);
052            }
053    
054            /**
055             * @deprecated As of 7.0.0, replaced by {@link #register(Indexer)}
056             */
057            @Deprecated
058            public static void register(String className, Indexer<?> indexer) {
059                    getIndexerRegistry().register(indexer);
060            }
061    
062            public static void unregister(Indexer<?> indexer) {
063                    getIndexerRegistry().unregister(indexer);
064            }
065    
066            public static void unregister(String className) {
067                    getIndexerRegistry().unregister(className);
068            }
069    
070            private static final IndexerRegistry _indexerRegistry =
071                    ProxyFactory.newServiceTrackedInstance(IndexerRegistry.class);
072    
073    }