Author: cwiklik Date: Mon Jun 7 17:20:00 2010 New Revision: 952339 URL: http://svn.apache.org/viewvc?rev=952339&view=rev Log: UIMA-1800 Reverted to code that is not using BlockingExecutor
Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/spi/transport/vm/UimaVmMessageDispatcher.java Modified: uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/spi/transport/vm/UimaVmMessageDispatcher.java URL: http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/spi/transport/vm/UimaVmMessageDispatcher.java?rev=952339&r1=952338&r2=952339&view=diff ============================================================================== --- uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/spi/transport/vm/UimaVmMessageDispatcher.java (original) +++ uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/spi/transport/vm/UimaVmMessageDispatcher.java Mon Jun 7 17:20:00 2010 @@ -23,7 +23,6 @@ import java.util.concurrent.ThreadPoolEx import org.apache.uima.UIMAFramework; import org.apache.uima.aae.UIMAEE_Constants; -import org.apache.uima.aae.UimaBlockingExecutor; import org.apache.uima.aae.controller.AggregateAnalysisEngineController_impl; import org.apache.uima.aae.spi.transport.UimaMessage; import org.apache.uima.aae.spi.transport.UimaMessageDispatcher; @@ -40,15 +39,16 @@ import org.apache.uima.util.Level; public class UimaVmMessageDispatcher implements UimaMessageDispatcher { private static final Class<?> CLASS_NAME = UimaVmMessageDispatcher.class; - private UimaBlockingExecutor blockingExecutor; + private ThreadPoolExecutor executor = null; + // Message listener which will receive a new message private final UimaMessageListener targetListener; private String delegateKey; - public UimaVmMessageDispatcher(UimaBlockingExecutor anExecutor, UimaMessageListener aListener, + public UimaVmMessageDispatcher(ThreadPoolExecutor anExecutor, UimaMessageListener aListener, String aKey) { - blockingExecutor = anExecutor; + executor = anExecutor; delegateKey = aKey; targetListener = aListener; } @@ -59,37 +59,33 @@ public class UimaVmMessageDispatcher imp * the Executor. */ public void dispatch(final UimaMessage message) { - if ( !blockingExecutor.isReady() ) { + if (executor.isShutdown() || executor.isTerminating() || executor.isShutdown()) { return; } - try { - blockingExecutor.submitTask(new Runnable() { - public void run() { - try { - if (targetListener instanceof UimaVmMessageListener) { - ((UimaVmMessageListener) targetListener).onMessage(message); - } else { - System.out.println("!!!!!!!!!!!!!!! Wrong Type of UimaListener"); - } - } catch (Exception e) { - if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) { - UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), - "run", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, - "UIMAEE_exception__WARNING", e); - } + executor.execute(new Runnable() { + public void run() { + + try { + if (targetListener instanceof UimaVmMessageListener) { + ((UimaVmMessageListener) targetListener).onMessage(message); + } else { + System.out.println("!!!!!!!!!!!!!!! Wrong Type of UimaListener"); + } + } catch (Exception e) { + if (UIMAFramework.getLogger(CLASS_NAME).isLoggable(Level.WARNING)) { + UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), + "run", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, + "UIMAEE_exception__WARNING", e); } } - }); - } catch( Exception e) { - UIMAFramework.getLogger(CLASS_NAME).logrb(Level.WARNING, getClass().getName(), - "run", UIMAEE_Constants.JMS_LOG_RESOURCE_BUNDLE, - "UIMAEE_exception__WARNING", e); - } + } + }); } public void stop() { - if (blockingExecutor != null) { - blockingExecutor.stop(); + if (executor != null) { + executor.purge(); + executor.shutdownNow(); } } }