Java Code Examples for org.apache.uima.resource.ResourceInitializationException#MISSING_IMPLEMENTATION_CLASS_NAME

The following examples show how to use org.apache.uima.resource.ResourceInitializationException#MISSING_IMPLEMENTATION_CLASS_NAME . 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: FlowControllerDescription_impl.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
public void doFullValidation(ResourceManager aResourceManager)
        throws ResourceInitializationException {
  // check that user class was specified
  if (getImplementationName() == null || getImplementationName().length() == 0) {
    throw new ResourceInitializationException(
            ResourceInitializationException.MISSING_IMPLEMENTATION_CLASS_NAME,
            new Object[] { getSourceUrlString() });
  }
  // try to load user class
  // use UIMA extension ClassLoader if available
  Class<?> implClass;
  try {
    implClass = Class_TCCL.forName(getImplementationName(), aResourceManager);
  } catch (ClassNotFoundException e) {
    throw new ResourceInitializationException(ResourceInitializationException.CLASS_NOT_FOUND,
            new Object[] { getImplementationName(), getSourceUrlString() }, e);
  }
  // verify the user class implements FlowController
  if (!FlowController.class.isAssignableFrom(implClass)) {
    throw new ResourceInitializationException(
            ResourceInitializationException.RESOURCE_DOES_NOT_IMPLEMENT_INTERFACE, new Object[] {
                getImplementationName(), FlowController.class.getName(), getSourceUrlString() });
  }
}
 
Example 2
Source File: CasConsumerDescription_impl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
public void doFullValidation(ResourceManager aResourceManager)
        throws ResourceInitializationException {
  // check that user class was specified
  if (getImplementationName() == null || getImplementationName().length() == 0) {
    throw new ResourceInitializationException(
            ResourceInitializationException.MISSING_IMPLEMENTATION_CLASS_NAME,
            new Object[] { getSourceUrlString() });
  }
  // try to load user class
  // just UIMA extension ClassLoader if available
  Class<?> implClass;
  try {
    implClass = Class_TCCL.forName(getImplementationName(), aResourceManager);
  } catch (ClassNotFoundException e) {
    throw new ResourceInitializationException(ResourceInitializationException.CLASS_NOT_FOUND,
            new Object[] { getImplementationName(), getSourceUrlString() }, e);
  }
  // verify the user class implements CasConsumer
  if (!CasConsumer.class.isAssignableFrom(implClass)) {
    throw new ResourceInitializationException(
            ResourceInitializationException.RESOURCE_DOES_NOT_IMPLEMENT_INTERFACE, new Object[] {
                getImplementationName(), CasConsumer.class.getName(), getSourceUrlString() });
  }
  // try to create a CAS
  List<ProcessingResourceMetaData> metadata = new ArrayList<>();
  metadata.add(getCasConsumerMetaData());
  CasCreationUtils.createCas(metadata);
}
 
Example 3
Source File: CollectionReaderDescription_impl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
public void doFullValidation(ResourceManager aResourceManager)
        throws ResourceInitializationException {
  // check that user class was specified
  if (getImplementationName() == null || getImplementationName().length() == 0) {
    throw new ResourceInitializationException(
            ResourceInitializationException.MISSING_IMPLEMENTATION_CLASS_NAME,
            new Object[] { getSourceUrlString() });
  }
  // try to load user class

  // use UIMA extension ClassLoader if available
  Class<?> implClass;
  try {
    implClass = Class_TCCL.forName(getImplementationName(), aResourceManager);
  } catch (ClassNotFoundException e) {
    throw new ResourceInitializationException(ResourceInitializationException.CLASS_NOT_FOUND,
            new Object[] { getImplementationName(), getSourceUrlString() }, e);
  }
  // verify the user class implements CollectionReader
  if (!CollectionReader.class.isAssignableFrom(implClass)) {
    throw new ResourceInitializationException(
            ResourceInitializationException.RESOURCE_DOES_NOT_IMPLEMENT_INTERFACE, new Object[] {
                getImplementationName(), CollectionReader.class.getName(), getSourceUrlString() });
  }
  // try to create a CAS
  ArrayList<ProcessingResourceMetaData> metadata = new ArrayList<>();
  metadata.add(getCollectionReaderMetaData());
  CasCreationUtils.createCas(metadata, 
      UIMAFramework.getDefaultPerformanceTuningProperties(),
      aResourceManager);
}
 
Example 4
Source File: CasInitializerDescription_impl.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
public void doFullValidation(ResourceManager aResourceManager)
        throws ResourceInitializationException {
  // check that user class was specified
  if (getImplementationName() == null || getImplementationName().length() == 0) {
    throw new ResourceInitializationException(
            ResourceInitializationException.MISSING_IMPLEMENTATION_CLASS_NAME,
            new Object[] { getSourceUrlString() });
  }
  // try to load user class
  // just UIMA extension ClassLoader if available
  Class<?> implClass;
  try {
    implClass = Class_TCCL.forName(getImplementationName(), aResourceManager);
  } catch (ClassNotFoundException e) {
    throw new ResourceInitializationException(ResourceInitializationException.CLASS_NOT_FOUND,
            new Object[] { getImplementationName(), getSourceUrlString() }, e);
  }
  // verify the user class implements CasInitializer
  if (!CasInitializer.class.isAssignableFrom(implClass)) {
    throw new ResourceInitializationException(
            ResourceInitializationException.RESOURCE_DOES_NOT_IMPLEMENT_INTERFACE, new Object[] {
                getImplementationName(), CasInitializer.class.getName(), getSourceUrlString() });
  }
  // try to create a CAS
  List<ProcessingResourceMetaData> metadata = new ArrayList<>();
  metadata.add(getCasInitializerMetaData());
  CasCreationUtils.createCas(metadata);
}
 
Example 5
Source File: FlowControllerContainer.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates the FlowController class specified in the descriptor.
 */
private FlowController instantiateFlowController(ResourceCreationSpecifier aDescriptor)
        throws ResourceInitializationException {
  String flowControllerClassName;
  flowControllerClassName = aDescriptor.getImplementationName();

  if (flowControllerClassName == null || flowControllerClassName.length() == 0) {
    throw new ResourceInitializationException(
            ResourceInitializationException.MISSING_IMPLEMENTATION_CLASS_NAME,
            new Object[] { aDescriptor.getSourceUrlString() });
  }
  // load FlowController class
  Class<?> flowControllerClass = loadUserClassOrThrow(flowControllerClassName, aDescriptor);

  Object userObject;
  try {
    userObject = flowControllerClass.newInstance();
  } catch (Exception e) {
    throw new ResourceInitializationException(
            ResourceInitializationException.COULD_NOT_INSTANTIATE, new Object[] {
                flowControllerClassName, aDescriptor.getSourceUrlString() }, e);
  }
  if (!(userObject instanceof FlowController)) {
    throw new ResourceInitializationException(
            ResourceInitializationException.RESOURCE_DOES_NOT_IMPLEMENT_INTERFACE, new Object[] {
                flowControllerClassName, FlowController.class, aDescriptor.getSourceUrlString() });
  }
  return (FlowController) userObject;
}