1 package org.kuali.ole.docstore.service;
2
3 import org.kuali.ole.docstore.discovery.service.AdminService;
4 import org.kuali.ole.docstore.discovery.service.AdminServiceImpl;
5 import org.kuali.ole.docstore.indexer.solr.IndexerService;
6 import org.kuali.ole.docstore.indexer.solr.WorkBibDocumentIndexer;
7 import org.kuali.ole.solr.DummyAdminService;
8 import org.kuali.ole.solr.DummyIndexerServiceImpl;
9 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory;
11
12
13
14
15
16
17 public class ServiceLocator {
18 private static Boolean OLE_DOCSTORE_USE_DISCOVERY = null;
19 private static IndexerService indexerService = WorkBibDocumentIndexer.getInstance();
20 private static IndexerService dummyIndexerService = DummyIndexerServiceImpl.getInstance();
21 private static final Logger LOG = LoggerFactory.getLogger(ServiceLocator.class);
22 private static AdminService adminService = AdminServiceImpl.getInstance();
23 private static AdminService adminServiceDummy = new DummyAdminService();
24
25 public static IndexerService getIndexerService() {
26 initUseDiscovery();
27 if (OLE_DOCSTORE_USE_DISCOVERY) {
28 return indexerService;
29 } else {
30 return dummyIndexerService;
31 }
32 }
33
34 private static void initUseDiscovery() {
35 if (OLE_DOCSTORE_USE_DISCOVERY != null) {
36 return;
37 }
38
39 String strUseDiscovery = System.getProperty("OLE_DOCSTORE_USE_DISCOVERY");
40 if ((strUseDiscovery != null) && strUseDiscovery.equalsIgnoreCase("false")) {
41 OLE_DOCSTORE_USE_DISCOVERY = Boolean.FALSE;
42 } else {
43 OLE_DOCSTORE_USE_DISCOVERY = Boolean.TRUE;
44 }
45 LOG.info("OLE_DOCSTORE_USE_DISCOVERY = " + OLE_DOCSTORE_USE_DISCOVERY);
46 }
47
48 public static AdminService getDiscoveryAdminService() {
49 initUseDiscovery();
50 if (OLE_DOCSTORE_USE_DISCOVERY) {
51 return adminService;
52 } else {
53 return adminServiceDummy;
54 }
55 }
56 }