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.discovery.service.IndexerService;
6 import org.kuali.ole.docstore.discovery.service.IndexerServiceImpl;
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 = IndexerServiceImpl.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 }
30 else {
31 return dummyIndexerService;
32 }
33 }
34
35 private static void initUseDiscovery() {
36 if (OLE_DOCSTORE_USE_DISCOVERY != null) {
37 return;
38 }
39
40 String strUseDiscovery = System.getProperty("OLE_DOCSTORE_USE_DISCOVERY");
41 if ((strUseDiscovery != null) && strUseDiscovery.equalsIgnoreCase("false")) {
42 OLE_DOCSTORE_USE_DISCOVERY = Boolean.FALSE;
43 }
44 else {
45 OLE_DOCSTORE_USE_DISCOVERY = Boolean.TRUE;
46 }
47 LOG.info("OLE_DOCSTORE_USE_DISCOVERY = " + OLE_DOCSTORE_USE_DISCOVERY);
48 }
49
50 public static AdminService getDiscoveryAdminService() {
51 initUseDiscovery();
52 if (OLE_DOCSTORE_USE_DISCOVERY)
53 return adminService;
54 else
55 return adminServiceDummy;
56 }
57 }