You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by cw...@apache.org on 2010/06/04 16:43:58 UTC
svn commit: r951425 -
/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/spi/transport/vm/UimaVmMessageDispatcher.java
Author: cwiklik
Date: Fri Jun 4 14:43:58 2010
New Revision: 951425
URL: http://svn.apache.org/viewvc?rev=951425&view=rev
Log:
UIMA-1800 Modified to use UimaBlockingExecutor
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=951425&r1=951424&r2=951425&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 Fri Jun 4 14:43:58 2010
@@ -23,6 +23,7 @@ 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;
@@ -39,16 +40,15 @@ import org.apache.uima.util.Level;
public class UimaVmMessageDispatcher implements UimaMessageDispatcher {
private static final Class<?> CLASS_NAME = UimaVmMessageDispatcher.class;
- private ThreadPoolExecutor executor = null;
-
+ private UimaBlockingExecutor blockingExecutor;
// Message listener which will receive a new message
private final UimaMessageListener targetListener;
private String delegateKey;
- public UimaVmMessageDispatcher(ThreadPoolExecutor anExecutor, UimaMessageListener aListener,
+ public UimaVmMessageDispatcher(UimaBlockingExecutor anExecutor, UimaMessageListener aListener,
String aKey) {
- executor = anExecutor;
+ blockingExecutor = anExecutor;
delegateKey = aKey;
targetListener = aListener;
}
@@ -59,33 +59,37 @@ public class UimaVmMessageDispatcher imp
* the Executor.
*/
public void dispatch(final UimaMessage message) {
- if (executor.isShutdown() || executor.isTerminating() || executor.isShutdown()) {
+ if ( !blockingExecutor.isReady() ) {
return;
}
- 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);
+ 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);
+ }
}
}
- }
- });
+ });
+ } 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 (executor != null) {
- executor.purge();
- executor.shutdownNow();
+ if (blockingExecutor != null) {
+ blockingExecutor.stop();
}
}
}