本文整理汇总了Java中org.apache.uima.resource.SharedResourceObject类的典型用法代码示例。如果您正苦于以下问题:Java SharedResourceObject类的具体用法?Java SharedResourceObject怎么用?Java SharedResourceObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SharedResourceObject类属于org.apache.uima.resource包,在下文中一共展示了SharedResourceObject类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadResource
import org.apache.uima.resource.SharedResourceObject; //导入依赖的package包/类
public Object loadResource(ResourceType resourceType) {
URL resourceURL = getResourceURL(resourceType);
try {
if(SharedResourceObject.class.isAssignableFrom(resourceType.getResourceClass())) {
SharedResourceObject sro = (SharedResourceObject)resourceType.getResourceClass().newInstance();
sro.load(new UIMATermSuiteResourceWrapper(resourceURL));
return sro;
} else if(TermSuiteResource.class.isAssignableFrom(resourceType.getResourceClass())) {
try(InputStreamReader reader = new InputStreamReader(resourceURL.openStream())) {
TermSuiteResource tr = (TermSuiteResource)resourceType.getResourceClass().newInstance();
tr.load(reader);
return tr;
}
} else
throw new IllegalStateException(String.format("resource implementing classes must be a subtype of %s or %s",
SharedResourceObject.class.getSimpleName(),
TermSuiteResource.class.getSimpleName()));
} catch (Exception e) {
throw new TermSuiteException("Resource initialization error", e);
}
}
开发者ID:termsuite,项目名称:termsuite-core,代码行数:23,代码来源:TermSuiteResourceManager.java
示例2: configure
import org.apache.uima.resource.SharedResourceObject; //导入依赖的package包/类
public void configure() {
for(Field field:engineInjector.getAnnotatedFields(description.getEngineClass(), Resource.class, SharedResourceObject.class, TermSuiteResource.class)) {
Resource annotation = field.getAnnotation(Resource.class);
ResourceType resourceType = annotation.type();
resourceMgr.registerResource(description.getEngineName(), resourceType);
}
}
开发者ID:termsuite,项目名称:termsuite-core,代码行数:8,代码来源:EngineRunner.java
示例3: injectResources
import org.apache.uima.resource.SharedResourceObject; //导入依赖的package包/类
public void injectResources(Object instance) {
for(Field field:getAnnotatedFields(instance, Resource.class, SharedResourceObject.class, TermSuiteResource.class)) {
Resource annotation = field.getAnnotation(Resource.class);
ResourceType resourceType = annotation.type();
injectField(field, instance, mgr.get(resourceType));
}
}
开发者ID:termsuite,项目名称:termsuite-core,代码行数:8,代码来源:ResourceInjector.java
示例4: injectMembers
import org.apache.uima.resource.SharedResourceObject; //导入依赖的package包/类
@Override
public void injectMembers(T instance) {
Class<?> fieldClass = field.getType();
Preconditions.checkState(
SharedResourceObject.class.isAssignableFrom(fieldClass)
|| TermSuiteResource.class.isAssignableFrom(fieldClass) ,
"Can only inject resource of type %s or %s. Got: %s",
SharedResourceObject.class,
fieldClass);
try {
field.set(instance, resourceMgr.get(resourceType));
} catch (IllegalAccessException e) {
throw new TermSuiteException("An error occurred during injection of resource", e);
}
}
开发者ID:termsuite,项目名称:termsuite-core,代码行数:16,代码来源:ResourceInjector.java
注:本文中的org.apache.uima.resource.SharedResourceObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论