org.apache.uima.resource.ResourceConfigurationException Java Examples
The following examples show how to use
org.apache.uima.resource.ResourceConfigurationException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConfigurationManagerImplBase.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Validate that a value is of an appropriate data type for assignment to the given parameter. * * @param aParam * configuration parameter * @param aValue * candidate value * @param aContextName * name of context, used to generate error message * * @throws ResourceConfigurationException * if the data types do not match */ private void validateConfigurationParameterDataTypeMatch(ConfigurationParameter aParam, Object aValue, String aContextName) throws ResourceConfigurationException { if (aValue != null) { Class<?> valClass = aValue.getClass(); if (aParam.isMultiValued() && !valClass.isArray()) { throw new ResourceConfigurationException(ResourceConfigurationException.ARRAY_REQUIRED, new Object[] { aParam.getName(), aContextName }); } if (!valClass.equals(getParameterExpectedValueClass(aParam))) { throw new ResourceConfigurationException( ResourceConfigurationException.PARAMETER_TYPE_MISMATCH, new Object[] { aContextName, valClass.getName(), aParam.getName(), aParam.getType() }); } } }
Example #2
Source File: CPMEngine.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Parses Cas Processor descriptor and checks if it is parallelizable. * * @param aDescPath - * fully qualified path to a CP descriptor * @param aCpName - * name of the CP * @param isConsumer - * true if the CP is a Cas Consumer, false otherwise * @return - true if CP is parallelizable, false otherwise * * @throws Exception - */ private boolean isMultipleDeploymentAllowed(String aDescPath, String aCpName, boolean isConsumer) throws Exception { OperationalProperties op = null; // Parse the descriptor to access Operational Properties ResourceSpecifier resourceSpecifier = cpeFactory.getSpecifier(new File(aDescPath).toURL()); if (resourceSpecifier != null && resourceSpecifier instanceof ResourceCreationSpecifier) { ResourceMetaData md = ((ResourceCreationSpecifier) resourceSpecifier).getMetaData(); if (md instanceof ProcessingResourceMetaData) { op = ((ProcessingResourceMetaData) md).getOperationalProperties(); if (op == null) { // Operational Properties not defined, so use defaults if (isConsumer) { return false; // the default for CasConsumer } return true; // default for AEs } return op.isMultipleDeploymentAllowed(); } } throw new ResourceConfigurationException(ResourceInitializationException.NOT_A_CAS_PROCESSOR, new Object[] { aCpName, "<unknown>", aDescPath }); }
Example #3
Source File: AggregateAnalysisEngine_impl.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * @see org.apache.uima.analysis_engine.AnalysisEngine#reconfigure() */ public void reconfigure() throws ResourceConfigurationException { // do base resource reconfiguration super.reconfigure(); // call this method recursively on each component Map<String, AnalysisEngine> components = this._getASB().getComponentAnalysisEngines(); Iterator<AnalysisEngine> it = components.values().iterator(); while (it.hasNext()) { ConfigurableResource component = it.next(); component.reconfigure(); } //and the FlowController FlowControllerContainer fcc = ((ASB_impl) _getASB()).getFlowControllerContainer(); fcc.reconfigure(); }
Example #4
Source File: CPEFactory.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Returns number of processing threads (Processing Units). * * @return Number of processing threads * @throws ResourceConfigurationException - */ public int getProcessingUnitThreadCount() throws ResourceConfigurationException { int threadCount; try { threadCount = this.getCpeDescriptor().getCpeCasProcessors().getConcurrentPUCount(); } catch (Exception e) { throw new ResourceConfigurationException(InvalidXMLException.REQUIRED_ATTRIBUTE_MISSING, new Object[] { "processingUnitThreadCount" }, new Exception(CpmLocalizedMessage .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_missing_attribute_from_xml_element__WARNING", new Object[] { Thread.currentThread().getName(), "casProcessors", "processingUnitThreadCount", "<casProcessors>", }))); } return threadCount; }
Example #5
Source File: CasProcessorConfigurationJAXBImpl.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Copies deployment type associated with this Cas Processor * * @param aJaxbCasProcessorConfig - - * configuration object containing Cas Processor configuration * @throws ResourceConfigurationException - */ private void addDeploymentType(CpeCasProcessor aCasProcessorConfig) throws ResourceConfigurationException { if (aCasProcessorConfig == null) { throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] { "<casProcessor>", "<casProcessors>" }, new Exception(CpmLocalizedMessage .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_bad_cpe_descriptor_no_cp__WARNING", new Object[] { Thread .currentThread().getName() }))); } String deployType = aCasProcessorConfig.getDeployment(); if (deployType == null || deployType.trim().length() == 0) { throw new ResourceConfigurationException(InvalidXMLException.REQUIRED_ATTRIBUTE_MISSING, new Object[] { "deployment", "casProcessor" }, new Exception(CpmLocalizedMessage .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_missing_attribute_from_xml_element__WARNING", new Object[] { Thread.currentThread().getName(), aCasProcessorConfig.getName(), "deployment", "<casProcessor>" }))); } deploymentType = deployType; }
Example #6
Source File: CasProcessorConfigurationJAXBImpl.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Returns parsed filter expressions as List. * */ public LinkedList getFilter() throws ResourceConfigurationException { String filterExpression = null; try { filterExpression = getFilterString(); if (filterExpression != null) { if (UIMAFramework.getLogger().isLoggable(Level.FINEST)) { UIMAFramework.getLogger(this.getClass()).logrb(Level.FINEST, this.getClass().getName(), "initialize", CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_show_cp_filter__FINEST", new Object[] { Thread.currentThread().getName(), name, filterExpression }); } Filter filter = new Filter(); return filter.parse(filterExpression); } } catch (Exception e) { throw new ResourceConfigurationException(InvalidXMLException.INVALID_ELEMENT_TEXT, new Object[] { "filter" }, new Exception(CpmLocalizedMessage.getLocalizedMessage( CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_missing_xml_element__WARNING", new Object[] { Thread.currentThread().getName(), name, "filer" }))); } return null; }
Example #7
Source File: FileSystemCollectionReader.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Initialize. * * @throws ResourceInitializationException the resource initialization exception * @see org.apache.uima.collection.CollectionReader_ImplBase#initialize() */ public void initialize() throws ResourceInitializationException { File directory = new File(((String) getConfigParameterValue(PARAM_INPUTDIR)).trim()); mEncoding = (String) getConfigParameterValue(PARAM_ENCODING); mLanguage = (String) getConfigParameterValue(PARAM_LANGUAGE); mRecursive = (Boolean) getConfigParameterValue(PARAM_SUBDIR); if (null == mRecursive) { // could be null if not set, it is optional mRecursive = Boolean.FALSE; } mCurrentIndex = 0; // if input directory does not exist or is not a directory, throw exception if (!directory.exists() || !directory.isDirectory()) { throw new ResourceInitializationException(ResourceConfigurationException.DIRECTORY_NOT_FOUND, new Object[] { PARAM_INPUTDIR, this.getMetaData().getName(), directory.getPath() }); } // get list of files in the specified directory, and subdirectories if the // parameter PARAM_SUBDIR is set to True mFiles = new ArrayList<>(); addFilesFromDir(directory); }
Example #8
Source File: VinciCasProcessorDeployer.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Returns CasProcessor service name from a descriptor. * * @param aCasProcessorConfig - * CasProcessor configuration containing service descriptor path * @return - name of the service * @throws ResourceConfigurationException if the uri is missing or empty */ private String getServiceUri(CasProcessorConfiguration aCasProcessorConfig) throws ResourceConfigurationException { URL descriptorUrl; descriptorUrl = aCasProcessorConfig.getDescriptorUrl(); URISpecifier uriSpecifier = getURISpecifier(descriptorUrl); String uri = uriSpecifier.getUri(); if (uri == null || uri.trim().length() == 0) { throw new ResourceConfigurationException(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_invalid_deployment__SEVERE", new Object[] { Thread.currentThread().getName(), descriptorUrl, uri }); } return uri; }
Example #9
Source File: Settings_impl.java From uima-uimaj with Apache License 2.0 | 6 votes |
private String lookUp(String from, String name) throws ResourceConfigurationException { // Maintain a set of variables being expanded so can recognize infinite recursion // Needs to be thread-local as multiple threads may be evaluating properties HashMap<String, Integer> resolving = tlResolving.get(); if (resolving.containsKey(name)) { System.err.println("Circular evaluation of property: '" + name + "' - definitions are:"); for (String s : resolving.keySet()) { System.err.println(resolving.get(s) + ": " + s + " = " + map.get(s)); } // Circular reference to external override variable "{0}" when evaluating "{1}" throw new ResourceConfigurationException(ResourceConfigurationException.EXTERNAL_OVERRIDE_CIRCULAR_REFERENCE, new Object[] { name, from }); } // Add the name for the duration of the lookup resolving.put(name, resolving.size()); try { return resolve(from, map.get(name)); } finally { resolving.remove(name); } }
Example #10
Source File: ConfigurationManagerImplBase.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Called during creation of a new context. Declares parameters, optionally in a group. Concrete * subclasses will likely want to override this to set up any necessary data structures. * * @param aGroupName * name of parameter group, null if none * @param aParams * parameter declarations * @param aSettings * settings for parameters * @param aContextName * name of context containing this parameter * @param aExternalOverrides * settings for parameters with external overrides * @throws ResourceConfigurationException passthru */ protected void declareParameters(String aGroupName, ConfigurationParameter[] aParams, ConfigurationParameterSettings aSettings, String aContextName, Settings aExternalOverrides) throws ResourceConfigurationException { // iterate over config. param _declarations_ if (aParams != null) { for (int i = 0; i < aParams.length; i++) { ConfigurationParameter param = aParams[i]; String qname = makeQualifiedName(aContextName, param.getName(), aGroupName); // if this parameter explicitly overrides others, enter those parameter links in the map String[] overrides = param.getOverrides(); for (int j = 0; j < overrides.length; j++) { mLinkMap.put(makeQualifiedName(aContextName, overrides[j], aGroupName), qname); } } } }
Example #11
Source File: ConfigurationManagerImplBase.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * Validates configuration parameter settings within a group. * * @param aContext * name of context containing the parameter settings * @param aParams * parameter declarations * @param aGroup * name of group to validate, null if none * * @throws ResourceConfigurationException * if the configuration parameter settings are invalid */ private void validateConfigurationParameterSettings(String aContext, ConfigurationParameter[] aParams, String aGroupName) throws ResourceConfigurationException { for (int i = 0; i < aParams.length; i++) { // get value Object val = this.getConfigParameterValue(aContext + aParams[i].getName(), aGroupName); // is required value missing? if (val == null && aParams[i].isMandatory()) { if (aGroupName != null) { throw new ResourceConfigurationException( ResourceConfigurationException.MANDATORY_VALUE_MISSING_IN_GROUP, new Object[] { aParams[i].getName(), aGroupName, aContext }); } else { throw new ResourceConfigurationException( ResourceConfigurationException.MANDATORY_VALUE_MISSING, new Object[] { aParams[i].getName(), aContext }); } } // check datatype validateConfigurationParameterDataTypeMatch(aParams[i], val, aContext); } }
Example #12
Source File: WhiteTextCollectionReader.java From bluima with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public void initialize(UimaContext context) throws ResourceInitializationException { try { if (corpus == null) { corpus = CorporaHelper.CORPORA_HOME + "/src/main/resources/pear_resources/whitetext/WhiteText.1.3.xml"; } checkArgument(new File(corpus).exists()); InputStream corpusIs = new FileInputStream(corpus); SAXBuilder builder = new SAXBuilder(); Document doc = builder.build(corpusIs); Element rootNode = doc.getRootElement(); articleIt = rootNode.getChildren("PubmedArticle").iterator(); } catch (Exception e) { throw new ResourceInitializationException( ResourceConfigurationException.NONEXISTENT_PARAMETER, new Object[] { corpus }); } }
Example #13
Source File: AnalysisEnginePool.java From uima-uimaj with Apache License 2.0 | 6 votes |
/** * @see org.apache.uima.resource.ConfigurableResource#reconfigure() * @throws ResourceConfigurationException - */ public synchronized void reconfigure() throws ResourceConfigurationException { // reconfigure each AnalysisEngine in the pool List<AnalysisEngine> toRelease = new ArrayList<>(); try { for (int i = 0; i < mPool.getSize(); i++) { // get an Analysis Engine from the pool AnalysisEngine ae = (AnalysisEngine) mPool.getResource(0); // wait forever // store AE instance on List to be released later toRelease.add(ae); // reconfigure ae.reconfigure(); } } finally { // release all AnalysisEngines back to pool Iterator<AnalysisEngine> it = toRelease.iterator(); while (it.hasNext()) { mPool.releaseResource(it.next()); } } }
Example #14
Source File: FileSystemCollectionReader.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * @see org.apache.uima.collection.CollectionReader_ImplBase#initialize() */ public void initialize() throws ResourceInitializationException { String dirPath = ((String) getConfigParameterValue(PARAM_INPUTDIR)).trim(); File directory = new File(dirPath); mEncoding = (String) getConfigParameterValue(PARAM_ENCODING); mLanguage = (String) getConfigParameterValue(PARAM_LANGUAGE); mXCAS = (String) getConfigParameterValue(PARAM_XCAS); //XCAS parameter can be set to "xcas" or "xmi", as well as "true" (which for historical reasons //means the same as "xcas"). Any other value will cause the input file to be treated as a text document. mTEXT = !("xcas".equalsIgnoreCase(mXCAS) || "xmi".equalsIgnoreCase(mXCAS) || "true".equalsIgnoreCase(mXCAS)); String mLenient = (String) getConfigParameterValue(PARAM_LENIENT); lenient = "true".equalsIgnoreCase(mLenient); mCurrentIndex = 0; // if input directory does not exist or is not a directory, throw exception if (!directory.exists() || !directory.isDirectory()) { throw new ResourceInitializationException(ResourceConfigurationException.DIRECTORY_NOT_FOUND, new Object[] { PARAM_INPUTDIR, this.getMetaData().getName(), directory.getPath() }); } // get list of files (not subdirectories) in the specified directory mFiles = new ArrayList(); File[] files = directory.listFiles(); for (int i = 0; i < files.length; i++) { if (!files[i].isDirectory()) { mFiles.add(files[i]); } } }
Example #15
Source File: ResourceMetaData_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Overridden to validate configuration parameter data types immediately after parsing is * complete. * * @see org.apache.uima.util.XMLizable#buildFromXMLElement(org.w3c.dom.Element, * org.apache.uima.util.XMLParser) */ public void buildFromXMLElement(Element aElement, XMLParser aParser, XMLParser.ParsingOptions aOptions) throws InvalidXMLException { super.buildFromXMLElement(aElement, aParser, aOptions); try { validateConfigurationParameterSettings(); } catch (ResourceConfigurationException e) { throw new InvalidXMLException(e); } }
Example #16
Source File: PrimitiveAnalysisEngine_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * @see org.apache.uima.analysis_engine.AnalysisEngine#reconfigure() */ public void reconfigure() throws ResourceConfigurationException { // do base resource reconfiguration super.reconfigure(); // inform the annotator UimaContext prevContext = setContextHolder(); // for use by POJOs try { mAnalysisComponent.reconfigure(); } catch (ResourceInitializationException e) { throw new ResourceConfigurationException(e); } finally { UimaContextHolder.setContext(prevContext); } }
Example #17
Source File: CPEFactory.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Check if a class has appropriate type. * * @param aResourceClass - * class to check * @param resourceSpecifier - * specifier containing expected type * @param aDescriptor - * descriptor name * @return true - if class matches type * @throws ResourceConfigurationException - */ public boolean isDefinitionInstanceOf(Class aResourceClass, ResourceSpecifier resourceSpecifier, String aDescriptor) throws ResourceConfigurationException { boolean validDefinition = false; String implementationClass = null; try { String frameworkName = null; if (resourceSpecifier instanceof AnalysisEngineDescription) { frameworkName = ((AnalysisEngineDescription) resourceSpecifier) .getFrameworkImplementation(); implementationClass = ((AnalysisEngineDescription) resourceSpecifier) .getImplementationName(); } else if (resourceSpecifier instanceof CasConsumerDescription) { frameworkName = ((CasConsumerDescription) resourceSpecifier).getFrameworkImplementation(); implementationClass = ((CasConsumerDescription) resourceSpecifier).getImplementationName(); } else { return false; } if (frameworkName.startsWith(org.apache.uima.Constants.CPP_FRAMEWORK_NAME)) { validDefinition = true; } else { // String className = ((CasConsumerDescription) resourceSpecifier).getImplementationName(); // load class using UIMA Extension ClassLoader if there is one Class currentClass = Class_TCCL.forName(implementationClass, getResourceManager()); // check to see if this is a subclass of aResourceClass if (aResourceClass.isAssignableFrom(currentClass)) { validDefinition = true; } } } catch (Exception e) { throw new ResourceConfigurationException(ResourceInitializationException.CLASS_NOT_FOUND, new Object[] { implementationClass, aDescriptor }, e); } return validDefinition; }
Example #18
Source File: CPMImpl.java From uima-uimaj with Apache License 2.0 | 5 votes |
public void setAnalysisEngine(AnalysisEngine aAnalysisEngine) throws ResourceConfigurationException { if (super.getCasProcessors().length > 0 && super.getCasProcessors()[0] instanceof AnalysisEngine) { super.removeCasProcessor(super.getCasProcessors()[0]); super.addCasProcessor(aAnalysisEngine, 0); } else { super.addCasProcessor(aAnalysisEngine, 0); } }
Example #19
Source File: UimaContextHolderTest.java From uima-uimaj with Apache License 2.0 | 5 votes |
@Override public void run() { try { result = testSettings(); } catch (ResourceConfigurationException e) { e.printStackTrace(); } }
Example #20
Source File: CPEFactory.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Instantiates a local (managed) Cas Processor. * * @param aCasProcessorCfg - * Cas Processor configuration * @return - Local CasProcessor * @throws ResourceConfigurationException - */ private CasProcessor produceLocalCasProcessor(CpeCasProcessor aCasProcessorCfg) throws ResourceConfigurationException { if (aCasProcessorCfg == null) { throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] { "casProcessor", "casProcessors" }, new Exception(CpmLocalizedMessage.getLocalizedMessage( CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_bad_cpe_descriptor_no_cp__WARNING", new Object[] { Thread.currentThread().getName() }))); } CasProcessor casProcessor = new NetworkCasProcessorImpl(aCasProcessorCfg); return casProcessor; }
Example #21
Source File: ResourceMetaData_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Validate that a value is of an appropriate data type for assignment to the given parameter. * <P> * NOTE: this method can cause a change to the NameValuePair object in the case where the value of * a parameter is an empty Object[] and the parameter type is an array of a different type. In * this case the empty object array will be replaced by an empty array of the appropriate type. * * @param aParam * configuration parameter * @param aNVP * name value pair containing candidate value * * @throws ResourceConfigurationException * if the data types do not match */ protected void validateConfigurationParameterDataTypeMatch(ConfigurationParameter aParam, NameValuePair aNVP) throws ResourceConfigurationException { String paramName = aParam.getName(); String paramType = aParam.getType(); if (aNVP.getValue() == null) { throw new ResourceConfigurationException(ResourceConfigurationException.CONFIG_SETTING_ABSENT, new Object[] { paramName }); } Class<?> valClass = aNVP.getValue().getClass(); if (aParam.isMultiValued()) // value must be an array { if (!valClass.isArray()) { throw new ResourceConfigurationException(ResourceConfigurationException.ARRAY_REQUIRED, new Object[] { paramName, getName() }); } valClass = valClass.getComponentType(); // check for zero-length array special case if (Array.getLength(aNVP.getValue()) == 0 && valClass.equals(Object.class)) { aNVP.setValue(Array.newInstance(getClassForParameterType(paramType), 0)); return; } } if (valClass != getClassForParameterType(paramType)) { throw new ResourceConfigurationException( ResourceConfigurationException.PARAMETER_TYPE_MISMATCH, new Object[] { getName(), valClass.getName(), paramName, paramType }); /* Parameter type mismatch in component "{0}". A value of class {1} cannot be assigned to the configuration parameter {2}, which has type {3}. */ } }
Example #22
Source File: ResourceMetaData_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Validates configuration parameter settings within a group. * * @param aNVPs * the parameter settings * @param aGroupName * the group * @param aParamDecls * Configuration Parameter Declarations * * @throws ResourceConfigurationException * if the configuration parameter settings are invalid */ protected void validateConfigurationParameterSettings(NameValuePair[] aNVPs, String aGroupName, ConfigurationParameterDeclarations aParamDecls) throws ResourceConfigurationException { for (int i = 0; i < aNVPs.length; i++) { // look up the parameter info String name = aNVPs[i].getName(); if (name == null) { throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] { "name", "nameValuePair" }); } ConfigurationParameter param = aParamDecls.getConfigurationParameter(aGroupName, name); if (param == null) { if (aGroupName == null) { throw new ResourceConfigurationException( ResourceConfigurationException.NONEXISTENT_PARAMETER, new Object[] { name, getName() }); } else { throw new ResourceConfigurationException( ResourceConfigurationException.NONEXISTENT_PARAMETER_IN_GROUP, new Object[] { name, aGroupName, getName() }); } } else { // check datatype validateConfigurationParameterDataTypeMatch(param, aNVPs[i]); } } }
Example #23
Source File: CasProcessorConfigurationJAXBImpl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Copies batch size associated with this Cas Processor * * @param aJaxbCasProcessorConfig - * configuration object containing Cas Processor configuration */ private void addBatchSize(CpeCasProcessor aCasProcessorConfig) throws ResourceConfigurationException { if (aCasProcessorConfig == null) { throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] { "<casProcessor>", "<casProcessors>" }, new Exception(CpmLocalizedMessage .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_bad_cpe_descriptor_no_cp__WARNING", new Object[] { Thread .currentThread().getName() }))); } CpeCheckpoint checkpoint = aCasProcessorConfig.getCheckpoint(); if (checkpoint == null) { throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] { "<checkpoint>", "<casProcessor>" }, new Exception(CpmLocalizedMessage .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_missing_xml_element__WARNING", new Object[] { Thread.currentThread().getName(), aCasProcessorConfig.getName(), "<checkpoint>" }))); } try { if (checkpoint.getBatchSize() > 0) { batchSize = checkpoint.getBatchSize(); } } catch (NumberFormatException e) { throw new ResourceConfigurationException(InvalidXMLException.REQUIRED_ATTRIBUTE_MISSING, new Object[] { "batch", "<checkpoint>" }, new Exception(CpmLocalizedMessage .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_missing_attribute_from_xml_element__WARNING", new Object[] { Thread.currentThread().getName(), aCasProcessorConfig.getName(), "batch", "<checkpoint>" }))); } }
Example #24
Source File: CpmPanel.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Adds the AE. * * @param aeSpecifierFile the ae specifier file * @throws CpeDescriptorException the cpe descriptor exception * @throws InvalidXMLException the invalid XML exception * @throws IOException Signals that an I/O exception has occurred. * @throws ResourceConfigurationException the resource configuration exception */ private void addAE(String aeSpecifierFile) throws CpeDescriptorException, InvalidXMLException, IOException, ResourceConfigurationException { String tempAeName = new File(aeSpecifierFile).getName(); // overriden later CpeCasProcessor casProc = CpeDescriptorFactory.produceCasProcessor(tempAeName); casProc.setDescriptor(aeSpecifierFile); casProc.setBatchSize(10000); casProc.getErrorHandling().getErrorRateThreshold().setMaxErrorCount(0); // add to pipeline as last AE but before CAS Consumers currentCpeDesc.addCasProcessor(aeTabbedPane.getTabCount(), casProc); // update GUI addAE(casProc); }
Example #25
Source File: AnalysisEngineDescription_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Determines if the AnalysisEngineDescription is valid. An exception is thrown if it is not * valid. This should be called from this Analysis Engine's initialize method. Note this does not * check configuration parameter settings - that must be done by an explicit call to * validateConfigurationParameterSettings. * * @param aResourceManager * a ResourceManager instance to use to resolve imports by name. * * @throws ResourceInitializationException * if <code>aDesc</code> is invalid * @throws ResourceConfigurationException * if the configuration parameter settings in <code>aDesc</code> are invalid */ public void validate(ResourceManager aResourceManager) throws ResourceInitializationException, ResourceConfigurationException { // do validation common to all descriptor types (e.g. config parameters) super.validate(aResourceManager); // TypeSystem may not be specified for an Aggregate Analysis Engine if (!isPrimitive() && getAnalysisEngineMetaData().getTypeSystem() != null) { throw new ResourceInitializationException( ResourceInitializationException.AGGREGATE_AE_TYPE_SYSTEM, new Object[] { getSourceUrlString() }); } //Keys in FixedFlow or LanguageCapabilityFlow must be defined FlowConstraints fc = getAnalysisEngineMetaData().getFlowConstraints(); String[] keys = null; if (fc instanceof FixedFlow) { keys = ((FixedFlow)fc).getFixedFlow(); } else if (fc instanceof CapabilityLanguageFlow) { keys = ((CapabilityLanguageFlow)fc).getCapabilityLanguageFlow(); } if (keys != null) { for (int i = 0; i < keys.length; i++) { if (!getDelegateAnalysisEngineSpecifiersWithImports().containsKey(keys[i])) { throw new ResourceInitializationException(ResourceInitializationException.UNDEFINED_KEY_IN_FLOW, new Object[]{getAnalysisEngineMetaData().getName(), keys[i], getSourceUrlString()}); } } } }
Example #26
Source File: UimacppAnalysisEngineImpl.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * @see org.apache.uima.analysis_engine.AnalysisEngine#reconfigure() */ public void reconfigure() throws ResourceConfigurationException { // do base resource reconfiguration super.reconfigure(); mAnnotator.reconfigure(); }
Example #27
Source File: VinciCasProcessorDeployer.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Parses given service descriptor and returns initialized ResourceSpecifier. * * @param aUrl - * URL of the descriptor * @return - ResourceSpecifier parsed from descriptor * @throws ResourceConfigurationException wraps Exception */ private ResourceSpecifier getSpecifier(URL aUrl) throws ResourceConfigurationException { try { XMLInputSource in = new XMLInputSource(aUrl); return UIMAFramework.getXMLParser().parseResourceSpecifier(in); } catch (Exception e) { e.printStackTrace(); throw new ResourceConfigurationException(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_invalid_deployment__SEVERE", new Object[] { Thread.currentThread().getName(), aUrl, null }); } }
Example #28
Source File: CPEFactory.java From uima-uimaj with Apache License 2.0 | 5 votes |
/** * Checks if cpe description has been created. * * @throws ResourceConfigurationException the resource configuration exception */ private void checkForErrors() throws ResourceConfigurationException { if (cpeDescriptor == null) { throw new ResourceConfigurationException(new Exception(CpmLocalizedMessage .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_EXP_no_cpe_descriptor__WARNING", new Object[] { Thread .currentThread().getName() }))); } }
Example #29
Source File: TestResourceInterface_impl.java From uima-uimaj with Apache License 2.0 | 4 votes |
/** * @see org.apache.uima.resource.Resource#setConfigurationParameters(NameValuePair[]) */ public void setConfigurationParameters(NameValuePair[] aSettings) throws ResourceConfigurationException { }
Example #30
Source File: CollectionReaderAdapter.java From uima-uimaj with Apache License 2.0 | 4 votes |
public void reconfigure() throws ResourceInitializationException, ResourceConfigurationException { mCollectionReader.reconfigure(); }