use of org.apache.uima.resource.ResourceManager in project dkpro-tc by dkpro.
the class FeatureUtil method createResource.
@SuppressWarnings("unchecked")
public static <T extends Resource> T createResource(TcFeature feature) throws ResourceInitializationException, ResourceAccessException {
// Configure external resource
ExternalResourceDescription desc = feature.getActualValue();
// Configure resource manager
ResourceManagerConfiguration cfg = UIMAFramework.getResourceSpecifierFactory().createResourceManagerConfiguration();
ExternalResourceFactory.bindExternalResource(cfg, "rootResource", desc);
// Instantiate resource manager (internally instantiates resources)
final ResourceManager manager = new ResourceManager_impl();
manager.initializeExternalResources(cfg, "/", null);
T res = (T) manager.getResource("/rootResource");
// Initialize nested resources
UimaContextAdmin ctx = new RootUimaContext_impl() {
@Override
public ResourceManager getResourceManager() {
return manager;
}
};
ExternalResourceInitializer.initialize(res, ctx);
// Get resource instance
return res;
}
Aggregations