repackaged error handler

This commit is contained in:
benni 2012-11-19 16:03:27 +01:00
parent 201518d9f4
commit b3fa064217
3 changed files with 13 additions and 16 deletions

View File

@ -24,17 +24,7 @@ public abstract class AbstractMessageBus<T, P extends IMessageBus.IPostCommand>
}
};
// This is the default error handler it will simply log to standard out and
// print stack trace if available
protected static final class ConsoleLogger implements IPublicationErrorHandler {
@Override
public void handleError(PublicationError error) {
System.out.println(error);
if (error.getCause() != null) error.getCause().printStackTrace();
}
}
;
// executor for asynchronous listeners using unbound queuing strategy to ensure that no events get lost
private ExecutorService executor;
@ -98,7 +88,7 @@ public abstract class AbstractMessageBus<T, P extends IMessageBus.IPostCommand>
public AbstractMessageBus(int dispatcherThreadCount, ExecutorService executor) {
this.executor = executor;
initDispatcherThreads(dispatcherThreadCount > 0 ? dispatcherThreadCount : 2);
addErrorHandler(new ConsoleLogger());
addErrorHandler(new IPublicationErrorHandler.ConsoleLogger());
subscriptionFactory = getSubscriptionFactory();
initialize();
}

View File

@ -10,4 +10,16 @@ package org.mbassy;
public interface IPublicationErrorHandler {
public void handleError(PublicationError error);
// This is the default error handler it will simply log to standard out and
// print stack trace if available
static final class ConsoleLogger implements IPublicationErrorHandler {
@Override
public void handleError(PublicationError error) {
System.out.println(error);
if (error.getCause() != null) error.getCause().printStackTrace();
}
}
;
}

View File

@ -1,8 +1,5 @@
package org.mbassy.common;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.LinkedList;
@ -15,8 +12,6 @@ import java.util.List;
*/
public class ReflectionUtils {
private static final Logger logger = LoggerFactory.getLogger(ReflectionUtils.class);
public static List<Method> getMethods(IPredicate<Method> condition, Class<?> target) {
List<Method> methods = new LinkedList<Method>();
try {