View Javadoc
1   /**
2    * Copyright 2005-2014 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.ksb.messaging;
17  
18  import org.kuali.rice.ksb.messaging.exceptionhandling.DefaultExceptionServiceImpl;
19  import org.kuali.rice.test.TestUtilities;
20  import org.kuali.rice.test.ThreadMonitor;
21  
22  
23  public class TestExceptionRoutingServiceImpl extends DefaultExceptionServiceImpl {
24  
25      	private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
26  		.getLogger(TestExceptionRoutingServiceImpl.class);
27      
28  	public void placeInExceptionRouting(Throwable throwable, PersistedMessageBO message, Object service) {
29  		ExceptionThreader exceptionThreader = new ExceptionThreader(throwable, message, service, this);
30  		ThreadMonitor.addThread(exceptionThreader);
31  		exceptionThreader.start();
32  	}
33  	
34  	private static class ExceptionThreader extends Thread {
35  
36  		private Throwable throwable;
37  		private PersistedMessageBO message;
38  		private Object service;
39  		private TestExceptionRoutingServiceImpl testExceptionService;
40  		
41  		public ExceptionThreader(Throwable throwable, PersistedMessageBO message, Object service, TestExceptionRoutingServiceImpl testExceptionService) {
42  			this.throwable = throwable;
43  			this.message = message;
44  			this.service = service;
45  			this.testExceptionService = testExceptionService;
46  			TestUtilities.setExceptionThreader(this);
47  		}
48  
49  		public void run() {
50  		    try {
51  			this.testExceptionService.callRealPlaceInExceptionRouting(this.throwable, this.message, this.service);
52  		    } catch (Throwable t) {
53  			LOG.fatal("Error executing callRealPlaceInExceptionRouting.", t);
54  		    }
55  		}
56  	}
57  	
58  	public void callRealPlaceInExceptionRouting(Throwable throwable, PersistedMessageBO message, Object service) throws Exception {
59  		super.placeInExceptionRouting(throwable, message, service);
60  	}
61  	
62  }