Java Code Examples for org.apache.uima.util.InvalidXMLException#REQUIRED_ATTRIBUTE_MISSING

The following examples show how to use org.apache.uima.util.InvalidXMLException#REQUIRED_ATTRIBUTE_MISSING . 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: CPEFactory.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * 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 2
Source File: CasProcessorConfigurationJAXBImpl.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * 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 3
Source File: ConfigurationGroup_impl.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Overridden to read <code>names</code> property from XML attribute.
 * 
 * @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 {
  String names = aElement.getAttribute("names");
  if (names.length() == 0) {
    throw new InvalidXMLException(InvalidXMLException.REQUIRED_ATTRIBUTE_MISSING, new Object[] {
        "names", "configurationGroup" });
  }
  // treat names as a space-separated list
  StringTokenizer tokenizer = new StringTokenizer(names, " \t");
  List<String> nameList = new ArrayList<>();
  while (tokenizer.hasMoreTokens()) {
    nameList.add(tokenizer.nextToken());
  }
  String[] nameArr = new String[nameList.size()];
  nameList.toArray(nameArr);
  setNames(nameArr);

  // call superclass method to read the configurationParameters property
  super.buildFromXMLElement(aElement, aParser, aOptions);
}
 
Example 4
Source File: CasProcessorConfigurationJAXBImpl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * 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 5
Source File: DeployFactory.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a
 * {@link org.apache.uima.collection.impl.base_cpm.container.deployer.CasProcessorDeployer} object
 * that specializes in deploying components as either local, remote, or integrated.
 * 
 * @param aCpeFactory cpe factory
 * @param aCasProcessorConfig cpe configuration reference
 * @param aPca mode of deployment.
 * @return appropriate deployer object for the mode of depolyment
 * @throws ResourceConfigurationException missing protocol or other deployment error
 */

public static CasProcessorDeployer getDeployer(CPEFactory aCpeFactory,
        CpeCasProcessor aCasProcessorConfig, ProcessControllerAdapter aPca)
        throws ResourceConfigurationException {
  String deployMode = aCasProcessorConfig.getDeployment();

  if (Constants.DEPLOYMENT_LOCAL.equals(deployMode)) {
    return new VinciCasProcessorDeployer(aCpeFactory);
  } else if (Constants.DEPLOYMENT_REMOTE.equals(deployMode)) {
    String protocol = getProtocol(aCasProcessorConfig, aCpeFactory.getResourceManager());
    if (protocol == null || protocol.trim().length() == 0) {
      throw new ResourceConfigurationException(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
              "UIMA_CPM_invalid_service_descriptor__SEVERE", new Object[] {
                  Thread.currentThread().getName(), "<uriSpecifier>", "<protocol>" },
              new Exception(CpmLocalizedMessage.getLocalizedMessage(
                      CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                      "UIMA_CPM_EXP_invalid_service_descriptor__WARNING", new Object[] {
                          Thread.currentThread().getName(), aCasProcessorConfig.getName() })));
    } else if (Constants.SOCKET_PROTOCOL.equalsIgnoreCase(protocol)) {
      if (aPca == null) {
        throw new ResourceConfigurationException(
                ResourceInitializationException.CONFIG_SETTING_ABSENT,
                new Object[] { "ProcessControllerAdapter" });
      }
      return new SocketCasProcessorDeployer(aPca, aCpeFactory);
    } else {
      // Default is still Vinci
      return new VinciCasProcessorDeployer(aCpeFactory);
    }
  } else if (Constants.DEPLOYMENT_INTEGRATED.equals(deployMode)) {
    return new CPEDeployerDefaultImpl(aCpeFactory);
  }
  throw new ResourceConfigurationException(InvalidXMLException.REQUIRED_ATTRIBUTE_MISSING,
          new Object[] { "deployment", "casProcessor" }, new Exception(CpmLocalizedMessage
                  .getLocalizedMessage(CPMUtils.CPM_LOG_RESOURCE_BUNDLE,
                          "UIMA_CPM_Exception_invalid_deployment__WARNING", new Object[] {
                              Thread.currentThread().getName(), aCasProcessorConfig.getName(),
                              deployMode })));
}