You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2020/02/10 17:02:02 UTC

[uima-uimafit] branch UIMA-6188-uimaFIT-initializes-resources-with-parameter-values-originating-from-component created (now 0b9fce9)

This is an automated email from the ASF dual-hosted git repository.

rec pushed a change to branch UIMA-6188-uimaFIT-initializes-resources-with-parameter-values-originating-from-component
in repository https://gitbox.apache.org/repos/asf/uima-uimafit.git.


      at 0b9fce9  [UIMA-6188] uimaFIT initializes resources with parameter values originating from component

This branch includes the following new commits:

     new 0b9fce9  [UIMA-6188] uimaFIT initializes resources with parameter values originating from component

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[uima-uimafit] 01/01: [UIMA-6188] uimaFIT initializes resources with parameter values originating from component

Posted by re...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rec pushed a commit to branch UIMA-6188-uimaFIT-initializes-resources-with-parameter-values-originating-from-component
in repository https://gitbox.apache.org/repos/asf/uima-uimafit.git

commit 0b9fce9ddd890d37dc522180c77a17be7b25fb21
Author: Richard Eckart de Castilho <re...@apache.org>
AuthorDate: Mon Feb 10 18:01:54 2020 +0100

    [UIMA-6188] uimaFIT initializes resources with parameter values originating from component
    
    - Only pass the ResourceManger on, but not the entire UIMA context
---
 .../ConfigurationParameterInitializer.java         | 38 ++++++++++++----------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/ConfigurationParameterInitializer.java b/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/ConfigurationParameterInitializer.java
index 81ff354..6b2f31a 100644
--- a/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/ConfigurationParameterInitializer.java
+++ b/uimafit-core/src/main/java/org/apache/uima/fit/component/initialize/ConfigurationParameterInitializer.java
@@ -6,9 +6,9 @@
  * 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
@@ -85,6 +85,7 @@ public final class ConfigurationParameterInitializer {
    * or to not provide one at all. If the context does not have a configuration parameter, then the
    * default value provided by the developer as specified by the defaultValue element of the
    * {@link ConfigurationParameter} will be used. See comments in the code for additional details.
+   *
    * @param component
    *          the component to initialize.
    * @param context
@@ -157,8 +158,8 @@ public final class ConfigurationParameterInitializer {
             // }
             if (empty) {
               // Use bind error processor to create FieldError.
-              getBindingErrorProcessor()
-                      .processMissingFieldError(field, getInternalBindingResult());
+              getBindingErrorProcessor().processMissingFieldError(field,
+                      getInternalBindingResult());
               // Remove property from property values to bind:
               // It has already caused a field error with a rejected value.
               if (pv != null) {
@@ -173,9 +174,9 @@ public final class ConfigurationParameterInitializer {
     binder.initDirectFieldAccess();
     registerUimaFITEditors(binder);
     binder.setRequiredFields(mandatoryValues.toArray(new String[mandatoryValues.size()]));
-    
+
     binder.bind(values);
-    
+
     if (binder.getBindingResult().hasErrors()) {
       StringBuilder sb = new StringBuilder();
       sb.append("Errors initializing [" + component.getClass() + "]");
@@ -191,7 +192,7 @@ public final class ConfigurationParameterInitializer {
 
   /**
    * Initialize a component from a map.
-   * 
+   *
    * @param component
    *          the component to initialize.
    * @param map
@@ -202,18 +203,19 @@ public final class ConfigurationParameterInitializer {
    */
   public static void initialize(final Object component, final Map<String, Object> map)
           throws ResourceInitializationException {
-    // If there is already a UimaContext then re-use that, otherwise create a new one.
-    UimaContextAdmin context;
+    // If there is already a ResourceManager then re-use that, otherwise create a new one.
+    ResourceManager resMgr;
     if (component instanceof Resource) {
-      context = ((Resource) component).getUimaContextAdmin();
+      resMgr = ((Resource) component).getResourceManager();
     } else {
-      ResourceManager resMgr = newResourceManager();
-      context = newUimaContext(getLogger(), resMgr, newConfigurationManager());
+      resMgr = newResourceManager();
     }
 
+    UimaContextAdmin context = newUimaContext(getLogger(), resMgr, newConfigurationManager());
+
     ConfigurationManager cfgMgr = context.getConfigurationManager();
     cfgMgr.setSession(context.getSession());
-    
+
     for (Entry<String, Object> e : map.entrySet()) {
       cfgMgr.setConfigParameterValue(context.getQualifiedContextName() + e.getKey(), e.getValue());
     }
@@ -223,7 +225,7 @@ public final class ConfigurationParameterInitializer {
 
   /**
    * Initialize a component from a {@link CustomResourceSpecifier}.
-   * 
+   *
    * @param component
    *          the component to initialize.
    * @param spec
@@ -239,7 +241,7 @@ public final class ConfigurationParameterInitializer {
 
   /**
    * Initialize a component from a {@link CustomResourceSpecifier}.
-   * 
+   *
    * @param component
    *          the component to initialize.
    * @param parameters
@@ -259,7 +261,7 @@ public final class ConfigurationParameterInitializer {
 
   /**
    * Initialize a component from a {@link ResourceMetaData}.
-   * 
+   *
    * @param component
    *          the component to initialize.
    * @param parameters
@@ -279,7 +281,7 @@ public final class ConfigurationParameterInitializer {
 
   /**
    * Initialize a component from a {@link ResourceMetaData}.
-   * 
+   *
    * @param component
    *          the component to initialize.
    * @param dataResource
@@ -294,7 +296,7 @@ public final class ConfigurationParameterInitializer {
     ConfigurationParameterSettings settings = metaData.getConfigurationParameterSettings();
     initialize(component, settings.getParameterSettings());
   }
-  
+
   public static void initialize(Object component, Object... aParameters)
           throws ResourceInitializationException {
     ConfigurationData configurationData = createConfigurationData(aParameters);