01: /*
02: * Copyright 2007 The Kuali Foundation
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
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 edu.iu.uis.eden.messaging.exceptionhandling;
17:
18: import org.apache.log4j.Logger;
19: import org.kuali.bus.services.KSBServiceLocator;
20:
21: import edu.iu.uis.eden.messaging.AsynchronousCall;
22: import edu.iu.uis.eden.messaging.PersistedMessage;
23: import edu.iu.uis.eden.messaging.RemoteResourceServiceLocator;
24: import edu.iu.uis.eden.messaging.resourceloading.KSBResourceLoaderFactory;
25:
26: /**
27: * Default implementation of {@link ExceptionRoutingService}. Just saves
28: * the message in the queue as is, which should be marked Exception by the
29: * {@link MessageExceptionHandler}.
30: *
31: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
32: *
33: */
34: public class DefaultExceptionServiceImpl implements
35: ExceptionRoutingService {
36:
37: private static final Logger LOG = Logger
38: .getLogger(DefaultExceptionServiceImpl.class);
39:
40: public void placeInExceptionRouting(Throwable throwable,
41: PersistedMessage message) {
42: KSBServiceLocator.getRouteQueueService().save(message);
43: }
44:
45: public void placeInExceptionRouting(Throwable throwable,
46: PersistedMessage message, Object service) {
47: LOG.error("Exception caught processing message "
48: + message.getRouteQueueId() + " "
49: + message.getServiceName() + ": " + throwable);
50:
51: RemoteResourceServiceLocator remoteResourceServiceLocator = KSBResourceLoaderFactory
52: .getRemoteResourceLocator();
53: AsynchronousCall methodCall = null;
54: if (message.getMethodCall() != null) {
55: methodCall = message.getMethodCall();
56: } else {
57: methodCall = message.getPayload().getMethodCall();
58: }
59: message.setMethodCall(methodCall);
60: MessageExceptionHandler exceptionHandler = remoteResourceServiceLocator
61: .getMessageExceptionHandler(methodCall.getServiceInfo()
62: .getQname());
63: exceptionHandler.handleException(throwable, message, service);
64: }
65: }
|