use of io.crnk.legacy.registry.AnnotatedResourceEntry in project crnk-framework by crnk-project.
the class DefaultRegistryEntryBuilder method buildResourceRepository.
@SuppressWarnings({ "rawtypes", "unchecked" })
private ResourceEntry buildResourceRepository(ResourceInformation resourceInformation) {
resourceRepository.information().setResourceInformation(resourceInformation);
ResourceRepositoryInformation repositoryInformation = resourceRepository.information().build();
Object instance = resourceRepository.instance;
final Object decoratedRepository = decorateRepository(instance);
RepositoryInstanceBuilder repositoryInstanceBuilder = new RepositoryInstanceBuilder(null, instance.getClass()) {
@Override
public Object buildRepository() {
return decoratedRepository;
}
};
if (ClassUtils.getAnnotation(decoratedRepository.getClass(), JsonApiResourceRepository.class).isPresent()) {
return new AnnotatedResourceEntry(repositoryInstanceBuilder, repositoryInformation);
} else {
return new DirectResponseResourceEntry(repositoryInstanceBuilder, repositoryInformation);
}
}
use of io.crnk.legacy.registry.AnnotatedResourceEntry in project crnk-framework by crnk-project.
the class RegistryEntry method getResourceRepository.
@SuppressWarnings("unchecked")
public ResourceRepositoryAdapter getResourceRepository(RepositoryMethodParameterProvider parameterProvider) {
Object repoInstance = null;
if (resourceEntry instanceof DirectResponseResourceEntry) {
repoInstance = ((DirectResponseResourceEntry) resourceEntry).getResourceRepository();
} else if (resourceEntry instanceof AnnotatedResourceEntry) {
repoInstance = ((AnnotatedResourceEntry) resourceEntry).build(parameterProvider);
}
if (repoInstance instanceof ResourceRegistryAware) {
((ResourceRegistryAware) repoInstance).setResourceRegistry(moduleRegistry.getResourceRegistry());
}
ResourceInformation resourceInformation = getResourceInformation();
return new ResourceRepositoryAdapter(resourceInformation, moduleRegistry, repoInstance);
}
Aggregations