You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by al...@apache.org on 2006/11/22 17:44:00 UTC

svn commit: r478226 [17/32] - in /incubator/uima/uimaj/trunk/uimaj-cpe/src: main/java/org/apache/uima/cas_data/impl/vinci/ main/java/org/apache/uima/collection/impl/ main/java/org/apache/uima/collection/impl/base_cpm/container/ main/java/org/apache/uim...

Modified: incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/CPMThreadGroup.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/CPMThreadGroup.java?view=diff&rev=478226&r1=478225&r2=478226
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/CPMThreadGroup.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/CPMThreadGroup.java Wed Nov 22 08:43:54 2006
@@ -30,87 +30,82 @@
 import org.apache.uima.util.ProcessTrace;
 
 /**
- * This component catches uncaught errors in the CPM. 
- * All critical threads in the CPM are part of this
- * ThreadGroup. If OutOfMemory Error is thrown this
- * component is notified by the JVM and its job is to
- * notify registered listeners.
- *
+ * This component catches uncaught errors in the CPM. All critical threads in the CPM are part of
+ * this ThreadGroup. If OutOfMemory Error is thrown this component is notified by the JVM and its
+ * job is to notify registered listeners.
+ * 
  */
-public class CPMThreadGroup extends ThreadGroup
-{
-	private ArrayList callbackListeners = null;
-	private ProcessTrace procTr = null;
-	/**
-	 * @param name
-	 */
-	public CPMThreadGroup(String name)
-	{
-		super(name);
-	}
-
-	/**
-	 * @param parent - parent thread group
-	 * @param name - name of this thread group
-	 */
-	public CPMThreadGroup(ThreadGroup parent, String name)
-	{
-		super(parent, name);
-	}
-	/**
-	 * Sets listeners to be used in notifications
-	 *
-	 * @param aListenerList - list of registered listners
-	 */
-	public void setListeners(ArrayList aListenerList)
-	{
-		callbackListeners = aListenerList;
-	}
-	public void setProcessTrace(ProcessTrace aProcessTrace)
-	{
-		procTr = aProcessTrace;
-	}
-	public void uncaughtException(Thread t, Throwable e)
-	{
-		System.out.println("ThreadGroup.uncaughtException()-Got Error");
-		if ( UIMAFramework.getLogger().isLoggable(Level.SEVERE) )
-		{
-			UIMAFramework.getLogger(this.getClass()).logrb(Level.SEVERE, this.getClass().getName(), "process",
-			        CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_unhandled_error__SEVERE",
-			        new Object[] {Thread.currentThread().getName(),e.getClass().getName() });
-
-		}
-		try
-		{
-			//	Notify listeners
-			for (int i = 0; callbackListeners != null && i < callbackListeners.size(); i++)
-			{
-//				System.out.println("ThreadGroup.uncaughtException()-Got Error - Notifying Listener");
-				notifyListener((BaseStatusCallbackListener) callbackListeners.get(i), e);
-			}
-			
-		}
-		catch (Throwable tr)
-		{
-			if ( UIMAFramework.getLogger().isLoggable(Level.FINER) )
-			{
-				UIMAFramework.getLogger(this.getClass()).logrb(Level.FINER, this.getClass().getName(), "process",
-				        CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_exception__FINER",
-				        new Object[] {Thread.currentThread().getName(),tr.getClass().getName() });
-                tr.printStackTrace();
-			}
-		}
-//		System.out.println("ThreadGroup.uncaughtException()-Done Handling Error");
-	}
-	private void notifyListener(BaseStatusCallbackListener aStatCL, Throwable e)
-	{
-		EntityProcessStatusImpl enProcSt = new EntityProcessStatusImpl(procTr);
-		enProcSt.addEventStatus("Process", "Failed", e);
-		((StatusCallbackListener) aStatCL).entityProcessComplete(null, enProcSt);
-	}
-	public void cleanup()
-	{
-		callbackListeners = null;
-		procTr = null;
-	}
+public class CPMThreadGroup extends ThreadGroup {
+  private ArrayList callbackListeners = null;
+
+  private ProcessTrace procTr = null;
+
+  /**
+   * @param name
+   */
+  public CPMThreadGroup(String name) {
+    super(name);
+  }
+
+  /**
+   * @param parent -
+   *          parent thread group
+   * @param name -
+   *          name of this thread group
+   */
+  public CPMThreadGroup(ThreadGroup parent, String name) {
+    super(parent, name);
+  }
+
+  /**
+   * Sets listeners to be used in notifications
+   * 
+   * @param aListenerList -
+   *          list of registered listners
+   */
+  public void setListeners(ArrayList aListenerList) {
+    callbackListeners = aListenerList;
+  }
+
+  public void setProcessTrace(ProcessTrace aProcessTrace) {
+    procTr = aProcessTrace;
+  }
+
+  public void uncaughtException(Thread t, Throwable e) {
+    System.out.println("ThreadGroup.uncaughtException()-Got Error");
+    if (UIMAFramework.getLogger().isLoggable(Level.SEVERE)) {
+      UIMAFramework.getLogger(this.getClass()).logrb(Level.SEVERE, this.getClass().getName(),
+                      "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
+                      "UIMA_CPM_unhandled_error__SEVERE",
+                      new Object[] { Thread.currentThread().getName(), e.getClass().getName() });
+
+    }
+    try {
+      // Notify listeners
+      for (int i = 0; callbackListeners != null && i < callbackListeners.size(); i++) {
+        // System.out.println("ThreadGroup.uncaughtException()-Got Error - Notifying Listener");
+        notifyListener((BaseStatusCallbackListener) callbackListeners.get(i), e);
+      }
+
+    } catch (Throwable tr) {
+      if (UIMAFramework.getLogger().isLoggable(Level.FINER)) {
+        UIMAFramework.getLogger(this.getClass()).logrb(Level.FINER, this.getClass().getName(),
+                        "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_exception__FINER",
+                        new Object[] { Thread.currentThread().getName(), tr.getClass().getName() });
+        tr.printStackTrace();
+      }
+    }
+    // System.out.println("ThreadGroup.uncaughtException()-Done Handling Error");
+  }
+
+  private void notifyListener(BaseStatusCallbackListener aStatCL, Throwable e) {
+    EntityProcessStatusImpl enProcSt = new EntityProcessStatusImpl(procTr);
+    enProcSt.addEventStatus("Process", "Failed", e);
+    ((StatusCallbackListener) aStatCL).entityProcessComplete(null, enProcSt);
+  }
+
+  public void cleanup() {
+    callbackListeners = null;
+    procTr = null;
+  }
 }

Modified: incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ConsumerCasUtils.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ConsumerCasUtils.java?view=diff&rev=478226&r1=478225&r2=478226
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ConsumerCasUtils.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/ConsumerCasUtils.java Wed Nov 22 08:43:54 2006
@@ -26,72 +26,77 @@
 
 /**
  * 
- *
+ * 
  * 
  * 
  */
-public class ConsumerCasUtils
-{
-	/**
-	 * Returns an int value of a given Feature Structure
-	 * 
-	 * @param aTcas - CAS instance to retrieve data from
-	 * @param aTypeS - Feature Type
-	 * @param aFeatS - Feature Structure
-	 * 
-	 * @return - feature value as int
-	 */
-	public static int getIntFeatValue(TCAS aTcas, String aTypeS, String aFeatS)
-	{
-		int result = 0;
-		FSIterator idIter = aTcas.getAnnotationIndex(aTcas.getTypeSystem().getType(aTypeS)).iterator();
-		while (idIter != null && idIter.isValid())
-		{
-			org.apache.uima.cas.FeatureStructure idFS = idIter.get();
-			result = idFS.getIntValue(aTcas.getTypeSystem().getFeatureByFullName(aTypeS + ":" + aFeatS));
-			idIter.moveToNext();
-		}
-		return result;
-	}
-	/**
-	 * Returns a string value of a given Feature Structure
-	 * 
-	 * @param aCasView - CAS view to retrieve data from
-	 * @param aTypeS - Feature Type
-	 * @param aFeatS - Feature Structure
-	 * 
-	 * @return feature value as string
-	 */
-	public static String getStringFeatValue(CAS aCasView, String aTypeS, String aFeatS)
-	{
-		String result = null;
-		FSIterator idIter = aCasView.getAnnotationIndex(aCasView.getTypeSystem().getType(aTypeS)).iterator();
-		while (idIter != null && idIter.isValid())
-		{
-			org.apache.uima.cas.FeatureStructure idFS = idIter.get();
-			result = idFS.getStringValue(aCasView.getTypeSystem().getFeatureByFullName(aTypeS + ":" + aFeatS));
-			idIter.moveToNext();
-		}
-		return result;
-	}
-	/**
-	 * Returns a Feature Structure of a given type
-	 * 
-	 * @param aTcas - CAS instance to retrieve data from
-	 * @param aTypeS - Feature Type
-	 * 
-	 * @return
-	 */
-	public static FeatureStructure getTcasFS(TCAS aTcas, String aTypeS)
-	{
-		org.apache.uima.cas.FeatureStructure idFS = null;
-		FSIterator idIter = aTcas.getAnnotationIndex(aTcas.getTypeSystem().getType(aTypeS)).iterator();
-		while (idIter != null && idIter.isValid())
-		{
-			idFS = idIter.get();
-			idIter.moveToNext();
-		}
-		return idFS;
-	}
+public class ConsumerCasUtils {
+  /**
+   * Returns an int value of a given Feature Structure
+   * 
+   * @param aTcas -
+   *          CAS instance to retrieve data from
+   * @param aTypeS -
+   *          Feature Type
+   * @param aFeatS -
+   *          Feature Structure
+   * 
+   * @return - feature value as int
+   */
+  public static int getIntFeatValue(TCAS aTcas, String aTypeS, String aFeatS) {
+    int result = 0;
+    FSIterator idIter = aTcas.getAnnotationIndex(aTcas.getTypeSystem().getType(aTypeS)).iterator();
+    while (idIter != null && idIter.isValid()) {
+      org.apache.uima.cas.FeatureStructure idFS = idIter.get();
+      result = idFS.getIntValue(aTcas.getTypeSystem().getFeatureByFullName(aTypeS + ":" + aFeatS));
+      idIter.moveToNext();
+    }
+    return result;
+  }
+
+  /**
+   * Returns a string value of a given Feature Structure
+   * 
+   * @param aCasView -
+   *          CAS view to retrieve data from
+   * @param aTypeS -
+   *          Feature Type
+   * @param aFeatS -
+   *          Feature Structure
+   * 
+   * @return feature value as string
+   */
+  public static String getStringFeatValue(CAS aCasView, String aTypeS, String aFeatS) {
+    String result = null;
+    FSIterator idIter = aCasView.getAnnotationIndex(aCasView.getTypeSystem().getType(aTypeS))
+                    .iterator();
+    while (idIter != null && idIter.isValid()) {
+      org.apache.uima.cas.FeatureStructure idFS = idIter.get();
+      result = idFS.getStringValue(aCasView.getTypeSystem().getFeatureByFullName(
+                      aTypeS + ":" + aFeatS));
+      idIter.moveToNext();
+    }
+    return result;
+  }
+
+  /**
+   * Returns a Feature Structure of a given type
+   * 
+   * @param aTcas -
+   *          CAS instance to retrieve data from
+   * @param aTypeS -
+   *          Feature Type
+   * 
+   * @return
+   */
+  public static FeatureStructure getTcasFS(TCAS aTcas, String aTypeS) {
+    org.apache.uima.cas.FeatureStructure idFS = null;
+    FSIterator idIter = aTcas.getAnnotationIndex(aTcas.getTypeSystem().getType(aTypeS)).iterator();
+    while (idIter != null && idIter.isValid()) {
+      idFS = idIter.get();
+      idIter.moveToNext();
+    }
+    return idFS;
+  }
 
 }

Modified: incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/DebugControlThread.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/DebugControlThread.java?view=diff&rev=478226&r1=478225&r2=478226
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/DebugControlThread.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/DebugControlThread.java Wed Nov 22 08:43:54 2006
@@ -29,273 +29,224 @@
 import org.apache.uima.collection.impl.cpm.utils.CpmLocalizedMessage;
 import org.apache.uima.util.Level;
 
-public class DebugControlThread implements Runnable
-{
-	private final static String NOTFOUND = "NOT-FOUND";
-
-	private String fileName = null;
-	private boolean stop = false;
-	private int checkpointFrequency = 3000;
-	private boolean pause = false;
-	private String monitor = "";
-	//private boolean isRunning = false;
-	private CPMEngine cpm = null;
-
-	public DebugControlThread(CPMEngine aCpm, String aFilename, int aCheckpointFrequency)
-	{
-		cpm = aCpm;
-		fileName = aFilename;
-		checkpointFrequency = aCheckpointFrequency;
-	}
-
-	public void start() throws RuntimeException
-	{
-		if (fileName == null)
-		{
-			if ( UIMAFramework.getLogger().isLoggable(Level.FINEST) )
-			{
-				UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(), "process",
-				        CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_checkpoint_target_not_defined__FINEST",
-				        new Object[] {Thread.currentThread().getName() });
-			}
-			throw new RuntimeException(CpmLocalizedMessage.getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
-					"UIMA_CPM_EXP_target_checkpoint_not_defined__WARNING",new Object[] {Thread.currentThread().getName()}) );
-		}
-		if (cpm == null)
-		{
-			if ( UIMAFramework.getLogger().isLoggable(Level.FINEST) )
-			{
-				UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(), "process",
-				        CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_invalid_cpm_instance__FINEST",
-				        new Object[] {Thread.currentThread().getName() });
-			}
-			throw new RuntimeException(CpmLocalizedMessage.getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
-					"UIMA_CPM_EXP_invalid_cpm__WARNING",new Object[] {Thread.currentThread().getName()}) );
-		}
-		else
-		{
-			new Thread(this).start();
-		}
-	}
-
-	public void stop()
-	{
-		stop = true;
-		//isRunning = false;
-		doCheckpoint();
-	}
-	public void run()
-	{
-		//isRunning = true;
-		while (!stop && cpm.isRunning())
-		{
-			if (pause)
-			{
-				synchronized (monitor)
-				{
-					try
-					{
-						monitor.wait();
-					}
-					catch (Exception e)
-					{
-					}
-				}
-			}
-			String command = doCheckpoint();
-			if (NOTFOUND.equals(command) == false)
-			{
-				interpretAndExecuteCommand(command);
-			}
-			try
-			{
-				Thread.sleep(checkpointFrequency);
-			}
-			catch (Exception e)
-			{
-			}
-		}
-		if ( UIMAFramework.getLogger().isLoggable(Level.FINEST) )
-		{
-			UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(), "process",
-			        CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_thread_terminating__FINEST",
-			        new Object[] {Thread.currentThread().getName() });
-		}
-	}
-	/**
-	 *  
-	 * 
-	 * @param aCommand
-	 */
-	private void interpretAndExecuteCommand(String aCommand)
-	{
-		if ( aCommand == null )
-		{
-			return;  // nothing to do
-		}
-		try
-		{
-			StringTokenizer st = new StringTokenizer(aCommand, " ");
-			while (st.hasMoreTokens())
-			{
-				String cmd = aCommand.trim().toLowerCase();
-				if ("die".equalsIgnoreCase(cmd))
-				{
-					cpm.stopIt();
-					deleteCheckpoint();
-					break;
-				}
-				else if ("halt".equalsIgnoreCase(cmd))
-				{
-					cpm.stopIt();
-					break;
-				}
-				else if (aCommand != null && aCommand.trim().startsWith("-D") )
-				{
-
-				
-					int pos = 0;
-					String value;
-					String key;
-					if ( (pos = aCommand.indexOf("=")) > -1 )
-					{
-						key = aCommand.substring(2,pos);
-						value = aCommand.substring(pos+1);
-						if ( value.trim().equalsIgnoreCase("off") && System.getProperties().containsKey(key))
-						{
-							if ( UIMAFramework.getLogger().isLoggable(Level.FINEST) )
-							{
-								UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(), "process",
-								        CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_disabling_key__FINEST",
-								        new Object[] {Thread.currentThread().getName(), key, value });
-
-							}
-							System.getProperties().remove(key);
-						}
-						else if ( value.trim().equalsIgnoreCase("on") && !System.getProperties().containsKey(key) )
-						{
-							if ( UIMAFramework.getLogger().isLoggable(Level.FINEST) )
-							{
-								UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(), "process",
-								        CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_enabling_key__FINEST",
-								        new Object[] {Thread.currentThread().getName(), key, value });
-							}
-							System.getProperties().put(key,value);
-						}
-					}
-					break;
-				}
-				break;
-			}
-		}
-		catch (Exception e)
-		{
-			e.printStackTrace();
-		}
-	}
-	public void deleteCheckpoint()
-	{
-		try
-		{
-			File inF = null;
-			inF = new File(fileName);
-			if (inF.exists())
-			{
-				inF.delete();
-			}
-		}
-		catch (Exception e)
-		{
-			e.printStackTrace();
-		}
-
-	}
-
-	public void pause()
-	{
-		pause = true;
-	}
-	public void resume()
-	{
-		synchronized (monitor)
-		{
-			if (pause)
-			{
-				try
-				{
-					monitor.notify();
-				}
-				catch (Exception e)
-				{
-				}
-				pause = false;
-			}
-		}
-
-	}
-
-	public String doCheckpoint()
-	{
-		File inF = null;
-		FileInputStream fis = null;
-		try
-		{
-			if ( UIMAFramework.getLogger().isLoggable(Level.FINEST) )
-			{
-				UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(), "process",
-				        CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_show_access_control_file__FINEST",
-				        new Object[] {Thread.currentThread().getName(), fileName});
-			}
-			inF = new File(fileName);
-			byte[] content = new byte[(int) inF.length()];
-			fis = new FileInputStream(inF);
-
-			fis.read(content);
-			return new String(content);
-
-		}
-		catch (FileNotFoundException e)
-		{
-			if ( UIMAFramework.getLogger().isLoggable(Level.FINEST) )
-			{
-				UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(), "process",
-				        CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_access_control_file_not_found__FINEST",
-				        new Object[] {Thread.currentThread().getName(), fileName});
-			}
-			return NOTFOUND;
-		}
-		catch (Exception e)
-		{
-			e.printStackTrace();
-		}
-		finally
-		{
-			if (fis != null)
-			{
-				try
-				{
-					fis.close();
-					inF.delete();
-				}
-				catch (Exception e)
-				{
-				}
-			}
-		}
-		return null;
-
-	}
-	public boolean exists()
-	{
-		try
-		{
-			new File(fileName);
-			return true;
-		}
-		catch (Exception e)
-		{
-		}
-		return false;
-	}
+public class DebugControlThread implements Runnable {
+  private final static String NOTFOUND = "NOT-FOUND";
+
+  private String fileName = null;
+
+  private boolean stop = false;
+
+  private int checkpointFrequency = 3000;
+
+  private boolean pause = false;
+
+  private String monitor = "";
+
+  // private boolean isRunning = false;
+  private CPMEngine cpm = null;
+
+  public DebugControlThread(CPMEngine aCpm, String aFilename, int aCheckpointFrequency) {
+    cpm = aCpm;
+    fileName = aFilename;
+    checkpointFrequency = aCheckpointFrequency;
+  }
+
+  public void start() throws RuntimeException {
+    if (fileName == null) {
+      if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
+        UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
+                        "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
+                        "UIMA_CPM_checkpoint_target_not_defined__FINEST",
+                        new Object[] { Thread.currentThread().getName() });
+      }
+      throw new RuntimeException(CpmLocalizedMessage.getLocalizedMessage(
+                      CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
+                      "UIMA_CPM_EXP_target_checkpoint_not_defined__WARNING", new Object[] { Thread
+                                      .currentThread().getName() }));
+    }
+    if (cpm == null) {
+      if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
+        UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
+                        "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
+                        "UIMA_CPM_invalid_cpm_instance__FINEST",
+                        new Object[] { Thread.currentThread().getName() });
+      }
+      throw new RuntimeException(CpmLocalizedMessage.getLocalizedMessage(
+                      CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_invalid_cpm__WARNING",
+                      new Object[] { Thread.currentThread().getName() }));
+    } else {
+      new Thread(this).start();
+    }
+  }
+
+  public void stop() {
+    stop = true;
+    // isRunning = false;
+    doCheckpoint();
+  }
+
+  public void run() {
+    // isRunning = true;
+    while (!stop && cpm.isRunning()) {
+      if (pause) {
+        synchronized (monitor) {
+          try {
+            monitor.wait();
+          } catch (Exception e) {
+          }
+        }
+      }
+      String command = doCheckpoint();
+      if (NOTFOUND.equals(command) == false) {
+        interpretAndExecuteCommand(command);
+      }
+      try {
+        Thread.sleep(checkpointFrequency);
+      } catch (Exception e) {
+      }
+    }
+    if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
+      UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
+                      "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
+                      "UIMA_CPM_thread_terminating__FINEST",
+                      new Object[] { Thread.currentThread().getName() });
+    }
+  }
+
+  /**
+   * 
+   * 
+   * @param aCommand
+   */
+  private void interpretAndExecuteCommand(String aCommand) {
+    if (aCommand == null) {
+      return; // nothing to do
+    }
+    try {
+      StringTokenizer st = new StringTokenizer(aCommand, " ");
+      while (st.hasMoreTokens()) {
+        String cmd = aCommand.trim().toLowerCase();
+        if ("die".equalsIgnoreCase(cmd)) {
+          cpm.stopIt();
+          deleteCheckpoint();
+          break;
+        } else if ("halt".equalsIgnoreCase(cmd)) {
+          cpm.stopIt();
+          break;
+        } else if (aCommand != null && aCommand.trim().startsWith("-D")) {
+
+          int pos = 0;
+          String value;
+          String key;
+          if ((pos = aCommand.indexOf("=")) > -1) {
+            key = aCommand.substring(2, pos);
+            value = aCommand.substring(pos + 1);
+            if (value.trim().equalsIgnoreCase("off") && System.getProperties().containsKey(key)) {
+              if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
+                UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST,
+                                this.getClass().getName(), "process",
+                                CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_disabling_key__FINEST",
+                                new Object[] { Thread.currentThread().getName(), key, value });
+
+              }
+              System.getProperties().remove(key);
+            } else if (value.trim().equalsIgnoreCase("on")
+                            && !System.getProperties().containsKey(key)) {
+              if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
+                UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST,
+                                this.getClass().getName(), "process",
+                                CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_enabling_key__FINEST",
+                                new Object[] { Thread.currentThread().getName(), key, value });
+              }
+              System.getProperties().put(key, value);
+            }
+          }
+          break;
+        }
+        break;
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+  }
+
+  public void deleteCheckpoint() {
+    try {
+      File inF = null;
+      inF = new File(fileName);
+      if (inF.exists()) {
+        inF.delete();
+      }
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+
+  }
+
+  public void pause() {
+    pause = true;
+  }
+
+  public void resume() {
+    synchronized (monitor) {
+      if (pause) {
+        try {
+          monitor.notify();
+        } catch (Exception e) {
+        }
+        pause = false;
+      }
+    }
+
+  }
+
+  public String doCheckpoint() {
+    File inF = null;
+    FileInputStream fis = null;
+    try {
+      if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
+        UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
+                        "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
+                        "UIMA_CPM_show_access_control_file__FINEST",
+                        new Object[] { Thread.currentThread().getName(), fileName });
+      }
+      inF = new File(fileName);
+      byte[] content = new byte[(int) inF.length()];
+      fis = new FileInputStream(inF);
+
+      fis.read(content);
+      return new String(content);
+
+    } catch (FileNotFoundException e) {
+      if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) {
+        UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(),
+                        "process", CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
+                        "UIMA_CPM_access_control_file_not_found__FINEST",
+                        new Object[] { Thread.currentThread().getName(), fileName });
+      }
+      return NOTFOUND;
+    } catch (Exception e) {
+      e.printStackTrace();
+    } finally {
+      if (fis != null) {
+        try {
+          fis.close();
+          inF.delete();
+        } catch (Exception e) {
+        }
+      }
+    }
+    return null;
+
+  }
+
+  public boolean exists() {
+    try {
+      new File(fileName);
+      return true;
+    } catch (Exception e) {
+    }
+    return false;
+  }
 
 }

Modified: incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/EOFToken.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/EOFToken.java?view=diff&rev=478226&r1=478225&r2=478226
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/EOFToken.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-cpe/src/main/java/org/apache/uima/collection/impl/cpm/engine/EOFToken.java Wed Nov 22 08:43:54 2006
@@ -20,12 +20,10 @@
 package org.apache.uima.collection.impl.cpm.engine;
 
 /**
- * Special class interpreted by the CPM's ProcessingUnit as the
- * end of processing. It is enqueued onto a queue from which 
- * the ProcessingUnit gets entities to process. The EOFToken is
- * placed in the queue by the ArtifactProducer when the either
- * the CollectionReader is done reading the collection or the
- * CPM has been instructed to terminate. 
+ * Special class interpreted by the CPM's ProcessingUnit as the end of processing. It is enqueued
+ * onto a queue from which the ProcessingUnit gets entities to process. The EOFToken is placed in
+ * the queue by the ArtifactProducer when the either the CollectionReader is done reading the
+ * collection or the CPM has been instructed to terminate.
  * 
  * 
  */