View Javadoc

1   /**
2    * Copyright 2005-2011 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
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  		ExceptionThreader exceptionThreader = new ExceptionThreader(throwable, persistedMessage, documentId, this);
33  		ThreadMonitor.addThread(exceptionThreader);
34  		exceptionThreader.start();
35  	}
36  	
37  	private static class ExceptionThreader extends Thread {
38  
39  		private Throwable throwable;
40  		private PersistedMessageBO message;
41  		String documentId;
42  		private TestExceptionRoutingServiceImpl testExceptionService;
43  		
44  		public ExceptionThreader(Throwable throwable, PersistedMessageBO message, String documentId, TestExceptionRoutingServiceImpl testExceptionService) {
45  			this.throwable = throwable;
46  			this.message = message;
47  			this.documentId = documentId;
48  			this.testExceptionService = testExceptionService;
49  			TestUtilities.setExceptionThreader(this);
50  		}
51  
52  		public void run() {
53  		    try {
54  			testExceptionService.callRealPlaceInExceptionRouting(throwable, message, documentId);
55  		    } catch (Exception e) {
56  			LOG.error(e, e);
57  		    }
58  		}
59  	}
60  	
61  	public void callRealPlaceInExceptionRouting(Throwable throwable, PersistedMessageBO message, String documentId) throws Exception {
62  		super.placeInExceptionRouting(throwable, message, documentId);
63  	}	
64  }