Java Code Examples for org.apache.uima.resource.ResourceInitializationException#CLASS_NOT_FOUND
The following examples show how to use
org.apache.uima.resource.ResourceInitializationException#CLASS_NOT_FOUND .
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 |
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: 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 3
Source File: ResourceManager_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
public static Class<?> loadUserClassOrThrow(String name, ResourceManager rm, ResourceSpecifier aSpecifier) throws ResourceInitializationException { try { return Class_TCCL.forName(name, rm, true); } catch (ClassNotFoundException e) { throw new ResourceInitializationException( ResourceInitializationException.CLASS_NOT_FOUND, new Object[] { name, aSpecifier.getSourceUrlString() }, e); } }
Example 4
Source File: CasConsumerDescription_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
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 5
Source File: CollectionReaderDescription_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
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 6
Source File: CasInitializerDescription_impl.java From uima-uimaj with Apache License 2.0 | 5 votes |
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); }