001    /**
002     * Copyright (c) 2000-2010 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.search;
016    
017    import java.util.List;
018    
019    /**
020     * @author Raymond Augé
021     */
022    public class IndexerRegistryUtil {
023    
024            public static Indexer getIndexer(Class<?> classObj) {
025                    return getIndexerRegistry().getIndexer(classObj.getName());
026            }
027    
028            public static Indexer getIndexer(String className) {
029                    return getIndexerRegistry().getIndexer(className);
030            }
031    
032            public static IndexerRegistry getIndexerRegistry() {
033                    return _indexerRegistry;
034            }
035    
036            public static List<Indexer> getIndexers() {
037                    return getIndexerRegistry().getIndexers();
038            }
039    
040            public static void register(Indexer indexer) {
041                    for (String className : indexer.getClassNames()) {
042                            register(className, indexer);
043                    }
044    
045                    register(indexer.getClass().getName(), indexer);
046            }
047    
048            public static void register(
049                    String className, Indexer indexer) {
050    
051                    getIndexerRegistry().register(className, indexer);
052            }
053    
054            public static void unregister(Indexer indexer) {
055                    for (String className : indexer.getClassNames()) {
056                            unregister(className);
057                    }
058    
059                    unregister(indexer.getClass().getName());
060            }
061    
062            public static void unregister(String className) {
063                    getIndexerRegistry().unregister(className);
064            }
065    
066            public void setIndexerRegistry(IndexerRegistry indexerRegistry) {
067                    _indexerRegistry = indexerRegistry;
068            }
069    
070            private static IndexerRegistry _indexerRegistry;
071    
072    }