You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by de...@apache.org on 2013/04/12 16:39:11 UTC
svn commit: r1467288 - in
/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli:
./ aio/
Author: degenaro
Date: Fri Apr 12 14:39:10 2013
New Revision: 1467288
URL: http://svn.apache.org/r1467288
Log:
UIMA-2793 Support --all_in_one local
Added:
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOne.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOneLauncher.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/CasGenerator.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/CasPipeline.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/DDParser.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/IMessageHandler.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/MessageHandler.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/Plist.java
Modified:
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobSubmit.java
uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobSubmit.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobSubmit.java?rev=1467288&r1=1467287&r2=1467288&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobSubmit.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/DuccJobSubmit.java Fri Apr 12 14:39:10 2013
@@ -22,6 +22,7 @@ import java.lang.management.ManagementFa
import java.util.ArrayList;
import java.util.Properties;
+import org.apache.uima.ducc.cli.aio.AllInOneLauncher;
import org.apache.uima.ducc.common.utils.DuccPropertiesResolver;
import org.apache.uima.ducc.transport.event.IDuccContext.DuccContext;
import org.apache.uima.ducc.transport.event.SubmitJobDuccEvent;
@@ -43,10 +44,12 @@ public class DuccJobSubmit
// this.duccMessageProcessor = duccMessageProcessor;
// }
- UiOption[] opts_release = new UiOption[] {
+ public static UiOption[] opts_release = new UiOption[] {
UiOption.Help,
UiOption.Debug,
+ UiOption.AllInOne,
+
UiOption.ProcessDebug,
UiOption.ProcessAttachConsole,
UiOption.DriverDebug,
@@ -59,14 +62,15 @@ public class DuccJobSubmit
UiOption.WorkingDirectory,
UiOption.Jvm,
- UiOption.JvmArgs,
UiOption.Classpath,
UiOption.Environment,
+ UiOption.DriverJvmArgs,
UiOption.DriverDescriptorCR,
UiOption.DriverDescriptorCROverrides,
UiOption.DriverExceptionHandler,
+ UiOption.ProcessJvmArgs,
UiOption.ProcessMemorySize,
UiOption.ProcessDD,
UiOption.ProcessDescriptorCM,
@@ -90,10 +94,12 @@ public class DuccJobSubmit
UiOption.ClasspathOrder,
};
- UiOption[] opts_beta = new UiOption[] {
+ public static UiOption[] opts_beta = new UiOption[] {
UiOption.Help,
UiOption.Debug,
+ UiOption.AllInOne,
+
UiOption.ProcessDebug,
UiOption.ProcessAttachConsole,
UiOption.DriverDebug,
@@ -144,7 +150,7 @@ public class DuccJobSubmit
UiOption.ClasspathOrder,
};
- UiOption[] opts = opts_release;
+ public static UiOption[] opts = opts_release;
public DuccJobSubmit(ArrayList<String> args)
throws Exception
@@ -520,28 +526,46 @@ public class DuccJobSubmit
return rc;
}
+ private boolean isAllInOne() {
+ return jobRequestProperties.containsKey(UiOption.AllInOne.pname());
+ }
+
+ private static void main_job(String[] args, DuccJobSubmit ds) throws Exception {
+ boolean rc = ds.execute();
+ // If the return is 'true' then as best the API can tell, the submit worked
+ if ( rc ) {
+ // Fetch the Ducc ID
+ System.out.println("Job " + ds.getDuccId() + " submitted");
+ int exit_code = 0; // first best guess, waiting for completion.
+ if ( ds.waitForCompletion() ) {
+ exit_code = ds.getReturnCode(); // updated from wait.
+ System.out.println("Job return code: " + exit_code);
+ }
+ System.exit(exit_code);
+ } else {
+ System.out.println("Could not submit job");
+ System.exit(1);
+ }
+ }
+
+ private static void main_aio(String[] args) throws Exception {
+ AllInOneLauncher allInOneLauncher = new AllInOneLauncher(args);
+ allInOneLauncher.go();
+ }
+
public static void main(String[] args) {
try {
DuccJobSubmit ds = new DuccJobSubmit(args, null);
- boolean rc = ds.execute();
-
- // If the return is 'true' then as best the API can tell, the submit worked
- if ( rc ) {
- // Fetch the Ducc ID
- System.out.println("Job " + ds.getDuccId() + " submitted");
- int exit_code = 0; // first best guess, waiting for completion.
- if ( ds.waitForCompletion() ) {
- exit_code = ds.getReturnCode(); // updated from wait.
- System.out.println("Job return code: " + exit_code);
- }
- System.exit(exit_code);
- } else {
- System.out.println("Could not submit job");
- System.exit(1);
- }
- } catch (Exception e) {
- System.out.println("Cannot initialize: " + e.getMessage());
+ if(ds.isAllInOne()) {
+ main_aio(args);
+ }
+ else {
+ main_job(args, ds);
+ }
+ }
+ catch(Exception e) {
+ System.out.println("Cannot initialize: " + e.getMessage());
System.exit(1);
- }
+ }
}
}
Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java?rev=1467288&r1=1467287&r2=1467288&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/IUiOptions.java Fri Apr 12 14:39:10 2013
@@ -56,7 +56,18 @@ public interface IUiOptions
public boolean multiargs() { return false; }
public boolean required() { return false; }
},
-
+
+ AllInOne {
+ public String pname() { return "all_in_one"; }
+ public String argname() { return "local|remote"; }
+ public String description() { return "Run driver and pipeline in single process."; }
+ public String example() { return null; }
+ public String deflt() { return null; }
+ public String label() { return name(); }
+ public boolean multiargs() { return false; }
+ public boolean required() { return false; }
+ },
+
Autostart {
public String pname() { return "autostart"; }
public String argname() { return "boolean: true or false"; }
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOne.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOne.java?rev=1467288&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOne.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOne.java Fri Apr 12 14:39:10 2013
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.cli.aio;
+
+import java.io.IOException;
+
+import org.apache.commons.cli.MissingArgumentException;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.collection.CollectionException;
+import org.apache.uima.ducc.cli.CliBase;
+import org.apache.uima.ducc.cli.DuccJobSubmit;
+import org.apache.uima.ducc.cli.aio.IMessageHandler.Level;
+import org.apache.uima.ducc.cli.aio.IMessageHandler.Toggle;
+import org.apache.uima.ducc.transport.event.cli.JobRequestProperties;
+import org.apache.uima.resource.ResourceInitializationException;
+
+public class AllInOne extends CliBase {
+
+ private static String cid = AllInOne.class.getSimpleName();
+
+ private static String or_port = "ducc.orchestrator.http.port";
+ private static String or_host = "ducc.orchestrator.node";
+
+ private IMessageHandler mh = new MessageHandler();
+
+ private JobRequestProperties jobRequestProperties = new JobRequestProperties();
+
+ CasGenerator casGenerator;
+ CasPipeline casPipeline;
+
+ public AllInOne(String[] args) throws Exception {
+ UiOption[] opts = DuccJobSubmit.opts;
+ init(this.getClass().getName(), opts, args, jobRequestProperties, or_host, or_port, "or", consoleCb, null);
+ }
+
+ private void examine_debug() {
+ String mid = "examine_debug";
+ debug = jobRequestProperties.containsKey(UiOption.Debug.pname());
+ if(debug) {
+ mh.setLevel(Level.FrameworkInfo, Toggle.On);
+ mh.setLevel(Level.FrameworkDebug, Toggle.On);
+ mh.setLevel(Level.FrameworkError, Toggle.On);
+ mh.setLevel(Level.FrameworkWarn, Toggle.On);
+ String message = "true";
+ mh.frameworkDebug(cid, mid, message);
+ }
+ else {
+ String message = "false";
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_timestamp() {
+ String mid = "examine_timestamp";
+ boolean timestamp = jobRequestProperties.containsKey(UiOption.Timestamp.pname());
+ if(timestamp) {
+ mh.setTimestamping(Toggle.On);
+ String message = "true";
+ mh.frameworkDebug(cid, mid, message);
+ }
+ else {
+ String message = "false";
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine() throws MissingArgumentException, IllegalArgumentException {
+ String mid = "examine";
+ mh.frameworkTrace(cid, mid, "enter");
+ examine_debug();
+ examine_timestamp();
+ mh.frameworkTrace(cid, mid, "exit");
+ }
+
+ private void initialize() throws Exception {
+ String mid = "initialize";
+ mh.frameworkTrace(cid, mid, "enter");
+ // Generator
+ casGenerator = new CasGenerator(jobRequestProperties, mh);
+ casGenerator.initialize();
+ // Pipeline
+ casPipeline = new CasPipeline(jobRequestProperties, mh);
+ casPipeline.initialize();
+ mh.frameworkTrace(cid, mid, "exit");
+ }
+
+ private void process() throws CollectionException, ResourceInitializationException, IOException, AnalysisEngineProcessException {
+ String mid = "process";
+ mh.frameworkTrace(cid, mid, "enter");
+ int count = 0;
+ int total = casGenerator.getTotal();
+ mh.frameworkInfo(cid, mid, "total:"+total);
+ CAS cas = null;
+ while(casGenerator.hasNext()) {
+ cas = casGenerator.getCas(cas);
+ mh.frameworkInfo(cid, mid, "cas:"+count);
+ casPipeline.process(cas);
+ count++;
+ }
+ mh.frameworkTrace(cid, mid, "exit");
+ }
+
+ public void go() throws Exception {
+ String mid = "go";
+ mh.frameworkTrace(cid, mid, "enter");
+ examine();
+ initialize();
+ process();
+ mh.frameworkTrace(cid, mid, "exit");
+ }
+
+
+ public static void main(String[] args) throws Exception {
+ AllInOne allInOne = new AllInOne(args);
+ allInOne.go();
+ }
+
+ @Override
+ protected boolean execute() throws Exception {
+ return false;
+ }
+
+}
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOneLauncher.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOneLauncher.java?rev=1467288&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOneLauncher.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/AllInOneLauncher.java Fri Apr 12 14:39:10 2013
@@ -0,0 +1,671 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.cli.aio;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Map;
+
+import org.apache.commons.cli.MissingArgumentException;
+import org.apache.uima.ducc.cli.CliBase;
+import org.apache.uima.ducc.cli.DuccJobSubmit;
+import org.apache.uima.ducc.cli.aio.IMessageHandler.Level;
+import org.apache.uima.ducc.cli.aio.IMessageHandler.Toggle;
+import org.apache.uima.ducc.transport.event.cli.JobRequestProperties;
+
+public class AllInOneLauncher extends CliBase {
+
+ private static String cid = AllInOneLauncher.class.getSimpleName();
+
+ private static String or_port = "ducc.orchestrator.http.port";
+ private static String or_host = "ducc.orchestrator.node";
+
+ private static String remote = "remote";
+ private static String local = "local";
+
+ private String allInOneType = null;
+
+ private String jvm = null;
+ private String working_directory = null;
+
+ private String driver_jvm_args = null;
+ private String process_jvm_args = null;
+ private String jvm_args = null;
+
+ private String driver_classpath = null;
+ private String process_classpath = null;
+ private String classpath = null;
+
+ private String driver_environment = null;
+ private String process_environment = null;
+ private String environment = null;
+
+ private String driver_descriptor_CR = null;
+ private String driver_descriptor_CR_overrides = null;
+
+ private String process_descriptor_CM = null;
+ private String process_descriptor_CM_overrides = null;
+
+ private String process_descriptor_AE = null;
+ private String process_descriptor_AE_overrides = null;
+
+ private String process_descriptor_CC = null;
+ private String process_descriptor_CC_overrides = null;
+
+ private String process_DD = null;
+
+ private boolean classpath_user_first = true;
+
+ private IMessageHandler mh = new MessageHandler();
+
+ private JobRequestProperties jobRequestProperties = new JobRequestProperties();
+
+ private String[] args = new String[0];
+ private UiOption[] opts = DuccJobSubmit.opts;
+
+ public AllInOneLauncher(String[] args) throws Exception {
+ this.args = args;
+ init(this.getClass().getName(), opts, args, jobRequestProperties, or_host, or_port, "or", consoleCb, null);
+ }
+
+ private void examine_debug() {
+ String mid = "examine_debug";
+ debug = jobRequestProperties.containsKey(UiOption.Debug.pname());
+ if(debug) {
+ mh.setLevel(Level.FrameworkInfo, Toggle.On);
+ mh.setLevel(Level.FrameworkDebug, Toggle.On);
+ mh.setLevel(Level.FrameworkError, Toggle.On);
+ mh.setLevel(Level.FrameworkWarn, Toggle.On);
+ String message = "true";
+ mh.frameworkDebug(cid, mid, message);
+ }
+ else {
+ String message = "false";
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_timestamp() {
+ String mid = "examine_timestamp";
+ boolean timestamp = jobRequestProperties.containsKey(UiOption.Timestamp.pname());
+ if(timestamp) {
+ mh.setTimestamping(Toggle.On);
+ String message = "true";
+ mh.frameworkDebug(cid, mid, message);
+ }
+ else {
+ String message = "false";
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_allInOne() throws MissingArgumentException, IllegalArgumentException {
+ String mid = "examine_allInOne";
+ allInOneType = jobRequestProperties.getProperty(UiOption.AllInOne.pname());
+ if(allInOneType == null) {
+ throw new MissingArgumentException(UiOption.AllInOne.pname());
+ }
+ if(allInOneType.equalsIgnoreCase(local)) {
+ String message = allInOneType;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ else if(allInOneType.equalsIgnoreCase(remote)) {
+ String message = allInOneType;
+ mh.frameworkDebug(cid, mid, message);
+ //TODO
+ throw new IllegalArgumentException(UiOption.AllInOne.pname()+": "+allInOneType+" not supported");
+ }
+ else {
+ throw new IllegalArgumentException(UiOption.AllInOne.pname()+": "+allInOneType);
+ }
+ }
+
+ private void examine_jvm() {
+ String mid = "examine_jvm";
+ String key = UiOption.Jvm.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ jvm = jobRequestProperties.getProperty(key);
+ String message = jvm;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ else {
+ jvm = System.getProperty("java.home")+File.separator+"bin"+File.separator+"java";
+ String message = jvm;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_working_directory() {
+ String mid = "examine_working_directory";
+ String key = UiOption.WorkingDirectory.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ working_directory = jobRequestProperties.getProperty(key);
+ String message = working_directory;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ else {
+ working_directory = System.getProperty("user.dir");
+ String message = working_directory;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_driver_jvm_args() {
+ String mid = "examine_driver_jvm_args";
+ String key = UiOption.DriverJvmArgs.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ driver_jvm_args = jobRequestProperties.getProperty(key);
+ String message = driver_jvm_args;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_process_jvm_args() {
+ String mid = "examine_process_jvm_args";
+ String key = UiOption.ProcessJvmArgs.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ process_jvm_args = jobRequestProperties.getProperty(key);
+ String message = process_jvm_args;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_jvm_args() {
+ String mid = "examine_jvm_args";
+ String key = UiOption.JvmArgs.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ jvm_args = jobRequestProperties.getProperty(key);
+ String message = jvm_args;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ if(jobRequestProperties.containsKey(key)) {
+ throw new IllegalArgumentException(UiOption.JvmArgs.pname()+" disallowed");
+ }
+ }
+
+ private void examine_driver_classpath() {
+ String mid = "examine_driver_classpath";
+ String key = UiOption.DriverClasspath.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ driver_classpath = jobRequestProperties.getProperty(key);
+ String message = driver_classpath;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_process_classpath() {
+ String mid = "examine_process_classpath";
+ String key = UiOption.ProcessClasspath.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ process_classpath = jobRequestProperties.getProperty(key);
+ String message = process_classpath;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_classpath() {
+ String mid = "examine_classpath";
+ String key = UiOption.Classpath.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ classpath = jobRequestProperties.getProperty(key);
+ String message = classpath;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_classpath_order() {
+ String mid = "examine_classpath_order";
+ String key = UiOption.ClasspathOrder.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ String value = jobRequestProperties.getProperty(key);
+ if(value != null) {
+ if(value.equalsIgnoreCase(ClasspathOrderParms.UserBeforeDucc.name())) {
+ classpath_user_first = true;
+ }
+ else if(value.equalsIgnoreCase(ClasspathOrderParms.DuccBeforeUser.name())) {
+ classpath_user_first = false;
+ }
+ else {
+ throw new IllegalArgumentException(UiOption.ClasspathOrder.pname()+": "+value);
+ }
+ }
+ String message = value;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_driver_environment() {
+ String mid = "examine_driver_environment";
+ String key = UiOption.DriverEnvironment.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ driver_environment = jobRequestProperties.getProperty(key);
+ String message = driver_environment;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_process_environment() {
+ String mid = "examine_process_environment";
+ String key = UiOption.ProcessEnvironment.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ process_environment = jobRequestProperties.getProperty(key);
+ String message = process_environment;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void reconcile_jvm_args() {
+ String mid = "reconcile_jvm_args";
+ if(process_jvm_args != null) {
+ jvm_args = process_jvm_args;
+ String message = "using "+UiOption.ProcessJvmArgs.pname()+": "+jvm_args;
+ mh.frameworkInfo(cid, mid, message);
+ }
+ if(driver_jvm_args != null) {
+ String message = "ignoring "+UiOption.DriverJvmArgs.pname()+": "+jvm_args;
+ mh.frameworkWarn(cid, mid, message);
+ }
+ /*
+ if(jvm_args != null) {
+ if(process_jvm_args != null) {
+ throw new IllegalArgumentException(UiOption.ProcessJvmArgs.pname());
+ }
+ else if(driver_jvm_args != null) {
+ throw new IllegalArgumentException(UiOption.DriverJvmArgs.pname());
+ }
+ }
+ else if(process_jvm_args != null) {
+ jvm_args = process_jvm_args;
+ String message = "using process jvm_args: "+jvm_args;
+ mh.frameworkInfo(cid, mid, message);
+ }
+ else if(driver_jvm_args != null) {
+ jvm_args = driver_jvm_args;
+ String message = "using driver jvm_args: "+jvm_args;
+ mh.frameworkInfo(cid, mid, message);
+ }
+ else {
+ // no default
+ }
+ */
+ }
+
+ private void reconcile_classpath() {
+ String mid = "reconcile_classpath";
+ if(classpath != null) {
+ if(process_classpath != null) {
+ throw new IllegalArgumentException(UiOption.ProcessClasspath.pname());
+ }
+ else if(driver_classpath != null) {
+ throw new IllegalArgumentException(UiOption.DriverClasspath.pname());
+ }
+ String message = "using classpath";
+ mh.frameworkDebug(cid, mid, message);
+ }
+ else if(process_classpath != null) {
+ classpath = process_classpath;
+ String message = "using process classpath";
+ mh.frameworkDebug(cid, mid, message);
+ }
+ else if(driver_classpath != null) {
+ classpath = driver_classpath;
+ String message = "using driver classpath";
+ mh.frameworkDebug(cid, mid, message);
+ }
+ if(classpath != null) {
+ if(classpath_user_first) {
+ classpath = System.getProperty("java.class.path")+File.pathSeparatorChar+classpath;
+ String message = "user first";
+ mh.frameworkInfo(cid, mid, message);
+ }
+ else {
+ classpath = classpath+File.pathSeparatorChar+System.getProperty("java.class.path");
+ String message = "user last";
+ mh.frameworkInfo(cid, mid, message);
+ }
+ }
+ else {
+ classpath = System.getProperty("java.class.path");
+ String message = "user only";
+ mh.frameworkInfo(cid, mid, message);
+ }
+ }
+
+ private void reconcile_environment() {
+ String mid = "reconcile_environment";
+ if(process_environment != null) {
+ environment = process_environment;
+ String message = "using process environment: "+environment;
+ mh.frameworkInfo(cid, mid, message);
+ }
+ else if(driver_environment != null) {
+ environment = driver_environment;
+ String message = "using driver environment: "+environment;
+ mh.frameworkInfo(cid, mid, message);
+ }
+ }
+
+ private void examine_driver_descriptor_CR() {
+ String mid = "examine_driver_descriptor_CR";
+ String key = UiOption.DriverDescriptorCR.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ driver_descriptor_CR = jobRequestProperties.getProperty(key);
+ String message = key+"="+driver_descriptor_CR;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_driver_descriptor_CR_overrides() {
+ String mid = "examine_driver_descriptor_CR_overrides";
+ String key = UiOption.DriverDescriptorCROverrides.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ driver_descriptor_CR_overrides = jobRequestProperties.getProperty(key);
+ String message = key+"="+driver_descriptor_CR_overrides;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_process_descriptor_CM() {
+ String mid = "examine_process_descriptor_CM";
+ String key = UiOption.ProcessDescriptorCM.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ process_descriptor_CM = jobRequestProperties.getProperty(key);
+ String message = key+"="+process_descriptor_CM;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_process_descriptor_CM_overrides() {
+ String mid = "examine_process_descriptor_CMOverrides";
+ String key = UiOption.ProcessDescriptorCMOverrides.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ process_descriptor_CM_overrides = jobRequestProperties.getProperty(key);
+ String message = key+"="+process_descriptor_CM_overrides;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_process_descriptor_AE() {
+ String mid = "examine_process_descriptor_AE";
+ String key = UiOption.ProcessDescriptorAE.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ process_descriptor_AE = jobRequestProperties.getProperty(key);
+ String message = key+"="+process_descriptor_AE;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_process_descriptor_AE_overrides() {
+ String mid = "examine_process_descriptor_AE_overrides";
+ String key = UiOption.ProcessDescriptorAEOverrides.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ process_descriptor_AE_overrides = jobRequestProperties.getProperty(key);
+ String message = key+"="+process_descriptor_AE_overrides;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_process_descriptor_CC() {
+ String mid = "examine_process_descriptor_CC";
+ String key = UiOption.ProcessDescriptorCC.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ process_descriptor_CC = jobRequestProperties.getProperty(key);
+ String message = key+"="+process_descriptor_CC;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_process_descriptor_CC_overrides() {
+ String mid = "examine_process_descriptor_CC_overrides";
+ String key = UiOption.ProcessDescriptorCCOverrides.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ process_descriptor_CC_overrides = jobRequestProperties.getProperty(key);
+ String message = key+"="+process_descriptor_CC_overrides;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void examine_process_DD() {
+ String mid = "examine_process_DD";
+ String key = UiOption.ProcessDD.pname();
+ if(jobRequestProperties.containsKey(key)) {
+ process_DD = jobRequestProperties.getProperty(key);
+ String message = key+"="+process_DD;
+ mh.frameworkDebug(cid, mid, message);
+ }
+ }
+
+ private void reconcile_descriptors() throws MissingArgumentException {
+ if(driver_descriptor_CR == null) {
+ throw new MissingArgumentException(UiOption.DriverDescriptorCR.pname());
+ }
+ if(process_DD != null) {
+ if(process_descriptor_CM != null) {
+ throw new IllegalArgumentException(UiOption.ProcessDescriptorCM.pname());
+ }
+ if(process_descriptor_AE != null) {
+ throw new IllegalArgumentException(UiOption.ProcessDescriptorAE.pname());
+ }
+ if(process_descriptor_CC != null) {
+ throw new IllegalArgumentException(UiOption.ProcessDescriptorCC.pname());
+ }
+ }
+ else {
+ if(process_descriptor_CM == null) {
+ if(process_descriptor_CM_overrides != null) {
+ throw new IllegalArgumentException(UiOption.ProcessDescriptorCMOverrides.pname());
+ }
+ }
+ if(process_descriptor_AE == null) {
+ if(process_descriptor_AE_overrides != null) {
+ throw new IllegalArgumentException(UiOption.ProcessDescriptorAEOverrides.pname());
+ }
+ }
+ if(process_descriptor_CC == null) {
+ if(process_descriptor_CC_overrides != null) {
+ throw new IllegalArgumentException(UiOption.ProcessDescriptorCCOverrides.pname());
+ }
+ }
+ if(process_descriptor_CM == null) {
+ if(process_descriptor_AE == null) {
+ if(process_descriptor_CC == null) {
+ throw new MissingArgumentException(UiOption.ProcessDescriptorAE.pname());
+ }
+ }
+ }
+ }
+ }
+
+ private void examine() throws MissingArgumentException, IllegalArgumentException {
+ String mid = "examine";
+ mh.frameworkTrace(cid, mid, "enter");
+
+ // debug & timestamp
+ examine_debug();
+ examine_timestamp();
+
+ // all_in_one
+ examine_allInOne();
+
+ // jvm
+ examine_jvm();
+
+ // working_directory
+ examine_working_directory();
+
+ // jvm_args
+ examine_driver_jvm_args();
+ examine_process_jvm_args();
+ examine_jvm_args();
+ reconcile_jvm_args();
+
+ // classpath
+ examine_driver_classpath();
+ examine_process_classpath();
+ examine_classpath();
+ examine_classpath_order();
+ reconcile_classpath();
+
+ // environment
+ examine_driver_environment();
+ examine_process_environment();
+ reconcile_environment();
+
+ // uima
+ examine_driver_descriptor_CR();
+ examine_driver_descriptor_CR_overrides();
+ examine_process_descriptor_CM();
+ examine_process_descriptor_CM_overrides();
+ examine_process_descriptor_AE();
+ examine_process_descriptor_AE_overrides();
+ examine_process_descriptor_CC();
+ examine_process_descriptor_CC_overrides();
+ examine_process_DD();
+ reconcile_descriptors();
+
+ mh.frameworkTrace(cid, mid, "exit");
+ }
+
+ private void launch_local() throws IOException {
+ String mid = "launch_local";
+ mh.frameworkTrace(cid, mid, "enter");
+ String message = "local";
+ mh.frameworkDebug(cid, mid, message);
+
+ ArrayList<String> commandArray = new ArrayList<String>();
+ commandArray.add(jvm);
+
+ commandArray.add("-classpath");
+ commandArray.add(classpath);
+
+ String[] cp = classpath.split(":");
+ for(String c : cp) {
+ message = "classpath: "+c;
+ mh.frameworkDebug(cid, mid, message);
+ }
+
+ if(jvm_args != null) {
+ String[] jvmargs = jvm_args.split(" ");
+ for(String jvmarg : jvmargs) {
+ message = "jvmarg: "+jvmarg;
+ mh.frameworkDebug(cid, mid, message);
+ commandArray.add(jvmarg);
+ }
+ }
+
+ commandArray.add("org.apache.uima.ducc.cli.aio.AllInOne");
+
+ for(String arg : args) {
+ commandArray.add(arg);
+ }
+
+ String[] command = commandArray.toArray(new String[0]);
+ ProcessBuilder pb = new ProcessBuilder( command );
+ if(working_directory != null) {
+ message = "working directory: "+working_directory;
+ mh.frameworkDebug(cid, mid, message);
+ File wd = new File(working_directory);
+ pb.directory(wd);
+ }
+
+ if(environment != null) {
+ Map<String,String> env = pb.environment();
+ env.clear();
+ String[]envVars = environment.split(" ");
+ for(String envVar : envVars) {
+ String[] nvp = envVar.trim().split("=");
+ if(nvp.length != 2) {
+ message = "invalid environment variable specified: "+envVar;
+ mh.error(cid, mid, message);
+ throw new IllegalArgumentException("invalid environment specified");
+ }
+ String name = nvp[0];
+ String value = nvp[1];
+ message = "environment: "+name+"="+value;
+ mh.info(cid, mid, message);
+ env.put(name, value);
+ }
+ }
+
+ Process process = pb.start();
+
+ String line;
+
+ InputStream is = process.getInputStream();
+ InputStreamReader isr = new InputStreamReader(is);
+ BufferedReader ibr = new BufferedReader(isr);
+ while ((line = ibr.readLine()) != null) {
+ System.out.println(line);
+ }
+
+ InputStream es = process.getErrorStream();
+ InputStreamReader esr = new InputStreamReader(es);
+ BufferedReader ebr = new BufferedReader(esr);
+ while ((line = ebr.readLine()) != null) {
+ System.err.println(line);
+ }
+ mh.frameworkTrace(cid, mid, "exit");
+ }
+
+ private void launch_remote() {
+ String mid = "launch_remote";
+ mh.frameworkTrace(cid, mid, "enter");
+ String message = "type "+allInOneType+" not supported";
+ mh.error(cid, mid, message);
+ mh.frameworkTrace(cid, mid, "exit");
+ }
+
+ private void launch() throws IOException {
+ String mid = "launch";
+ mh.frameworkTrace(cid, mid, "enter");
+ if(allInOneType.equalsIgnoreCase(local)) {
+ launch_local();
+ }
+ else if(allInOneType.equalsIgnoreCase(remote)) {
+ launch_remote();
+ }
+ else {
+ String message = "type "+allInOneType+" not supported";
+ mh.error(cid, mid, message);
+ }
+ mh.frameworkTrace(cid, mid, "exit");
+ }
+
+ public void go() throws MissingArgumentException, IllegalArgumentException, IOException {
+ String mid = "go";
+ mh.frameworkTrace(cid, mid, "enter");
+ examine();
+ launch();
+ mh.frameworkTrace(cid, mid, "exit");
+ }
+
+ public static void main(String[] args) throws Exception {
+ AllInOneLauncher allInOneLauncher = new AllInOneLauncher(args);
+ allInOneLauncher.go();
+ }
+
+ @Override
+ protected boolean execute() throws Exception {
+ return false;
+ }
+}
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/CasGenerator.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/CasGenerator.java?rev=1467288&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/CasGenerator.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/CasGenerator.java Fri Apr 12 14:39:10 2013
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.cli.aio;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.TreeMap;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.collection.CollectionException;
+import org.apache.uima.collection.CollectionReader;
+import org.apache.uima.ducc.cli.IUiOptions.UiOption;
+import org.apache.uima.ducc.common.uima.UimaUtils;
+import org.apache.uima.resource.ResourceConfigurationException;
+import org.apache.uima.resource.ResourceCreationSpecifier;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.resource.metadata.ConfigurationParameter;
+import org.apache.uima.resource.metadata.ConfigurationParameterDeclarations;
+import org.apache.uima.resource.metadata.ConfigurationParameterSettings;
+import org.apache.uima.resource.metadata.FsIndexDescription;
+import org.apache.uima.resource.metadata.TypePriorities;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.util.CasCreationUtils;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.Progress;
+import org.apache.uima.util.XMLInputSource;
+import org.apache.uima.util.XMLParser;
+
+public class CasGenerator {
+
+ public static String cid = CasGenerator.class.getSimpleName();
+
+ protected IMessageHandler mh = new MessageHandler();
+ protected Properties properties = new Properties();
+
+ private CollectionReader cr;
+ private TypePriorities cr_tp;
+ private TypeSystemDescription cr_tsd;
+ private FsIndexDescription[] cr_fid;
+ private Properties cr_properties = new Properties();
+
+ private int total;
+
+ public CasGenerator(Properties properties, IMessageHandler mh) {
+ if(properties != null) {
+ this.properties = properties;
+ }
+ if(mh != null) {
+ this.mh = mh;
+ }
+ }
+
+ public void initialize() throws InvalidXMLException, ResourceConfigurationException, ResourceInitializationException {
+ String mid = "initialize";
+ mh.frameworkTrace(cid, mid, "enter");
+ String crDescriptor = properties.getProperty(UiOption.DriverDescriptorCR.pname());
+ String crOverrides = properties.getProperty(UiOption.DriverDescriptorCROverrides.pname());
+ XMLParser xmlParser = UIMAFramework.getXMLParser();
+ XMLInputSource in = null;
+ try {
+ in = UimaUtils.getXMLInputSource(crDescriptor);
+ }
+ catch (InvalidXMLException e) {
+ mh.error(e);
+ throw e;
+ }
+ ResourceSpecifier crrs = xmlParser.parseCollectionReaderDescription(in);
+ // CR overrides
+ ResourceCreationSpecifier specifier = (ResourceCreationSpecifier) crrs;
+ ConfigurationParameterDeclarations configurationParameterDeclarations = specifier.getMetaData().getConfigurationParameterDeclarations();
+ ConfigurationParameterSettings cps = specifier.getMetaData().getConfigurationParameterSettings();
+ if(crOverrides != null) {
+ Plist plist = new Plist(crOverrides);
+ TreeMap<String,String> map = plist.getParameterMap();
+ Iterator<String> iterator = map.keySet().iterator();
+ while(iterator.hasNext()) {
+ String name = iterator.next();
+ String value = map.get(name);
+ String message = "config param name:"+name+" "+"value:"+value;
+ mh.frameworkDebug(cid, mid, message);
+ ConfigurationParameter configurationParameter = UimaUtils.findConfigurationParameter(configurationParameterDeclarations, name);
+ Object object = UimaUtils.getOverrideValueObject(configurationParameter, value);
+ cps.setParameterValue(name, object);
+ }
+ }
+ cr = UIMAFramework.produceCollectionReader(crrs);
+ // Change the heap size to reduce CAS size. The size here depends on what we intend to put into the CAS.
+ // If its just a pointer to data (like question id), the size of the heap can be reduced even more.
+ cr_properties.setProperty(UIMAFramework.CAS_INITIAL_HEAP_SIZE, "1000");
+ // Save CR type system. It will be used to initialize CASes later, in getEmptyCas().
+ cr_tp = cr.getProcessingResourceMetaData().getTypePriorities();
+ cr_tsd = cr.getProcessingResourceMetaData().getTypeSystem();
+ cr_fid = cr.getProcessingResourceMetaData().getFsIndexes();
+ initTotal();
+ mh.frameworkInfo(cid, mid, "total:"+getTotal());
+ mh.info("total:"+getTotal());
+ mh.frameworkTrace(cid, mid, "exit");
+ }
+
+ public Progress[] getProgressArray() {
+ String mid = "getProgressArray";
+ mh.frameworkTrace(cid, mid, "enter");
+ Progress[] retVal;
+ synchronized(cr) {
+ retVal = cr.getProgress();
+ }
+ mh.frameworkTrace(cid, mid, "exit");
+ return retVal;
+ }
+
+ public Progress getProgress() {
+ String mid = "getProgress";
+ mh.frameworkTrace(cid, mid, "enter");
+ Progress progress = null;
+ Progress[] progressArray = getProgressArray();
+ if(progressArray != null) {
+ progress = progressArray[0];
+ }
+ mh.frameworkTrace(cid, mid, "exit");
+ return progress;
+ }
+
+ private void initTotal() {
+ String mid = "initTotal";
+ mh.frameworkTrace(cid, mid, "enter");
+ Progress progress = getProgress();
+ if(progress != null) {
+ total = (int)progress.getTotal();
+ }
+ mh.frameworkTrace(cid, mid, "exit");
+ }
+
+ public int getTotal() {
+ String mid = "getTotal";
+ mh.frameworkTrace(cid, mid, "enter");
+ mh.frameworkTrace(cid, mid, "exit");
+ return total;
+ }
+
+ private CAS getEmptyCas() throws ResourceInitializationException {
+ String mid = "getEmptyCas";
+ mh.frameworkTrace(cid, mid, "enter");
+ CAS cas = null;
+ while(cas == null) {
+ // Use class level locking to serialize access to CasCreationUtils
+ // Only one thread at the time can create a CAS. UIMA uses lazy
+ // initialization approach which can cause NPE when two threads
+ // attempt to initialize a CAS.
+ synchronized( CasCreationUtils.class) {
+ cas = CasCreationUtils.createCas(cr_tsd, cr_tp, cr_fid, cr_properties);
+ }
+ }
+ mh.frameworkTrace(cid, mid, "exit");
+ return cas;
+ }
+
+ private CAS getNewCas() throws ResourceInitializationException, CollectionException, IOException {
+ String mid = "getNewCas";
+ mh.frameworkTrace(cid, mid, "enter");
+ CAS cas = getEmptyCas();
+ cr.getNext(cas);
+ mh.frameworkTrace(cid, mid, "exit");
+ return cas;
+ }
+
+ public CAS getUsedCas(CAS cas) throws CollectionException, IOException, ResourceInitializationException {
+ String mid = "getUsedCas";
+ mh.frameworkTrace(cid, mid, "enter");
+ cas.reset();
+ cr.getNext(cas);
+ mh.frameworkTrace(cid, mid, "exit");
+ return cas;
+ }
+
+ public CAS getCas(CAS cas) throws CollectionException, IOException, ResourceInitializationException {
+ if(cas == null) {
+ return getNewCas();
+ }
+ else {
+ return getUsedCas(cas);
+ }
+ }
+
+ public boolean hasNext() throws CollectionException, IOException {
+ return cr.hasNext();
+ }
+
+}
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/CasPipeline.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/CasPipeline.java?rev=1467288&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/CasPipeline.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/CasPipeline.java Fri Apr 12 14:39:10 2013
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.cli.aio;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.ducc.cli.IUiOptions.UiOption;
+import org.apache.uima.ducc.common.uima.UimaUtils;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.util.XMLInputSource;
+
+public class CasPipeline {
+
+ public static String cid = CasPipeline.class.getSimpleName();
+
+ protected IMessageHandler mh = new MessageHandler();
+ protected Properties properties = new Properties();
+
+ private AnalysisEngineDescription aed = null;
+ AnalysisEngine ae = null;
+
+ public CasPipeline(Properties properties, IMessageHandler mh) {
+ if(properties != null) {
+ this.properties = properties;
+ }
+ if(mh != null) {
+ this.mh = mh;
+ }
+ }
+
+ private ArrayList<String> toArrayList(String overrides) {
+ String mid = "toArrayList";
+ mh.frameworkTrace(cid, mid, "enter");
+ ArrayList<String> list = new ArrayList<String>();
+ if(overrides != null) {
+ String[] items = overrides.split(",");
+ for(String item : items) {
+ list.add(item.trim());
+ }
+ }
+ mh.frameworkTrace(cid, mid, "exit");
+ return list;
+ }
+
+ private File getFile(String descriptor) {
+ String mid = "getFile";
+ File file;
+ if(descriptor.endsWith(".xml")) {
+ mh.frameworkTrace(cid, mid, descriptor);
+ file = new File(descriptor);
+ }
+ else {
+ String relativePath = descriptor.replace('.', '/')+".xml";
+ URL url = getClass().getClassLoader().getResource(relativePath);
+ if(url == null) {
+ throw new IllegalArgumentException(relativePath+" not found in classpath");
+ }
+ mh.frameworkTrace(cid, mid, url.getFile());
+ file = new File(url.getFile());
+ }
+ return file;
+ }
+
+ private void initializeByDD() throws Exception {
+ String mid = "initializeByDD";
+ mh.frameworkTrace(cid, mid, "enter");
+ String dd = properties.getProperty(UiOption.ProcessDD.pname());
+ File ddFile = getFile(dd);
+ DDParser ddParser = new DDParser(ddFile);
+ String ddImport = ddParser.getDDImport();
+ mh.frameworkTrace(cid, mid, ddImport);
+ File uimaFile = getFile(ddImport);
+ XMLInputSource xis = new XMLInputSource(uimaFile);
+ ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(xis);
+ ae = UIMAFramework.produceAnalysisEngine(specifier);
+ mh.frameworkTrace(cid, mid, "exit");
+ }
+
+ private void initializeByParts() throws Exception {
+ String mid = "initializeByParts";
+ mh.frameworkTrace(cid, mid, "enter");
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ List<List<String>> overrides = new ArrayList<List<String>>();
+ List<String> descriptors = new ArrayList<String>();
+ String cmDescriptor = properties.getProperty(UiOption.ProcessDescriptorCM.pname());
+ if(cmDescriptor != null) {
+ ArrayList<String> cmOverrides = toArrayList(properties.getProperty(UiOption.ProcessDescriptorCMOverrides.pname()));
+ overrides.add(cmOverrides);
+ descriptors.add(cmDescriptor);
+ }
+ String aeDescriptor = properties.getProperty(UiOption.ProcessDescriptorAE.pname());
+ if(aeDescriptor != null) {
+ ArrayList<String> aeOverrides = toArrayList(properties.getProperty(UiOption.ProcessDescriptorAEOverrides.pname()));
+ overrides.add(aeOverrides);
+ descriptors.add(aeDescriptor);
+ }
+ String ccDescriptor = properties.getProperty(UiOption.ProcessDescriptorCC.pname());
+ if(ccDescriptor != null) {
+ ArrayList<String> ccOverrides = toArrayList(properties.getProperty(UiOption.ProcessDescriptorCCOverrides.pname()));
+ overrides.add(ccOverrides);
+ descriptors.add(ccDescriptor);
+ }
+ if(descriptors.size() == 3) {
+ aed = UimaUtils.createAggregateDescription(false, overrides, descriptors.get(0), descriptors.get(1), descriptors.get(2));
+ }
+ else if(descriptors.size() == 2) {
+ aed = UimaUtils.createAggregateDescription(false, overrides, descriptors.get(0), descriptors.get(1));
+ }
+ else if(descriptors.size() == 1) {
+ aed = UimaUtils.createAggregateDescription(false, overrides, descriptors.get(0));
+ }
+ aed.toXML(baos);
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ File file = null;
+ XMLInputSource xis = new XMLInputSource(bais, file);
+ ResourceSpecifier specifier = UIMAFramework.getXMLParser().parseResourceSpecifier(xis);
+ ae = UIMAFramework.produceAnalysisEngine(specifier);
+ mh.frameworkTrace(cid, mid, "exit");
+ }
+
+ public void initialize() throws Exception {
+ String mid = "initialize";
+ mh.frameworkTrace(cid, mid, "enter");
+ String dd = properties.getProperty(UiOption.ProcessDD.pname());
+ if(dd != null) {
+ initializeByDD();
+ }
+ else {
+ initializeByParts();
+ }
+ mh.frameworkTrace(cid, mid, "exit");
+ }
+
+ public CAS process(CAS cas) throws AnalysisEngineProcessException {
+ ae.process(cas);
+ return cas;
+ }
+}
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/DDParser.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/DDParser.java?rev=1467288&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/DDParser.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/DDParser.java Fri Apr 12 14:39:10 2013
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.cli.aio;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class DDParser extends DefaultHandler {
+
+ private File file = null;
+ private FileInputStream fis = null;
+ private SAXParser parser = null;
+
+ private String ddImport = null;
+
+ public DDParser(String filename) throws ParserConfigurationException, SAXException, IOException {
+ file = new File(filename);
+ parse();
+ }
+
+ public DDParser(File file) throws ParserConfigurationException, SAXException, IOException {
+ this.file = file;
+ parse();
+ }
+
+ private void parse() throws ParserConfigurationException, SAXException, IOException {
+ fis = new FileInputStream(file);
+ parser = SAXParserFactory.newInstance().newSAXParser();
+ parser.parse(fis, this);
+ }
+
+ @Override
+ public void startDocument() throws SAXException {
+ //System.out.println("startDocument");
+ }
+
+ @Override
+ public void endDocument() throws SAXException {
+ //System.out.println("endDocument");
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
+ //System.out.println("qName: "+qName);
+ if(qName != null) {
+ if(qName.trim().equalsIgnoreCase("import")) {
+ int count = attributes.getLength();
+ for(int i = 0; i < count; i++) {
+ String name = attributes.getLocalName(i);
+ String value = attributes.getValue(i);
+ //System.out.println(i+": "+name+"="+value);
+ if(name != null) {
+ if(name.trim().equalsIgnoreCase("name")) {
+ ddImport = value;
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ public String getDDImport() {
+ return ddImport;
+ }
+
+ public static void main(String[] args) throws Exception {
+ System.out.println(args[0]);
+ DDParser ddParser = new DDParser(args[0]);
+ System.out.println(ddParser.getDDImport());
+ }
+
+}
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/IMessageHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/IMessageHandler.java?rev=1467288&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/IMessageHandler.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/IMessageHandler.java Fri Apr 12 14:39:10 2013
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.cli.aio;
+
+public interface IMessageHandler {
+
+ public enum Level
+ {
+ UserInfo
+ { public String getLabel() { return "uI"; }
+ },
+ UserError
+ { public String getLabel() { return "uE"; }
+ },
+ UserWarn
+ { public String getLabel() { return "uW"; }
+ },
+ UserDebug
+ { public String getLabel() { return "uD"; }
+ },
+ UserTrace
+ { public String getLabel() { return "uT"; }
+ },
+ FrameworkInfo
+ { public String getLabel() { return "fI"; }
+ },
+ FrameworkError
+ { public String getLabel() { return "fE"; }
+ },
+ FrameworkWarn
+ { public String getLabel() { return "fW"; }
+ },
+ FrameworkDebug
+ { public String getLabel() { return "fD"; }
+ },
+ FrameworkTrace
+ { public String getLabel() { return "fT"; }
+ },
+ ;
+ public abstract String getLabel();
+ };
+
+
+
+ public enum Toggle { On, Off };
+
+ public void setLevel(Level level, Toggle toggle);
+ public Toggle getLevel(Level level);
+
+ public void setTimestamping(Toggle toggle);
+ public Toggle getTimestamping();
+
+ public void info(String message);
+ public void error(String message);
+ public void error(Exception e);
+ public void error(Throwable t);
+ public void warn(String message);
+ public void debug(String message);
+ public void trace(String message);
+
+ public void info(String cid, String mid, String message);
+ public void error(String cid, String mid, String message);
+ public void warn(String cid, String mid, String message);
+ public void debug(String cid, String mid, String message);
+ public void trace(String cid, String mid, String message);
+
+ public void frameworkInfo(String message);
+ public void frameworkError(String message);
+ public void frameworkError(Exception e);
+ public void frameworkError(Throwable t);
+ public void frameworkWarn(String message);
+ public void frameworkDebug(String message);
+ public void frameworkTrace(String message);
+
+ public void frameworkInfo(String cid, String mid, String message);
+ public void frameworkWarn(String cid, String mid, String message);
+ public void frameworkError(String cid, String mid, String message);
+ public void frameworkDebug(String cid, String mid, String message);
+ public void frameworkTrace(String cid, String mid, String message);
+
+}
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/MessageHandler.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/MessageHandler.java?rev=1467288&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/MessageHandler.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/MessageHandler.java Fri Apr 12 14:39:10 2013
@@ -0,0 +1,289 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.cli.aio;
+
+import java.util.Date;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class MessageHandler implements IMessageHandler {
+
+ private ConcurrentHashMap<Level,Toggle> map = new ConcurrentHashMap<Level,Toggle>();
+
+ private Toggle timestamping = Toggle.Off;
+ private Toggle typeIdentifying = Toggle.On;
+
+ public MessageHandler() {
+ initialize();
+ }
+
+ public MessageHandler(Toggle timestamping) {
+ setTimestamping(timestamping);
+ initialize();
+ }
+
+ private void initialize() {
+ map.put(Level.UserInfo, Toggle.On);
+ map.put(Level.UserError, Toggle.On);
+ map.put(Level.UserWarn, Toggle.On);
+ map.put(Level.UserDebug, Toggle.Off);
+ map.put(Level.UserTrace, Toggle.Off);
+ map.put(Level.FrameworkInfo, Toggle.Off);
+ map.put(Level.FrameworkError, Toggle.Off);
+ map.put(Level.FrameworkWarn, Toggle.Off);
+ map.put(Level.FrameworkDebug, Toggle.Off);
+ map.put(Level.FrameworkTrace, Toggle.Off);
+ }
+
+ public void setLevel(Level level, Toggle toggle) {
+ if(level != null) {
+ if(toggle != null) {
+ map.put(level, toggle);
+ }
+ }
+ }
+
+ public Toggle getLevel(Level level) {
+ Toggle retVal = Toggle.Off;
+ if(level != null) {
+ if(map.containsKey(level)) {
+ retVal = map.get(level);
+ }
+ }
+ return retVal;
+ }
+
+ public void setTimestamping(Toggle toggle) {
+ synchronized(timestamping) {
+ if(toggle != null) {
+ timestamping = toggle;
+ }
+ }
+ }
+
+ public Toggle getTimestamping() {
+ synchronized(timestamping) {
+ return timestamping;
+ }
+ }
+
+ public void setTypeIdentifying(Toggle toggle) {
+ synchronized(typeIdentifying) {
+ if(toggle != null) {
+ typeIdentifying = toggle;
+ }
+ }
+ }
+
+ public Toggle getTypeIdentifying() {
+ synchronized(typeIdentifying) {
+ return typeIdentifying;
+ }
+ }
+
+ private void sysout(Level level, String message) {
+ String text = message;
+ switch(getTypeIdentifying()) {
+ case On:
+ if(level != null) {
+ text = level.getLabel()+" "+message;
+ }
+ }
+ switch(getTimestamping()) {
+ case On:
+ Date date = new Date();
+ text = date+" "+text;
+ }
+ System.out.println(text);
+ System.out.flush();
+ }
+
+ private void syserr(Level level, String message) {
+ String text = message;
+ switch(getTypeIdentifying()) {
+ case On:
+ if(level != null) {
+ text = level.getLabel()+" "+message;
+ }
+ }
+ switch(getTimestamping()) {
+ case On:
+ Date date = new Date();
+ text = date+" "+text;
+ }
+ System.err.println(text);
+ System.err.flush();
+ }
+
+ public void info(String message) {
+ Toggle toggle = map.get(Level.UserInfo);
+ switch(toggle) {
+ case On:
+ sysout(Level.UserInfo,message);
+ }
+ }
+
+ public void error(String message) {
+ Toggle toggle = map.get(Level.UserError);
+ switch(toggle) {
+ case On:
+ syserr(Level.UserError, message);
+ }
+ }
+
+ public void error(Exception e) {
+ Toggle toggle = map.get(Level.UserError);
+ switch(toggle) {
+ case On:
+ e.printStackTrace(System.err);
+ System.err.flush();
+ }
+ }
+
+ public void error(Throwable t) {
+ Toggle toggle = map.get(Level.UserError);
+ switch(toggle) {
+ case On:
+ t.printStackTrace(System.err);
+ System.err.flush();
+ }
+ }
+
+ public void warn(String message) {
+ Toggle toggle = map.get(Level.UserWarn);
+ switch(toggle) {
+ case On:
+ sysout(Level.UserWarn, message);
+ }
+ }
+
+ public void debug(String message) {
+ Toggle toggle = map.get(Level.UserDebug);
+ switch(toggle) {
+ case On:
+ sysout(Level.UserDebug, message);
+ }
+ }
+
+ public void trace(String message) {
+ Toggle toggle = map.get(Level.UserTrace);
+ switch(toggle) {
+ case On:
+ sysout(Level.UserTrace, message);
+ }
+ }
+
+ public void info(String cid, String mid, String message) {
+ info(cid+"."+mid+" "+message);
+ }
+
+ public void error(String cid, String mid, String message) {
+ error(cid+"."+mid+" "+message);
+ }
+
+ public void warn(String cid, String mid, String message) {
+ warn(cid+"."+mid+" "+message);
+ }
+
+ public void debug(String cid, String mid, String message) {
+ debug(cid+"."+mid+" "+message);
+ }
+
+ public void trace(String cid, String mid, String message) {
+ trace(cid+"."+mid+" "+message);
+ }
+
+ public void frameworkInfo(String message) {
+ Toggle toggle = map.get(Level.FrameworkInfo);
+ switch(toggle) {
+ case On:
+ sysout(Level.FrameworkInfo, message);
+ }
+ }
+
+ public void frameworkError(String message) {
+ Toggle toggle = map.get(Level.FrameworkError);
+ switch(toggle) {
+ case On:
+ syserr(Level.FrameworkError, message);
+ }
+ }
+
+ public void frameworkError(Exception e) {
+ Toggle toggle = map.get(Level.FrameworkError);
+ switch(toggle) {
+ case On:
+ e.printStackTrace(System.err);
+ System.err.flush();
+ }
+ }
+
+ public void frameworkError(Throwable t) {
+ Toggle toggle = map.get(Level.FrameworkError);
+ switch(toggle) {
+ case On:
+ t.printStackTrace(System.err);
+ System.err.flush();
+ }
+ }
+
+ public void frameworkWarn(String message) {
+ Toggle toggle = map.get(Level.FrameworkWarn);
+ switch(toggle) {
+ case On:
+ sysout(Level.FrameworkWarn, message);
+ }
+ }
+
+ public void frameworkDebug(String message) {
+ Toggle toggle = map.get(Level.FrameworkDebug);
+ switch(toggle) {
+ case On:
+ sysout(Level.FrameworkDebug, message);
+ }
+ }
+
+ public void frameworkTrace(String message) {
+ Toggle toggle = map.get(Level.FrameworkTrace);
+ switch(toggle) {
+ case On:
+ sysout(Level.FrameworkTrace, message);
+ }
+ }
+
+ public void frameworkInfo(String cid, String mid, String message) {
+ frameworkInfo(cid+"."+mid+" "+message);
+ }
+
+ public void frameworkError(String cid, String mid, String message) {
+ frameworkError(cid+"."+mid+" "+message);
+ }
+
+ public void frameworkWarn(String cid, String mid, String message) {
+ frameworkWarn(cid+"."+mid+" "+message);
+ }
+
+ public void frameworkDebug(String cid, String mid, String message) {
+ frameworkDebug(cid+"."+mid+" "+message);
+ }
+
+ public void frameworkTrace(String cid, String mid, String message) {
+ frameworkTrace(cid+"."+mid+" "+message);
+ }
+
+}
Added: uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/Plist.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/Plist.java?rev=1467288&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/Plist.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-cli/src/main/java/org/apache/uima/ducc/cli/aio/Plist.java Fri Apr 12 14:39:10 2013
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+package org.apache.uima.ducc.cli.aio;
+
+import java.util.TreeMap;
+import java.util.Iterator;
+
+public class Plist {
+
+ private String plist;
+
+ private final String delimParams = ",";
+ private final String delimValues = "[:=]";
+
+ private TreeMap<String,String> parameterMap = new TreeMap<String,String>();
+
+ public Plist(String plist) {
+ this.plist = plist;
+ if(plist != null) {
+ init();
+ }
+ }
+
+ private void init() {
+ String[] pArray = plist.split(delimParams);
+ for(int i=0; i<pArray.length; i++) {
+ String[] parameter = pArray[i].split(delimValues,2);
+ if(parameter.length == 2) {
+ String key = parameter[0];
+ String value = parameter[1];
+ if((key != null) && (key.length() > 0) && (value != null) && (value.length() > 0)) {
+ parameterMap.put(key,value);
+ }
+ }
+ }
+ }
+
+ public TreeMap<String,String> getParameterMap() {
+ return parameterMap;
+ }
+
+ /*
+ * <test only>
+ */
+
+ private void dump() {
+ TreeMap<String,String> map = this.getParameterMap();
+ Iterator<String> iterator = map.keySet().iterator();
+ while(iterator.hasNext()) {
+ String name = iterator.next();
+ String value = map.get(name);
+ System.out.println("name:"+name+" "+"value:"+value);
+ }
+ }
+
+ public static void main(String[] args) {
+ Plist plist;
+ String test;
+ test = "WorkItems:0-59,FailItems:17-18";
+ plist = new Plist(test);
+ plist.dump();
+ test = "WorkItems=0-59,FailItems=17-18";
+ plist = new Plist(test);
+ plist.dump();
+ test = "x:1,y:2,z:http://3";
+ plist = new Plist(test);
+ plist.dump();
+ test = null;
+ plist = new Plist(test);
+ plist.dump();
+ test = "x";
+ plist = new Plist(test);
+ plist.dump();
+ test = "x:";
+ plist = new Plist(test);
+ plist.dump();
+ test = ":1";
+ plist = new Plist(test);
+ plist.dump();
+ test = ",";
+ plist = new Plist(test);
+ plist.dump();
+ test = ":,";
+ plist = new Plist(test);
+ plist.dump();
+ }
+
+ /*
+ * </test only>
+ */
+}