forked from cgaege/ruta-pear-archetype
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from averbis/10-Update-archetype-for-UIMA-3-OS…
…Gi-combination Issue #10: Update archetype for UIMA 3 OSGi combination
- Loading branch information
Showing
25 changed files
with
12,659 additions
and
445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
...ain/resources/archetype-resources/src/main/java/GenerateConfiguredDescriptorTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright 2021 Averbis GmbH | ||
* | ||
* Licensed 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 ${package}; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.io.OutputStream; | ||
|
||
import org.apache.uima.analysis_engine.AnalysisEngineDescription; | ||
import org.apache.uima.fit.factory.AnalysisEngineFactory; | ||
import org.apache.uima.resource.ResourceInitializationException; | ||
import org.apache.uima.resource.metadata.ConfigurationParameter; | ||
import org.apache.uima.resource.metadata.ConfigurationParameterDeclarations; | ||
import org.apache.uima.resource.metadata.ConfigurationParameterSettings; | ||
import org.apache.uima.ruta.ReindexUpdateMode; | ||
import org.apache.uima.ruta.engine.RutaEngine; | ||
import org.xml.sax.SAXException; | ||
|
||
/** | ||
* Helper class for manually generating a preconfigured descriptor template for the generated Ruta | ||
* analysis engine descriptors | ||
* | ||
*/ | ||
public class GenerateConfiguredDescriptorTemplate { | ||
|
||
public static void main(String[] args) throws ResourceInitializationException, | ||
FileNotFoundException, SAXException, IOException { | ||
|
||
File outputFile = new File("src/main/resources/descriptor/GeneratedBasicEngine.xml"); | ||
outputFile.getParentFile().mkdirs(); | ||
|
||
AnalysisEngineDescription description = AnalysisEngineFactory | ||
.createEngineDescription(RutaEngine.class); | ||
|
||
// activate complete reindexing mode for compatibility in OSGi environments | ||
description.getAnalysisEngineMetaData().getConfigurationParameterSettings() | ||
.setParameterValue(RutaEngine.PARAM_REINDEX_UPDATE_MODE, | ||
ReindexUpdateMode.COMPLETE.name()); | ||
|
||
// optionally activate rule debug information by passing 'true' | ||
configureIfAvailable(description, RutaEngine.PARAM_DEBUG, false); | ||
configureIfAvailable(description, RutaEngine.PARAM_DEBUG_WITH_MATCHES, false); | ||
|
||
try (OutputStream os = new FileOutputStream(outputFile)) { | ||
description.toXML(os); | ||
} | ||
} | ||
|
||
|
||
private static void configureIfAvailable(AnalysisEngineDescription description, String param, | ||
Object value) { | ||
|
||
ConfigurationParameterDeclarations configurationParameterDeclarations = description | ||
.getAnalysisEngineMetaData().getConfigurationParameterDeclarations(); | ||
ConfigurationParameterSettings configurationParameterSettings = description | ||
.getAnalysisEngineMetaData().getConfigurationParameterSettings(); | ||
|
||
ConfigurationParameter configurationParameter = configurationParameterDeclarations | ||
.getConfigurationParameter(null, param); | ||
|
||
if (configurationParameter != null) { | ||
configurationParameterSettings.setParameterValue(param, value); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.