1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.search;
16  
17  import java.util.List;
18  
19  /**
20   * <a href="IndexerRegistryUtil.java.html"><b><i>View Source</i></b></a>
21   *
22   * @author Raymond Augé
23   */
24  public class IndexerRegistryUtil {
25  
26      public static Indexer getIndexer(Class<?> classObj) {
27          return getIndexerRegistry().getIndexer(classObj.getName());
28      }
29  
30      public static Indexer getIndexer(String className) {
31          return getIndexerRegistry().getIndexer(className);
32      }
33  
34      public static IndexerRegistry getIndexerRegistry() {
35          return _indexerRegistry;
36      }
37  
38      public static List<Indexer> getIndexers() {
39          return getIndexerRegistry().getIndexers();
40      }
41  
42      public static void register(Indexer indexer) {
43          for (String className : indexer.getClassNames()) {
44              register(className, indexer);
45          }
46  
47          register(indexer.getClass().getName(), indexer);
48      }
49  
50      public static void register(
51          String className, Indexer indexer) {
52  
53          getIndexerRegistry().register(className, indexer);
54      }
55  
56      public static void unregister(Indexer indexer) {
57          for (String className : indexer.getClassNames()) {
58              unregister(className);
59          }
60  
61          unregister(indexer.getClass().getName());
62      }
63  
64      public static void unregister(String className) {
65          getIndexerRegistry().unregister(className);
66      }
67  
68      public void setIndexerRegistry(IndexerRegistry indexerRegistry) {
69          _indexerRegistry = indexerRegistry;
70      }
71  
72      private static IndexerRegistry _indexerRegistry;
73  
74  }