View Javadoc

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