001 /*
002 * Copyright 2005-2008 The Kuali Foundation
003 *
004 *
005 * Licensed under the Educational Community License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 * http://www.opensource.org/licenses/ecl2.php
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.kuali.rice.kew.routemanager;
018
019 import org.kuali.rice.kew.messaging.exceptionhandling.ExceptionRoutingServiceImpl;
020 import org.kuali.rice.kew.test.TestUtilities;
021 import org.kuali.rice.ksb.messaging.PersistedMessage;
022 import org.kuali.rice.test.ThreadMonitor;
023
024
025
026 public class TestExceptionRoutingServiceImpl extends ExceptionRoutingServiceImpl {
027
028 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger
029 .getLogger(TestExceptionRoutingServiceImpl.class);
030
031 @Override
032 public void placeInExceptionRouting(Throwable throwable, PersistedMessage persistedMessage, Long routeHeaderId) {
033 ExceptionThreader exceptionThreader = new ExceptionThreader(throwable, persistedMessage, routeHeaderId, this);
034 ThreadMonitor.addThread(exceptionThreader);
035 exceptionThreader.start();
036 }
037
038 private static class ExceptionThreader extends Thread {
039
040 private Throwable throwable;
041 private PersistedMessage message;
042 Long routeHeaderId;
043 private TestExceptionRoutingServiceImpl testExceptionService;
044
045 public ExceptionThreader(Throwable throwable, PersistedMessage message, Long routeHeaderId, TestExceptionRoutingServiceImpl testExceptionService) {
046 this.throwable = throwable;
047 this.message = message;
048 this.routeHeaderId = routeHeaderId;
049 this.testExceptionService = testExceptionService;
050 TestUtilities.setExceptionThreader(this);
051 }
052
053 public void run() {
054 try {
055 testExceptionService.callRealPlaceInExceptionRouting(throwable, message, routeHeaderId);
056 } catch (Exception e) {
057 LOG.error(e, e);
058 }
059 }
060 }
061
062 public void callRealPlaceInExceptionRouting(Throwable throwable, PersistedMessage message, Long routeHeaderId) throws Exception {
063 super.placeInExceptionRouting(throwable, message, routeHeaderId);
064 }
065 }