001
014
015 package com.liferay.portal.service;
016
017 import java.util.Map;
018
019
022 public class ExceptionRetryAcceptor implements RetryAcceptor {
023
024 public static final String EXCEPTION_NAME = "EXCEPTION_NAME";
025
026 @Override
027 public boolean acceptException(
028 Throwable t, Map<String, String> propertyMap) {
029
030 String name = propertyMap.get(EXCEPTION_NAME);
031
032 if (name == null) {
033 throw new IllegalArgumentException(
034 "Missing property " + EXCEPTION_NAME);
035 }
036
037 while (true) {
038 Class<?> clazz = t.getClass();
039
040 ClassLoader classLoader = clazz.getClassLoader();
041
042 try {
043 Class<?> exceptionClass = classLoader.loadClass(name);
044
045 if (exceptionClass.isInstance(t)) {
046 return true;
047 }
048 }
049 catch (ClassNotFoundException cnfe) {
050 }
051
052 Throwable cause = t.getCause();
053
054 if ((t == cause) || (cause == null)) {
055 break;
056 }
057
058 t = cause;
059 }
060
061 return false;
062 }
063
064 @Override
065 public boolean acceptResult(
066 Object returnValue, Map<String, String> propertyMap) {
067
068 return false;
069 }
070
071 }