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 2014/12/10 15:18:32 UTC

svn commit: r1644418 - /uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jp/classloader/JobProcessDeployer.java

Author: cwiklik
Date: Wed Dec 10 14:18:32 2014
New Revision: 1644418

URL: http://svn.apache.org/r1644418
Log:
UIMA-4057 Added initialize()

Modified:
    uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jp/classloader/JobProcessDeployer.java

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jp/classloader/JobProcessDeployer.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jp/classloader/JobProcessDeployer.java?rev=1644418&r1=1644417&r2=1644418&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jp/classloader/JobProcessDeployer.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-container/src/main/java/org/apache/uima/ducc/container/jp/classloader/JobProcessDeployer.java Wed Dec 10 14:18:32 2014
@@ -34,9 +34,17 @@ public class JobProcessDeployer implemen
 	private static String M_DEPLOY="deploy";
 	private static String M_PROCESS="process";
 	private static String M_STOP="stop";
+	private static String M_INITIALIZE="initialize";
+	
     private boolean DEBUG = false;
-
-	public IUimaProcessor deploy(String userClasspath, String[] args, String clzToLoad) throws ServiceFailedInitialization {
+    Method processMethod = null;
+    Method stopMethod = null;
+    Method deployMethod = null;
+    Object uimaContainerInstance = null;
+    int scaleout=1;
+    
+    
+    public int initialize(String userClasspath, String[] args, String clzToLoad) throws ServiceFailedInitialization {
 		try {
 
 			URLClassLoader ucl = PrivateClassLoader.create(userClasspath);
@@ -51,22 +59,33 @@ public class JobProcessDeployer implemen
 					System.out.println("-----------:"+u.getFile());
 				}
 			}
+			Method initMethod = classToLaunch.getMethod(M_INITIALIZE, String[].class);
+			processMethod = classToLaunch.getMethod(M_PROCESS, Object.class);
+			stopMethod = classToLaunch.getMethod(M_STOP);
+			deployMethod = classToLaunch.getMethod(M_DEPLOY);
+
+			uimaContainerInstance = classToLaunch.newInstance();
+			Object s = initMethod.invoke(uimaContainerInstance,
+					(Object) args);
+	        this.scaleout = (Integer)s;
 	        
-			Method deployMethod = classToLaunch.getMethod(M_DEPLOY, String[].class);
-			Method processMethod = classToLaunch.getMethod(M_PROCESS, Object.class);
-			Method stopMethod = classToLaunch.getMethod(M_STOP);
+			return scaleout;
 			
-			Object uimaContainerInstance = classToLaunch.newInstance();
-			// This blocks until Uima AS container is fully initialized
-			Object scaleout = deployMethod.invoke(uimaContainerInstance,
-					(Object) args);
-
-			return new UimaProcessor(uimaContainerInstance,processMethod,stopMethod,(Integer)scaleout);
-	
 		} catch( Exception e) {
 			throw new ServiceFailedInitialization(e);
 		}
 
+    	
+    }
+    public IUimaProcessor deploy() throws ServiceFailedInitialization {
+		try {
+	    	// This blocks until Uima AS container is fully initialized
+			deployMethod.invoke(uimaContainerInstance);
+	    	return new UimaProcessor(uimaContainerInstance,processMethod,stopMethod,scaleout);
+			
+		} catch( Exception e) {
+			throw new ServiceFailedInitialization(e);
+		}
 	}
 	
 }