You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by tw...@apache.org on 2007/11/09 11:49:19 UTC
svn commit: r593489 - in /incubator/uima/sandbox/trunk/SimpleServer: lib/
src/main/java/org/apache/uima/simpleserver/config/impl/ src/main/resources/
src/test/java/org/apache/uima/simpleserver/test/ src/test/resources/
Author: twgoetz
Date: Fri Nov 9 02:49:18 2007
New Revision: 593489
URL: http://svn.apache.org/viewvc?rev=593489&view=rev
Log:
Jira UIMA-627: create SimpleServer sandbox project.
https://issues.apache.org/jira/browse/UIMA-627
Added:
incubator/uima/sandbox/trunk/SimpleServer/src/main/java/org/apache/uima/simpleserver/config/impl/XmlConfigReader.java
Modified:
incubator/uima/sandbox/trunk/SimpleServer/lib/config-xml.jar
incubator/uima/sandbox/trunk/SimpleServer/src/main/resources/ResultSpecification.xsd
incubator/uima/sandbox/trunk/SimpleServer/src/test/java/org/apache/uima/simpleserver/test/ConfigTest.java
incubator/uima/sandbox/trunk/SimpleServer/src/test/resources/stuff.xml
Modified: incubator/uima/sandbox/trunk/SimpleServer/lib/config-xml.jar
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/SimpleServer/lib/config-xml.jar?rev=593489&r1=593488&r2=593489&view=diff
==============================================================================
Binary files - no diff available.
Added: incubator/uima/sandbox/trunk/SimpleServer/src/main/java/org/apache/uima/simpleserver/config/impl/XmlConfigReader.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/SimpleServer/src/main/java/org/apache/uima/simpleserver/config/impl/XmlConfigReader.java?rev=593489&view=auto
==============================================================================
--- incubator/uima/sandbox/trunk/SimpleServer/src/main/java/org/apache/uima/simpleserver/config/impl/XmlConfigReader.java (added)
+++ incubator/uima/sandbox/trunk/SimpleServer/src/main/java/org/apache/uima/simpleserver/config/impl/XmlConfigReader.java Fri Nov 9 02:49:18 2007
@@ -0,0 +1,52 @@
+/*
+ * 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.simpleserver.config.impl;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.apache.incubator.uima.simpleserver.config.xml.UimaSimpleServerSpecDocument;
+import org.apache.incubator.uima.simpleserver.config.xml.UimaSimpleServerSpecDocument.UimaSimpleServerSpec;
+import org.apache.uima.simpleserver.config.ConfigFactory;
+import org.apache.uima.simpleserver.config.ServerSpec;
+import org.apache.xmlbeans.XmlException;
+
+/**
+ * Read server configuration from an XML file or stream.
+ */
+public final class XmlConfigReader {
+
+ public static ServerSpec readServerSpec(File file) throws IOException, XmlException {
+ return readServerSpec(new BufferedInputStream(new FileInputStream(file)));
+ }
+
+ public static ServerSpec readServerSpec(InputStream is) throws IOException, XmlException {
+ UimaSimpleServerSpec specBean = UimaSimpleServerSpecDocument.Factory.parse(is)
+ .getUimaSimpleServerSpec();
+ ServerSpec spec = ConfigFactory.newServerSpec(specBean.getShortDescription(), specBean
+ .getLongDescription());
+
+ return spec;
+ }
+
+}
Modified: incubator/uima/sandbox/trunk/SimpleServer/src/main/resources/ResultSpecification.xsd
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/SimpleServer/src/main/resources/ResultSpecification.xsd?rev=593489&r1=593488&r2=593489&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/SimpleServer/src/main/resources/ResultSpecification.xsd (original)
+++ incubator/uima/sandbox/trunk/SimpleServer/src/main/resources/ResultSpecification.xsd Fri Nov 9 02:49:18 2007
@@ -22,7 +22,7 @@
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:uima="http://incubator.apache.org/uima/simpleserver/config/xml"
targetNamespace="http://incubator.apache.org/uima/simpleserver/config/xml">
- <xsd:element name="resultSpecification">
+ <xsd:element name="uimaSimpleServerSpec">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="shortDescription"
@@ -83,7 +83,7 @@
<xsd:complexType name="filterType">
- <xsd:attribute name="feature" type="xsd:string"
+ <xsd:attribute name="featurePath" type="xsd:string"
use="required">
</xsd:attribute>
<xsd:attribute name="condition" type="xsd:string"
@@ -100,7 +100,7 @@
minOccurs="0" maxOccurs="1">
</xsd:element>
</xsd:sequence>
- <xsd:attribute name="feature" type="xsd:string"
+ <xsd:attribute name="featurePath" type="xsd:string"
use="required">
</xsd:attribute>
<xsd:attribute name="outputAttribute" type="xsd:string"
Modified: incubator/uima/sandbox/trunk/SimpleServer/src/test/java/org/apache/uima/simpleserver/test/ConfigTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/SimpleServer/src/test/java/org/apache/uima/simpleserver/test/ConfigTest.java?rev=593489&r1=593488&r2=593489&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/SimpleServer/src/test/java/org/apache/uima/simpleserver/test/ConfigTest.java (original)
+++ incubator/uima/sandbox/trunk/SimpleServer/src/test/java/org/apache/uima/simpleserver/test/ConfigTest.java Fri Nov 9 02:49:18 2007
@@ -4,9 +4,11 @@
import java.io.IOException;
import java.io.InputStream;
+import java.util.List;
-import org.apache.incubator.uima.simpleserver.config.xml.ResultSpecificationDocument;
-import org.apache.incubator.uima.simpleserver.config.xml.TypeElementType;
+import org.apache.uima.simpleserver.config.ServerSpec;
+import org.apache.uima.simpleserver.config.TypeMap;
+import org.apache.uima.simpleserver.config.impl.XmlConfigReader;
import org.apache.xmlbeans.XmlException;
import org.junit.Test;
@@ -21,14 +23,12 @@
public void readSampleConfig() {
try {
InputStream is = this.getClass().getClassLoader().getResourceAsStream(CONFIG_TEST_FILE);
- ResultSpecificationDocument.ResultSpecification spec = ResultSpecificationDocument.Factory
- .parse(is).getResultSpecification();
- System.out
- .println("Short description: " + spec.getShortDescription());
- TypeElementType[] types = spec.getTypeArray();
- for (int i = 0; i < types.length; i++) {
- TypeElementType type = types[i];
- System.out.println("Type: " + type.getName() + ", " + type.getOutputTag());
+ ServerSpec spec = XmlConfigReader.readServerSpec(is);
+ System.out.println("Short description: " + spec.getShortDescription());
+ List<TypeMap> types = spec.getTypeSpecs();
+ for (int i = 0; i < types.size(); i++) {
+ TypeMap type = types.get(i);
+ System.out.println("Type: " + type.getTypeName() + ", " + type.getOutputTag());
}
} catch (XmlException e) {
e.printStackTrace();
Modified: incubator/uima/sandbox/trunk/SimpleServer/src/test/resources/stuff.xml
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/SimpleServer/src/test/resources/stuff.xml?rev=593489&r1=593488&r2=593489&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/SimpleServer/src/test/resources/stuff.xml (original)
+++ incubator/uima/sandbox/trunk/SimpleServer/src/test/resources/stuff.xml Fri Nov 9 02:49:18 2007
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
-<resultSpecification xmlns="http://incubator.apache.org/uima/simpleserver/config/xml">
+<uimaSimpleServerSpec xmlns="http://incubator.apache.org/uima/simpleserver/config/xml">
<shortDescription>Recognize stuff</shortDescription>
<type name="org.apache.uima.Stuff" outputTag="Stuff" outputCoveredText="on">
<filters>
- <filter feature="feat" condition="not null"/>
+ <filter featurePath="feat" condition="not null"/>
</filters>
<outputs>
- <output feature="ashes" outputAttribute="ashes"/>
- <output feature="dust" outputAttribute="dust"/>
+ <output featurePath="ashes" outputAttribute="ashes"/>
+ <output featurePath="dust" outputAttribute="dust"/>
</outputs>
</type>
-</resultSpecification>
+</uimaSimpleServerSpec>