String serviceName)
{
// Declare countdown latch and listener
final CountDownLatch latch = new CountDownLatch(1);
SystemExceptionHandler listener = null;
MessagingExceptionHandler messagingListener = null;
SystemExceptionHandler currentExceptionListener = null;
MessagingExceptionHandler currentMessagingListener = null;
final ValueHolder<Exception> exceptionHolder = new ValueHolder<Exception>();
try
{
// Next create a listener that listens for exception on the
// sftp-connector
listener = new SystemExceptionHandler()
{
@Override
public void handleException(Exception e, RollbackSourceCallback rollbackMethod)
{
exceptionHolder.value = e;
if (logger.isDebugEnabled())
logger.debug("Expected exception occurred: " + e.getMessage()
+ ", time to countdown the latch");
latch.countDown();
}
@Override
public void handleException(Exception exception)
{
handleException(exception, null);
}
};
messagingListener = new MessagingExceptionHandler()
{
@Override
public MuleEvent handleException(Exception e, MuleEvent event)
{
exceptionHolder.value = e;