View Javadoc

1   package org.kuali.ole.docstore.service;
2   
3   import org.kuali.ole.docstore.document.DocumentManagerFactory;
4   import org.kuali.ole.repository.DocumentStoreManager;
5   import org.springframework.context.ApplicationContext;
6   import org.springframework.context.support.ClassPathXmlApplicationContext;
7   
8   /**
9    * Created by IntelliJ IDEA.
10   * User: SG7940
11   * Date: 5/16/12
12   * Time: 12:54 PM
13   * To change this template use File | Settings | File Templates.
14   * <p/>
15   * Helper class to access beans created by Spring.
16   */
17  public class BeanLocator {
18  
19      public static ApplicationContext applicationContext = new ClassPathXmlApplicationContext(
20              "/docstore-springbeans.xml");
21  
22      public static DocumentStoreManager getDocumentStoreManager() {
23  
24          DocumentStoreManager documentStoreManager = (DocumentStoreManager) applicationContext
25                  .getBean("documentStoreManagerService");
26          return documentStoreManager;
27      }
28  
29      public static IngestNIndexHandlerService getIngestNIndexHandlerService() {
30  
31          IngestNIndexHandlerService ingestNIndexHandlerService = (IngestNIndexHandlerService) applicationContext
32                  .getBean("ingestNIndexHandlerService");
33          return ingestNIndexHandlerService;
34      }
35  
36      public static Object getBean(String id) {
37          return applicationContext.getBean(id);
38      }
39  
40      public static DocumentServiceImpl getDocumentServiceImpl() {
41          DocumentServiceImpl documentServiceImpl = (DocumentServiceImpl) applicationContext
42                  .getBean("documentService");
43          return documentServiceImpl;
44  }
45  
46      public static DocumentManagerFactory getDocumentManagerFactory() {
47          DocumentManagerFactory documentManagerFactoryService = (DocumentManagerFactory) applicationContext
48                  .getBean("documentManagerFactory");
49          return documentManagerFactoryService;
50      }
51  
52      public static BulkIngestProcessHandlerService getBulkIngestProcessHandlerService() {
53          BulkIngestProcessHandlerService bulkIngestProcessHandlerService
54                  = (BulkIngestProcessHandlerService) applicationContext.getBean("bulkIngestProcessHandlerService");
55          return bulkIngestProcessHandlerService;
56      }
57  }