private <T> Object createParamForClass(String value, Class<T> clas) throws ResourceConfigurationException { Method valOf; try { valOf = clas.getMethod("valueOf", String.class); return valOf.invoke(null, value); } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { if (e.getCause() instanceof NumberFormatException) { // External override value "{0}" is not an integer throw new ResourceConfigurationException(ResourceConfigurationException.EXTERNAL_OVERRIDE_NUMERIC_ERROR, new Object[] { value }); } e.printStackTrace(); throw new ResourceConfigurationException(e); } }
casProcessorPool.addCasProcessor(casProcessor); } catch (ResourceConfigurationException e) { e.printStackTrace(); throw e; } catch (Exception e) { e.printStackTrace(); throw new ResourceConfigurationException(ResourceServiceException.RESOURCE_UNAVAILABLE, new Object[] {}, e);
throw new ResourceConfigurationException( ResourceInitializationException.CONFIG_SETTING_ABSENT, new Object[] { "ProcessControllerAdapter" }); "UIMA_CPM_unable_to_read_meta__SEVERE", Thread.currentThread().getName()); throw new ResourceConfigurationException(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_casprocessor_no_name_found__SEVERE", new Object[] { Thread .currentThread().getName() }); throw new ResourceConfigurationException(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_invalid_container__SEVERE", new Object[] { Thread.currentThread() .getName() }); throw new ResourceConfigurationException(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_container_configuration_not_found__SEVERE", new Object[] { Thread .currentThread().getName() }); UIMAFramework.getLogger(this.getClass()).log(Level.SEVERE, e.getMessage(), e); UIMAFramework.getLogger(this.getClass()).log(Level.SEVERE, e.getMessage(), e); throw new ResourceConfigurationException(e);
e.printStackTrace(); } catch (ResourceConfigurationException e) { e.printStackTrace();
UIMAFramework.getLogger().log(Level.WARNING, "Ignoring error in parameter setting: " + e.getMessage());
throw rpe; } catch (ResourceConfigurationException rpe) { if (rpe.getCause() != null && rpe.getCause() instanceof KillPipelineException) { try { handleKillPipeline(container); throw new ResourceProcessException(rpe.getCause()); } catch (Exception rpe) { pTrTemp.endEvent(container.getName(), "Process", "failure");
new Object[] { Thread.currentThread().getName() }); throw new ResourceConfigurationException( InvalidXMLException.REQUIRED_ATTRIBUTE_MISSING, new Object[] { "name", "casProcessor" }, new Exception(CpmLocalizedMessage.getLocalizedMessage( throw new ResourceConfigurationException(InvalidXMLException.ELEMENT_NOT_FOUND, new Object[] { "<casProcessor>", "<casProcessors>" }, new Exception( CpmLocalizedMessage.getLocalizedMessage( e.printStackTrace(); throw e; } catch (Exception e) { e.printStackTrace(); throw new ResourceConfigurationException(ResourceServiceException.RESOURCE_UNAVAILABLE, new Object[] {}, e);
targetEngine.reconfigure(); } catch (ResourceConfigurationException e) { e.printStackTrace();
public void reconfigure() throws ResourceConfigurationException, ResourceInitializationException { try { mAnnotator.reconfigure(); } catch (AnnotatorConfigurationException e) { throw new ResourceConfigurationException(e); } catch (AnnotatorInitializationException e) { throw new ResourceInitializationException(e); } }
targetEngine.reconfigure(); } catch (ResourceConfigurationException e) { e.printStackTrace();
/** * 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() }))); } }
/** * Returns URISpecifier. * * @param aDescriptorUrl the a descriptor url * @return URISpecifier * @throws ResourceConfigurationException if the resource specifier in the URI is not a URISpecifier */ private URISpecifier getURISpecifier(URL aDescriptorUrl) throws ResourceConfigurationException { ResourceSpecifier resourceSpecifier = getSpecifier(aDescriptorUrl); if (!(resourceSpecifier instanceof URISpecifier)) { throw new ResourceConfigurationException(CPMUtils.CPM_LOG_RESOURCE_BUNDLE, "UIMA_CPM_invalid_deployment__SEVERE", new Object[] { Thread.currentThread().getName(), aDescriptorUrl, null }); } return (URISpecifier) resourceSpecifier; }
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, new Integer(resolving.size())); try { return resolve(from, map.get(name)); } finally { resolving.remove(name); } }
/** * Copies filter expression used during processing. * * @param aJaxbCasProcessorConfig - * configuration object containing Cas Processor configuration */ private void addFiltering(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() }))); } filterString = aCasProcessorConfig.getCasProcessorFilter(); }
/** * @see org.apache.uima.util.Settings#getSetting(java.lang.String) */ @Override public String getSetting(String name) throws ResourceConfigurationException { String value = lookUp(name, name); if (value == null) { return null; } // Arrays start with '[' and end with an ] that is not escaped if (value.length() >= 2 && value.charAt(0) == '[' && value.charAt(value.length() - 1) == ']' && value.charAt(value.length() - 2) != '\\') { // External override value for "{0}" has the wrong type (scalar or array) throw new ResourceConfigurationException(ResourceConfigurationException.EXTERNAL_OVERRIDE_TYPE_MISMATCH, new Object[] { name }); } return unescape(value); // Process escape characters after checking for array syntax }
/** * 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; }
/** * 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; }
/** * 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 }); } }
/** * 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; }
String val = lookUp(from, key); if (val == null) { // Undefined reference to external override variable "{0}" when evaluating "{1}" throw new ResourceConfigurationException(ResourceConfigurationException.EXTERNAL_OVERRIDE_INVALID, new Object[] { key, from });