下面列出了org.springframework.beans.PropertyAccessor#setPropertyValue ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Handle Spring-initialization of resoures produced by the UIMA framework.
*/
public static Resource initResource(Resource aResource, ApplicationContext aApplicationContext) {
AutowireCapableBeanFactory beanFactory = aApplicationContext.getAutowireCapableBeanFactory();
if (aResource instanceof PrimitiveAnalysisEngine_impl) {
PropertyAccessor pa = PropertyAccessorFactory.forDirectFieldAccess(aResource);
// Access the actual AnalysisComponent and initialize it
AnalysisComponent analysisComponent = (AnalysisComponent) pa
.getPropertyValue("mAnalysisComponent");
initializeBean(beanFactory, analysisComponent, aResource.getMetaData().getName());
pa.setPropertyValue("mAnalysisComponent", analysisComponent);
return aResource;
} else {
return (Resource) beanFactory.initializeBean(aResource, aResource.getMetaData().getName());
}
}
private Directory getDirectoryService() {
HttpTransport httpTransport = new NetHttpTransport();
JacksonFactory jacksonFactory = new JacksonFactory();
GoogleCredential credential = getGoogleCredential();
PropertyAccessor accessor = PropertyAccessorFactory.forDirectFieldAccess(credential);
accessor.setPropertyValue("serviceAccountUser", config.getAdminUsername());
accessor.setPropertyValue("serviceAccountScopes", SERVICE_ACCOUNT_SCOPES);
return new Directory.Builder(httpTransport, jacksonFactory, credential)
.setApplicationName("Spinnaker-Fiat")
.build();
}