use of org.apache.uima.resource.impl.ResourceManager_impl in project dkpro-tc by dkpro.
the class FeatureUtil method createResource.
// TODO this will eventually also be included in uimaFit and can be removed then
@SuppressWarnings("unchecked")
public static <T extends Resource> T createResource(Class<T> aClass, Object... aParam) throws ResourceInitializationException, ResourceAccessException {
// Configure external resource
ExternalResourceDescription desc = ExternalResourceFactory.createExternalResourceDescription(aClass, aParam);
// 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;
}
use of org.apache.uima.resource.impl.ResourceManager_impl 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