You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by bu...@apache.org on 2016/08/24 13:27:06 UTC

svn commit: r1757523 - in /uima/uimaj/trunk: uima-docbook-references/src/docbook/ uimaj-core/src/main/java/org/apache/uima/ uimaj-core/src/main/java/org/apache/uima/impl/ uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/ uimaj-core/src/tes...

Author: burn
Date: Wed Aug 24 13:27:06 2016
New Revision: 1757523

URL: http://svn.apache.org/viewvc?rev=1757523&view=rev
Log:
UIMA-5043 Describe the settings as shared rather than global. Change methods to start with getSharedSetting... to complement the existing getConfigParameter... methods, and to return similar things.

Modified:
    uima/uimaj/trunk/uima-docbook-references/src/docbook/ref.xml.component_descriptor.xml
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/UimaContext.java
    uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/impl/UimaContext_ImplBase.java
    uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TestAnnotator2.java
    uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/UimaContextHolderTest.java

Modified: uima/uimaj/trunk/uima-docbook-references/src/docbook/ref.xml.component_descriptor.xml
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uima-docbook-references/src/docbook/ref.xml.component_descriptor.xml?rev=1757523&r1=1757522&r2=1757523&view=diff
==============================================================================
--- uima/uimaj/trunk/uima-docbook-references/src/docbook/ref.xml.component_descriptor.xml (original)
+++ uima/uimaj/trunk/uima-docbook-references/src/docbook/ref.xml.component_descriptor.xml Wed Aug 24 13:27:06 2016
@@ -1909,7 +1909,7 @@ uima.tcas.Annotation.</programlisting>
             <para>
             External parameter overrides are usually declared in primitive descriptors as a way to
             easily modify the parameters in some or all of an application's annotators.  
-            By using external settings files and global parameter names the configuration
+            By using external settings files and shared parameter names the configuration
             information can be specified without regard for a particular descriptor hierachy.
             </para>
 
@@ -2044,26 +2044,27 @@ key9  :  [ array element1\, with embedde
             <title>Direct Access to External Configuration Parameters</title>
 
             <para>
-            Annotators and flow controllers can directly access these global configuration
+            Annotators and flow controllers can directly access these shared configuration
             parameters from their UimaContext. 
-            Direct access means an access where the key to select the global parameter is the 
-            external parameter name as specified in the external configuration settings file. 
+            Direct access means an access where the key to select the shared parameter is the 
+            parameter name as specified in the external configuration settings file. 
 			<programlisting>
-String value = aContext.getSetting(paramName);
-String values[] = aContext.getSettingArray(arrayParamName);
-Set&lt;String&gt; allNames = aContext.getSettingNames();
+String value = aContext.getSharedSettingValue(paramName);
+String values[] = aContext.getSharedSettingArray(arrayParamName);
+String allNames[] = aContext.getSharedSettingNames();
 			</programlisting>
             Java code called by an annotator or flow controller in the same thread or a child thread
             can use the <literal>UimaContextHolder</literal> to get the annotator's UimaContext and
-            hence access the global configuration parameters.
+            hence access the shared configuration parameters.
 			<programlisting>
 UimaContext uimaContext = UimaContextHolder.getUimaContext();
 if (uimaContext != null) {
-  value = uimaContext.getSetting(paramName);
+  value = uimaContext.getSharedSettingValue(paramName);
 }
 			</programlisting>
 			The UIMA framework puts the context in an InheritableThreadLocal variable.  The value
-			will be null if the code is not called from an annotator or flow controller.
+			will be null if <literal>getUimaContext</literal> is not invoked by an annotator or flow
+			controller on the same thread or a child thread.
             </para>
           </section>
 

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/UimaContext.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/UimaContext.java?rev=1757523&r1=1757522&r2=1757523&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/UimaContext.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/UimaContext.java Wed Aug 24 13:27:06 2016
@@ -118,31 +118,31 @@ public interface UimaContext {
   public String[] getConfigParameterNames();
 
   /**
-   * Get the value of an external override setting.
+   * Get the value of a shared configuration parameter from the external override settings.
    * 
    * @param name - the name of the parameter
-   * @return     - the value found in the settings file(s), or null if missing.
+   * @return     - the value found in the shared settings file(s), or null if missing.
    * @throws ResourceConfigurationException 
-   *                 if the value references an undefined property, or the value is an array
+   *                 if the value references an undefined parameter, or the value is an array
    */
-  public String getSetting(String name) throws ResourceConfigurationException;
+  public String getSharedSettingValue(String name) throws ResourceConfigurationException;
   
   /**
-  * Get the array of values for an external override setting.
+  * Get the array of values for a shared configuration parameter from the external override settings.
   * 
   * @param name  - the name of the parameter
-  * @return      - an array of values found in the settings file(s), or null if missing.
+  * @return      - an array of values found in the shared settings file(s), or null if missing.
   * @throws ResourceConfigurationException 
-  *                  if the value references an undefined property, or the value is not an array
+  *                  if the value references an undefined parameter, or the value is not an array
   */
-  public String[] getSettingArray(String name) throws ResourceConfigurationException;
+  public String[] getSharedSettingArray(String name) throws ResourceConfigurationException;
   
   /**
-   * Return a set containing the names of all the external override settings available
+   * Get the names of all the external override settings available.
    * 
-   * @return - set of strings
+   * @return - an array containing the names of all the external override settings.
    */
-  public Set<String> getSettingNames();
+  public String[] getSharedSettingNames();
   
   /**
    * Gets the <code>Settings</code> used for external parameter overrides

Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/impl/UimaContext_ImplBase.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/impl/UimaContext_ImplBase.java?rev=1757523&r1=1757522&r2=1757523&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/impl/UimaContext_ImplBase.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/impl/UimaContext_ImplBase.java Wed Aug 24 13:27:06 2016
@@ -278,21 +278,25 @@ public abstract class UimaContext_ImplBa
   }
 
   @Override
-  public String getSetting(String name) throws ResourceConfigurationException {
+  public String getSharedSettingValue(String name) throws ResourceConfigurationException {
     Settings settings = getRootContext().getExternalOverrides();
     return (settings == null) ? null : settings.getSetting(name);
   }
   
   @Override
-  public String[] getSettingArray(String name) throws ResourceConfigurationException {
+  public String[] getSharedSettingArray(String name) throws ResourceConfigurationException {
     Settings settings = getRootContext().getExternalOverrides();
     return (settings == null) ? null : settings.getSettingArray(name);
   }
   
   @Override
-  public Set<String> getSettingNames() {
+  public String[] getSharedSettingNames() {
     Settings settings = getRootContext().getExternalOverrides();
-    return (settings == null) ? null : settings.getKeys();
+    if (settings == null) {
+      return null;
+    }
+    Set<String> names = settings.getKeys();
+    return names.toArray(new String[names.size()]);
   }
   
   /**

Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TestAnnotator2.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TestAnnotator2.java?rev=1757523&r1=1757522&r2=1757523&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TestAnnotator2.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/analysis_engine/impl/TestAnnotator2.java Wed Aug 24 13:27:06 2016
@@ -79,7 +79,7 @@ public class TestAnnotator2 extends CasA
       String expected = "Context Holder Test";
       String[] actuals = null;
       try {
-        actuals = UimaContextHolder.getContext().getSettingArray("test.externalFloatArray");
+        actuals = UimaContextHolder.getContext().getSharedSettingArray("test.externalFloatArray");
       } catch (ResourceConfigurationException e) {
         Assert.fail(e.getMessage());
       }
@@ -89,7 +89,7 @@ public class TestAnnotator2 extends CasA
       // suffix = should be ignored
       String actual = null;
       try {
-        actual = UimaContextHolder.getContext().getSetting("context-holder");
+        actual = UimaContextHolder.getContext().getSharedSettingValue("context-holder");
       } catch (ResourceConfigurationException e) {
         Assert.fail(e.getMessage());
       }
@@ -97,13 +97,13 @@ public class TestAnnotator2 extends CasA
       
       // Test assigning an array to a string and vice-versa
       try {
-        actual = UimaContextHolder.getContext().getSetting("test.externalFloatArray");
+        actual = UimaContextHolder.getContext().getSharedSettingValue("test.externalFloatArray");
         Assert.fail("\"bad\" should create an error");
       } catch (ResourceConfigurationException e) {
         System.err.println("Expected exception: " + e.toString());
       }
       try {
-        actuals = UimaContextHolder.getContext().getSettingArray("prefix-suffix");
+        actuals = UimaContextHolder.getContext().getSharedSettingArray("prefix-suffix");
         Assert.fail("\"bad\" should create an error");
       } catch (ResourceConfigurationException e) {
         System.err.println("Expected exception: " + e.toString());

Modified: uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/UimaContextHolderTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/UimaContextHolderTest.java?rev=1757523&r1=1757522&r2=1757523&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/UimaContextHolderTest.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/util/UimaContextHolderTest.java Wed Aug 24 13:27:06 2016
@@ -39,7 +39,7 @@ public class UimaContextHolderTest imple
     if (uimaContext == null) {
       return nocontextError;
     }
-    return uimaContext.getSetting("context-holder");
+    return uimaContext.getSharedSettingValue("context-holder");
   }
 
   @Override