1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.routemanager;
17
18 import org.kuali.rice.kew.messaging.exceptionhandling.ExceptionRoutingServiceImpl;
19 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
20 import org.kuali.rice.kew.test.TestUtilities;
21 import org.kuali.rice.ksb.messaging.PersistedMessageBO;
22 import org.kuali.rice.test.ThreadMonitor;
23
24
25
26 public class TestExceptionRoutingServiceImpl extends ExceptionRoutingServiceImpl {
27
28 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
29 .getLogger(TestExceptionRoutingServiceImpl.class);
30
31 @Override
32 public DocumentRouteHeaderValue placeInExceptionRouting(Throwable throwable, PersistedMessageBO persistedMessage, String documentId) {
33 LOG.info("Invoking placeInExceptionRouting on TestExceptionRoutingServiceImpl");
34 ExceptionThreader exceptionThreader = new ExceptionThreader(throwable, persistedMessage, documentId, this);
35 ThreadMonitor.addThread(exceptionThreader);
36 exceptionThreader.start();
37 LOG.info("ExceptionThreader has been started");
38 return null;
39 }
40
41 private static class ExceptionThreader extends Thread {
42
43 private Throwable throwable;
44 private PersistedMessageBO message;
45 String documentId;
46 private TestExceptionRoutingServiceImpl testExceptionService;
47
48 public ExceptionThreader(Throwable throwable, PersistedMessageBO message, String documentId, TestExceptionRoutingServiceImpl testExceptionService) {
49 this.throwable = throwable;
50 this.message = message;
51 this.documentId = documentId;
52 this.testExceptionService = testExceptionService;
53 TestUtilities.setExceptionThreader(this);
54 }
55
56 public void run() {
57 try {
58 testExceptionService.callRealPlaceInExceptionRouting(throwable, message, documentId);
59 } catch (Exception e) {
60 LOG.error("Exception encountered when attempting to callRealPlaceInExceptionRouting", e);
61 }
62 }
63 }
64
65 public void callRealPlaceInExceptionRouting(Throwable throwable, PersistedMessageBO message, String documentId) throws Exception {
66 LOG.info("Invoking the real place in exception routing");
67 super.placeInExceptionRouting(throwable, message, documentId);
68 LOG.info("Document should now be in exception status");
69 }
70 }