use of io.crnk.legacy.repository.annotations.JsonApiRelationshipRepository in project crnk-framework by crnk-project.
the class CrnkBoot method setupComponents.
private void setupComponents() {
// not that the provided default implementation here are added last and
// as a consequence,
// can be overriden by other modules, like the
// JaxrsResourceRepositoryInformationBuilder.
SimpleModule module = new SimpleModule("discovery") {
@Override
public void setupModule(ModuleContext context) {
this.addHttpRequestProcessor(new JsonApiRequestProcessor(context));
super.setupModule(context);
}
};
for (JsonApiExceptionMapper<?> exceptionMapper : getInstancesByType(JsonApiExceptionMapper.class)) {
module.addExceptionMapper(exceptionMapper);
}
for (DocumentFilter filter : getInstancesByType(DocumentFilter.class)) {
module.addFilter(filter);
}
for (Object repository : getInstancesByType(Repository.class)) {
module.addRepository(repository);
}
for (Object repository : serviceDiscovery.getInstancesByAnnotation(JsonApiResourceRepository.class)) {
JsonApiResourceRepository annotation = ClassUtils.getAnnotation(repository.getClass(), JsonApiResourceRepository.class).get();
Class<?> resourceClass = annotation.value();
module.addRepository(resourceClass, repository);
}
for (Object repository : serviceDiscovery.getInstancesByAnnotation(JsonApiRelationshipRepository.class)) {
JsonApiRelationshipRepository annotation = ClassUtils.getAnnotation(repository.getClass(), JsonApiRelationshipRepository.class).get();
module.addRepository(annotation.source(), annotation.target(), repository);
}
moduleRegistry.addModule(module);
moduleRegistry.addModule(new CoreModule());
}
Aggregations