View Javadoc

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