1 package org.kuali.ole.docstore.process;
2
3 import org.apache.camel.CamelContext;
4 import org.apache.camel.builder.LoggingErrorHandlerBuilder;
5 import org.apache.camel.impl.DefaultCamelContext;
6 import org.slf4j.Logger;
7 import org.slf4j.LoggerFactory;
8
9
10
11
12
13
14
15
16 public class DocStoreCamelContext {
17
18 private static Logger log = LoggerFactory.getLogger(BulkLoadHandler.class);
19 private static DocStoreCamelContext handlerContext = null;
20 private CamelContext context = null;
21 private LoggingErrorHandlerBuilder errorHandler = new LoggingErrorHandlerBuilder();
22
23 private DocStoreCamelContext() {
24 context = new DefaultCamelContext();
25 try {
26 context.start();
27 log.info("DocStoreCamelContext Initialized");
28 } catch (Exception e) {
29 log.error("Ingest Handler Service Starup Failed : ", e);
30 e.printStackTrace();
31 }
32 }
33
34
35
36
37
38
39
40 public static DocStoreCamelContext getInstance() {
41 if (handlerContext == null)
42 handlerContext = new DocStoreCamelContext();
43 return handlerContext;
44 }
45
46 public boolean isRunning() {
47 return !context.isSuspended();
48 }
49
50 public void resume() throws Exception {
51 if (context.isSuspended())
52 context.resume();
53 }
54
55 public void suspend() throws Exception {
56 if (!context.isSuspended())
57 context.suspend();
58 }
59
60 public void stop() {
61 try {
62 BulkLoadHandler.getInstance().stop();
63 context.stop();
64 } catch (Exception e) {
65 log.error("Ingest Handler Service Cold Stop Failed : ", e);
66 }
67 }
68
69 public CamelContext getCamelContext() {
70 return context;
71 }
72
73 public LoggingErrorHandlerBuilder getErrorHandler() {
74 return errorHandler;
75 }
76
77 }