View Javadoc
1   package org.kuali.ole.docstore.common.client;
2   
3   /**
4    * Created with IntelliJ IDEA.
5    * User: divyaj
6    * Date: 1/6/14
7    * Time: 3:42 PM
8    * To change this template use File | Settings | File Templates.
9    */
10  public class DocstoreClientLocator {
11  
12      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocstoreClientLocator.class);
13      private DocstoreClient docstoreClient = null;
14      public DocstoreClientLocator(){
15          // TODO: Remove this line after fixing the logic for getDocstoreClient.
16          docstoreClient = new DocstoreRestClient();
17      }
18      public DocstoreClient getDocstoreClient()throws Exception{
19          if (docstoreClient !=null) {
20              return docstoreClient;
21          } else {
22              LOG.info("docstoreClient is null");
23              // Check whether docstore is local (Look for docstore local service).
24              try{
25                  Class<?> docstoreServiceClass = Class.forName("org.kuali.ole.docstore.engine.service.DocstoreServiceImpl");
26                  // Docstore is local. So create a local client.
27                  docstoreClient = (DocstoreClient) Class.forName("org.kuali.ole.docstore.engine.client.DocstoreLocalClient").newInstance();
28                  // TODO: Catch instantiation exception and throw DocstoreException.
29                  LOG.info("DocstoreLocalClient successfully instantiated");
30                  // Loginfo  "Docstore local client created".
31              }catch(ClassNotFoundException cnfe){
32                  // Docstore is remote. So create a rest client.
33                  docstoreClient = new DocstoreRestClient();
34                  LOG.info("DocstoreRestClient successfully instantiated");
35              }
36          }
37          return docstoreClient;
38      }
39  }