This is an automated email from the ASF dual-hosted git repository. rec pushed a commit to branch sync-v2-to-master in repository https://gitbox.apache.org/repos/asf/uima-uimafit.git
commit 1b317de0ceab64b467318452ab2fc06afea9e9a6 Merge: 100dd61 a2dec8a Author: Richard Eckart de Castilho <r...@apache.org> AuthorDate: Mon Feb 3 08:39:08 2020 +0100 Merge branch 'master-v2' into sync-v2-to-master * master-v2: [UIMA-6186] Factory methods for resource instances [UIMA-6169] Support Charset-typed parameters in components # Conflicts: # uimafit-core/pom.xml # uimafit-core/src/main/java/org/apache/uima/fit/factory/ExternalResourceFactory.java uimafit-core/pom.xml | 6 + .../ConfigurationParameterInitializer.java | 74 ++-- .../uima/fit/factory/ExternalResourceFactory.java | 60 +++- ...{PropertyEditorUtil.java => ChatsetEditor.java} | 29 +- .../propertyeditors/PropertyEditorUtil.java | 3 + .../ConfigurationParameterInitializerTest.java | 385 ++++++++++++++++++++- .../fit/factory/ResourceManagerFactoryTest.java | 55 +++ .../tools.uimafit.configurationparameters.xml | 21 +- 8 files changed, 569 insertions(+), 64 deletions(-) diff --cc uimafit-core/pom.xml index f5dac3a,2e78eee..54b3f84 --- a/uimafit-core/pom.xml +++ b/uimafit-core/pom.xml @@@ -56,10 -62,12 +56,16 @@@ <artifactId>spring-beans</artifactId> </dependency> <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-collections4</artifactId> + <version>4.4</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <scope>test</scope> diff --cc uimafit-core/src/main/java/org/apache/uima/fit/factory/ExternalResourceFactory.java index 91491d4,46abee8..6a1dc2b --- a/uimafit-core/src/main/java/org/apache/uima/fit/factory/ExternalResourceFactory.java +++ b/uimafit-core/src/main/java/org/apache/uima/fit/factory/ExternalResourceFactory.java @@@ -36,7 -38,7 +38,6 @@@ import java.util.Map import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicLong; - import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang.ArrayUtils; import org.apache.uima.UIMAFramework; import org.apache.uima.analysis_engine.AnalysisEngineDescription; import org.apache.uima.collection.CollectionReaderDescription; @@@ -1233,8 -1236,7 +1233,7 @@@ public final class ExternalResourceFact * uimaFIT internal use. This method is required by the ConfigurationParameterFactory, so it is * package private instead of private. */ - static ResourceValueType getResourceParameterType(Object aValue) - { - static ResourceValueType getExternalResourceParameterType(Object aValue) { ++ static ResourceValueType getResourceParameterType(Object aValue) { if (aValue == null) { return ResourceValueType.NO_RESOURCE; } @@@ -1261,6 -1260,48 +1257,48 @@@ } /** + * Create an instance of a UIMA shared/external resource class. + * + * @param <R> + * the resource type. + * @param resourceClass + * the class implementing the resource. + * @param params + * parameters passed to the resource when it is created. Each parameter consists of two + * arguments, the first being the name and the second being the parameter value + * @return the resource instance. + * @throws ResourceInitializationException + * if there was a problem instantiating the resource. + */ + public static <R> R createExternalResource(Class<? extends Resource> resourceClass, + Object... params) throws ResourceInitializationException { + return createExternalResource(resourceClass, null, params); + } + + /** + * Create an instance of a UIMA shared/external resource class. + * + * @param <R> + * the resource type. + * @param resourceClass + * the class implementing the resource. + * @param resMgr + * a resource manager (optional). + * @param params + * parameters passed to the resource when it is created. Each parameter consists of two + * arguments, the first being the name and the second being the parameter value + * @return the resource instance. + * @throws ResourceInitializationException + * if there was a problem instantiating the resource. + */ + @SuppressWarnings("unchecked") + public static <R> R createExternalResource(Class<? extends Resource> resourceClass, + ResourceManager resMgr, Object... params) throws ResourceInitializationException { - ExternalResourceDescription res = createExternalResourceDescription(resourceClass, params); ++ ExternalResourceDescription res = createResourceDescription(resourceClass, params); + return (R) produceResource(resourceClass, res.getResourceSpecifier(), resMgr, emptyMap()); + } + + /** * Types of external resource values. */ static enum ResourceValueType {