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 2014/11/28 19:20:15 UTC

svn commit: r1642334 - in /uima/sandbox/uima-ducc/trunk/uima-ducc-user/src: main/java/org/apache/uima/ducc/user/dd/iface/ test/java/org/apache/uima/ducc/user/jd/test/ test/resources/

Author: degenaro
Date: Fri Nov 28 18:20:15 2014
New Revision: 1642334

URL: http://svn.apache.org/r1642334
Log:
UIMA-4068 Redesign of JD toward the main goal of classpath separation for container (user) code.

User-side DDGenerate and JUnit (for the simplest case).

Added:
    uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/
    uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/DDException.java   (with props)
    uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/DDGenerate.java   (with props)
    uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/IDDGenerate.java   (with props)
    uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/resources/FixedSleepAE.xml   (with props)
Modified:
    uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/TestSuite.java

Added: uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/DDException.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/DDException.java?rev=1642334&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/DDException.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/DDException.java Fri Nov 28 18:20:15 2014
@@ -0,0 +1,28 @@
+/*
+ * 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.user.dd.iface;
+
+public class DDException extends Exception {
+
+	private static final long serialVersionUID = 1L;
+
+	public DDException(String message) {
+		super(message);
+	}
+}

Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/DDException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/DDGenerate.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/DDGenerate.java?rev=1642334&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/DDGenerate.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/DDGenerate.java Fri Nov 28 18:20:15 2014
@@ -0,0 +1,106 @@
+/*
+ * 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.user.dd.iface;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.ducc.user.dd.DeploymentDescriptorGenerator;
+import org.apache.uima.ducc.user.dd.DuccUimaAggregate;
+import org.apache.uima.ducc.user.dd.DuccUimaAggregateComponent;
+import org.apache.uima.ducc.user.dd.IDuccUimaAggregateComponent;
+import org.apache.uima.ducc.user.dd.IDuccUimaDeployableConfiguration;
+
+public class DDGenerate implements IDDGenerate {
+
+	public DDGenerate() {	
+	}
+	
+	private void conditionalAddComponent(ArrayList<IDuccUimaAggregateComponent> ddComponents, String descriptor, List<String> overrides) {
+		if(descriptor != null) {
+			DuccUimaAggregateComponent ddComponent = new DuccUimaAggregateComponent(descriptor, overrides);
+			ddComponents.add(ddComponent);
+		}
+	}
+	
+	private void show(String text) {
+		System.out.println(text);
+	}
+	
+	private void show(String name, String value) {
+		show(name+"="+value);
+	}
+	
+	private void show(String name, List<String> value) {
+		if(value == null) {
+			show(name+"="+value);
+		}
+		else {
+			show(name+"="+value.toString());
+		}
+	}
+	
+	@Override
+	public String generate(
+			String directory, 
+			String id,
+			String ddName,
+			String ddDescription,
+			Integer ddThreadCount,
+			String ddBrokerURL,
+			String ddEndpoint,
+			String cmDescriptor,
+			List<String> cmOverrides, 
+			String aeDescriptor, 
+			List<String> aeOverrides, 
+			String ccDescriptor,
+			List<String> ccOverrides
+			) throws DDException
+	{
+		String retVal = null;
+		try {
+			show("directory", directory);
+			show("id", id);
+			show("ddName", ddName);
+			show("ddDescription", ddDescription);
+			show("ddThreadCount", ddThreadCount.toString());
+			show("ddBrokerURL", ddBrokerURL);
+			show("ddEndpoint", ddEndpoint);
+			show("cmDescriptor", cmDescriptor);
+			show("cmOverrides", cmOverrides);
+			show("aeDescriptor", aeDescriptor);
+			show("aeOverrides", aeOverrides);
+			show("ccDescriptor", ccDescriptor);
+			show("ccOverrides", ccOverrides);
+			DeploymentDescriptorGenerator ddg = new DeploymentDescriptorGenerator(directory);
+			ArrayList<IDuccUimaAggregateComponent> ddComponents = new ArrayList<IDuccUimaAggregateComponent>();
+			conditionalAddComponent(ddComponents, cmDescriptor, cmOverrides);
+			conditionalAddComponent(ddComponents, aeDescriptor, aeOverrides);
+			conditionalAddComponent(ddComponents, ccDescriptor, ccOverrides);
+			IDuccUimaDeployableConfiguration configuration = new DuccUimaAggregate(ddName, ddDescription, ddThreadCount, ddBrokerURL, ddEndpoint, ddComponents);
+			retVal = ddg.generate(configuration, id);
+		}
+		catch(Exception e) {
+			e.printStackTrace();
+			throw new DDException(e.toString());
+		}
+		return retVal;
+	}
+
+}

Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/DDGenerate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/IDDGenerate.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/IDDGenerate.java?rev=1642334&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/IDDGenerate.java (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/IDDGenerate.java Fri Nov 28 18:20:15 2014
@@ -0,0 +1,40 @@
+/*
+ * 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.user.dd.iface;
+
+import java.util.List;
+
+public interface IDDGenerate {
+
+	public String generate(
+			String directory,
+			String id,
+			String ddName,
+			String ddDescription,
+			Integer ddThreadCount,
+			String ddBrokerURL,
+			String ddEndpoint,
+			String cm,
+			List<String> cmOverrides, 
+			String ae, 
+			List<String> aeOverrides, 
+			String cc,
+			List<String> ccOverrides
+			) throws DDException;
+}

Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/dd/iface/IDDGenerate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/TestSuite.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/TestSuite.java?rev=1642334&r1=1642333&r2=1642334&view=diff
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/TestSuite.java (original)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/TestSuite.java Fri Nov 28 18:20:15 2014
@@ -33,6 +33,7 @@ import org.apache.uima.ducc.user.dd.Ducc
 import org.apache.uima.ducc.user.dd.DuccUimaAggregateComponent;
 import org.apache.uima.ducc.user.dd.IDuccUimaAggregateComponent;
 import org.apache.uima.ducc.user.dd.IDuccUimaDeployableConfiguration;
+import org.apache.uima.ducc.user.dd.iface.DDGenerate;
 import org.apache.uima.ducc.user.jd.JdUserCollectionReader;
 import org.apache.uima.ducc.user.jd.JdUserException;
 import org.apache.uima.ducc.user.jd.JdUserMetaCas;
@@ -343,7 +344,7 @@ public class TestSuite {
 			directory.delete();
 		}
 		catch(Exception e) {
-			e.printStackTrace();
+			//e.printStackTrace();
 		}
 	}
 	
@@ -379,7 +380,7 @@ public class TestSuite {
 	}
 
 	@Test
-	public void test10() {
+	public void test10a() {
 		try {
 			URL url = this.getClass().getResource("/");
 			File root = new File(url.getFile());
@@ -403,4 +404,56 @@ public class TestSuite {
 			fail("Exception");
 		}
 	}
+	
+	@Test
+	public void test10b() {
+		try {
+			URL url = this.getClass().getResource("/");
+			File root = new File(url.getFile());
+			String name = root.getAbsolutePath();
+			debug(name);
+			assertTrue(root.isDirectory());
+			String nameWorking = name+File.separator+"working";
+			File working = new File(nameWorking);
+			delete(working);
+			working.mkdir();
+			DDGenerate ddGenerate = new DDGenerate();
+			
+			String directory = working.getAbsolutePath();
+			String id = "99999";
+			String ddName = "ddName";
+			String ddDescription = "ddDescription";
+			Integer ddThreadCount = new Integer(11);
+			String ddBrokerURL = "ddBrokerURL";
+			String ddBrokerEndpoint = "ddBrokerEndpount";
+			String cmDescriptor = null;
+			List<String> cmOverrides = null;
+			String aeDescriptor = root+File.separator+"FixedSleepAE.xml";
+			List<String> aeOverrides = null;
+			String ccDescriptor = null;
+			List<String> ccOverrides = null;
+			
+			String dd = ddGenerate.generate(
+					directory, 
+					id, ddName, 
+					ddDescription, 
+					ddThreadCount, 
+					ddBrokerURL, 
+					ddBrokerEndpoint, 
+					cmDescriptor, 
+					cmOverrides, 
+					aeDescriptor, 
+					aeOverrides, 
+					ccDescriptor, 
+					ccOverrides);
+			
+			debug(dd);
+			show(dd);
+			delete(working);
+		}
+		catch(Exception e) {
+			e.printStackTrace();
+			fail("Exception");
+		}
+	}
 }

Added: uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/resources/FixedSleepAE.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/resources/FixedSleepAE.xml?rev=1642334&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/resources/FixedSleepAE.xml (added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/resources/FixedSleepAE.xml Fri Nov 28 18:20:15 2014
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+	<!--
+	 ***************************************************************
+	 * 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.
+	 ***************************************************************
+   -->
+   
+<!-- AE that employs CAS indirection inside aggregate. -->
+
+<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier">
+	<frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+	<primitive>true</primitive>
+	<annotatorImplementationName>org.apache.uima.ducc.test.randomsleep.FixedSleepAE</annotatorImplementationName>
+	<analysisEngineMetaData>
+		<name>DefaultAE</name>
+		<description>Receives CASes with modified index; does nothing (echos).</description>
+		<version>1.0</version>
+		<vendor>The Apache Software Foundation</vendor>
+		
+		<configurationParameters>
+    		<configurationParameter>
+      			<name>DebugLevel</name>
+      			<description>Debug Level</description>
+      			<type>String</type>
+      			<multiValued>false</multiValued>
+      			<mandatory>false</mandatory>
+    		</configurationParameter>
+    	</configurationParameters>
+   	 	<configurationParameterSettings>
+    	</configurationParameterSettings>
+		
+		<typeSystemDescription>
+          <imports>
+            <import name="org.apache.uima.examples.SourceDocumentInformation"/>
+          </imports>
+        </typeSystemDescription>
+		<!--
+		Capabilities: Inputs, Outputs, and Preconditions
+		-->
+		<capabilities>
+          	<capability>
+          		<inputs/>
+          		<outputs>
+          			<type allAnnotatorFeatures="true">org.apache.uima.examples.SourceDocumentInformation</type>
+          		</outputs>
+          	</capability>
+        </capabilities>
+		<operationalProperties>
+			<modifiesCas>true</modifiesCas>
+			<multipleDeploymentAllowed>true</multipleDeploymentAllowed>
+			<outputsNewCASes>false</outputsNewCASes>
+		</operationalProperties>
+	</analysisEngineMetaData>
+</analysisEngineDescription>

Propchange: uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/resources/FixedSleepAE.xml
------------------------------------------------------------------------------
    svn:eol-style = native