You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by ea...@apache.org on 2009/06/24 19:32:40 UTC

svn commit: r788094 - /incubator/uima/sandbox/trunk/uima-as/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceController.java

Author: eae
Date: Wed Jun 24 17:32:40 2009
New Revision: 788094

URL: http://svn.apache.org/viewvc?rev=788094&view=rev
Log:
UIMA-1399

Modified:
    incubator/uima/sandbox/trunk/uima-as/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceController.java

Modified: incubator/uima/sandbox/trunk/uima-as/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceController.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/uima-as/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceController.java?rev=788094&r1=788093&r2=788094&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/uima-as/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceController.java (original)
+++ incubator/uima/sandbox/trunk/uima-as/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/UimacppServiceController.java Wed Jun 24 17:32:40 2009
@@ -56,6 +56,8 @@
  * 
  */
 public class UimacppServiceController implements ControllerLifecycle, DisposableBean {
+
+  private static final String STARTING_DIRECTORY = "UIMACPP_STARTING_DIRECTORY";
   protected ServerSocket server;
 
   private int port;
@@ -73,6 +75,8 @@
   private StderrHandler stderrHandler;
 
   private ProcessBuilder builder;
+  
+  private String startingDirectory;
 
   private String aeDesc;
 
@@ -103,7 +107,7 @@
   private Exception InitializedStatus = null;
   
   /**
-   * Configure and start a Uima C++ service that connects to an ActiveMG
+   * Configure and start a Uima C++ service that connects to an ActiveMQ
    * queue broker. 
    * This class  initializes the process environment and starts a process 
    * to deploy the C++ service.
@@ -140,6 +144,7 @@
       this.processCasErrorWindow = processCasErrorWindow;
       this.terminateOnCPCError = terminateOnCPCError;
       this.initialFsHeapSize = initialFsHeapSize;
+      this.startingDirectory = envVarMap.get(STARTING_DIRECTORY);
       
       /* start a listener */
       server = new ServerSocket(0);
@@ -206,7 +211,7 @@
       {
         //  If there is an exception, notify listener with failure
         if ( e != null ) {
-          (this.listeners.get(i)).notifyOnInitializationFailure( e);
+          (this.listeners.get(i)).notifyOnInitializationFailure(e);
         }
         // else, Success!
         else {
@@ -268,6 +273,7 @@
       this.processCasErrorWindow = processCasErrorWindow;
       this.terminateOnCPCError = terminateOnCPCError;
       this.initialFsHeapSize = initialFsHeapSize;
+      this.startingDirectory = envVarMap.get(STARTING_DIRECTORY);
       this.jmxMgmt = jmxManagement;
 
       /* start a listener */
@@ -332,7 +338,7 @@
         uimaLogger.log(Level.WARNING,"UimacppServiceController failed to register the JMX MBean.");
         //throw new ResourceInitializationException( new IOException("JmxManagement object is invalid."));
       }
-      
+
     } catch (IOException e) {
       throw new ResourceInitializationException(e);
     } catch (UIMAException e) {
@@ -560,6 +566,16 @@
       Thread t2 = new Thread(handler2);
       t2.start();
     
+      //setup starting directory if specified.
+      if (this.startingDirectory != null && this.startingDirectory.length() > 0) {
+        File startingDir = new File(this.startingDirectory);
+        if (!startingDir.exists()) {
+        	throw new ResourceInitializationException(new IOException(
+            this.startingDirectory + " Uimacpp Starting Directory not found. + ")); 	
+        }
+        builder.directory(startingDir);
+      }
+      
       uimacppProcess = builder.start();
       if (uimacppProcess == null) {
         throw new UIMAException(new Throwable("Could not fork process."));