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