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.test.TestUtilities;
20  import org.kuali.rice.ksb.messaging.PersistedMessageBO;
21  import org.kuali.rice.test.ThreadMonitor;
22  
23  
24  
25  public class TestExceptionRoutingServiceImpl extends ExceptionRoutingServiceImpl {
26  
27      private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
28  	    .getLogger(TestExceptionRoutingServiceImpl.class);
29      
30  	@Override
31  	public void placeInExceptionRouting(Throwable throwable, PersistedMessageBO persistedMessage, String documentId) {
32          LOG.info("Invoking placeInExceptionRouting on TestExceptionRoutingServiceImpl");
33  		ExceptionThreader exceptionThreader = new ExceptionThreader(throwable, persistedMessage, documentId, this);
34  		ThreadMonitor.addThread(exceptionThreader);
35  		exceptionThreader.start();
36          LOG.info("ExceptionThreader has been started");
37  	}
38  	
39  	private static class ExceptionThreader extends Thread {
40  
41  		private Throwable throwable;
42  		private PersistedMessageBO message;
43  		String documentId;
44  		private TestExceptionRoutingServiceImpl testExceptionService;
45  		
46  		public ExceptionThreader(Throwable throwable, PersistedMessageBO message, String documentId, TestExceptionRoutingServiceImpl testExceptionService) {
47  			this.throwable = throwable;
48  			this.message = message;
49  			this.documentId = documentId;
50  			this.testExceptionService = testExceptionService;
51  			TestUtilities.setExceptionThreader(this);
52  		}
53  
54  		public void run() {
55  		    try {
56  			    testExceptionService.callRealPlaceInExceptionRouting(throwable, message, documentId);
57  		    } catch (Exception e) {
58  			    LOG.error("Exception encountered when attempting to callRealPlaceInExceptionRouting", e);
59  		    }
60  		}
61  	}
62  	
63  	public void callRealPlaceInExceptionRouting(Throwable throwable, PersistedMessageBO message, String documentId) throws Exception {
64          LOG.info("Invoking the real place in exception routing");
65  		super.placeInExceptionRouting(throwable, message, documentId);
66          LOG.info("Document should now be in exception status");
67  	}	
68  }