use of io.crnk.client.internal.ResourceRepositoryStubImpl in project crnk-framework by crnk-project.
the class CrnkClient method setProxyFactory.
public void setProxyFactory(ClientProxyFactory proxyFactory) {
proxyFactory.init(new ClientProxyFactoryContext() {
@Override
public ModuleRegistry getModuleRegistry() {
return moduleRegistry;
}
@Override
public <T> DefaultResourceList<T> getCollection(Class<T> resourceClass, String url) {
RegistryEntry entry = resourceRegistry.findEntry(resourceClass);
ResourceInformation resourceInformation = entry.getResourceInformation();
final ResourceRepositoryStubImpl<T, ?> repositoryStub = new ResourceRepositoryStubImpl<>(CrnkClient.this, resourceClass, resourceInformation, urlBuilder);
return repositoryStub.findAll(url);
}
});
documentMapper.setProxyFactory(proxyFactory);
}
use of io.crnk.client.internal.ResourceRepositoryStubImpl in project crnk-framework by crnk-project.
the class CrnkClient method allocateRepository.
@SuppressWarnings({ "rawtypes", "unchecked" })
private <T, I extends Serializable> RegistryEntry allocateRepository(Class<T> resourceClass) {
ResourceInformationProvider resourceInformationProvider = moduleRegistry.getResourceInformationBuilder();
ResourceInformation resourceInformation = resourceInformationProvider.build(resourceClass);
final ResourceRepositoryStub<T, I> repositoryStub = new ResourceRepositoryStubImpl<>(this, resourceClass, resourceInformation, urlBuilder);
// create interface for it!
RepositoryInstanceBuilder repositoryInstanceBuilder = new RepositoryInstanceBuilder(null, null) {
@Override
public Object buildRepository() {
return repositoryStub;
}
};
ResourceRepositoryInformation repositoryInformation = new ResourceRepositoryInformationImpl(resourceInformation.getResourceType(), resourceInformation, RepositoryMethodAccess.ALL);
ResourceEntry resourceEntry = new DirectResponseResourceEntry(repositoryInstanceBuilder, repositoryInformation);
Map<ResourceField, ResponseRelationshipEntry> relationshipEntries = new HashMap<>();
RegistryEntry registryEntry = new RegistryEntry(resourceEntry, relationshipEntries);
registryEntry.initialize(moduleRegistry);
resourceRegistry.addEntry(resourceClass, registryEntry);
allocateRepositoryRelations(registryEntry);
return registryEntry;
}
use of io.crnk.client.internal.ResourceRepositoryStubImpl in project crnk-framework by crnk-project.
the class CrnkClient method getRepositoryForPath.
/**
* Generic access using {@link Resource} class without type mapping.
*/
public ResourceRepositoryV2<Resource, String> getRepositoryForPath(String resourceType) {
init();
ResourceInformation resourceInformation = new ResourceInformation(moduleRegistry.getTypeParser(), Resource.class, resourceType, null, null, new OffsetLimitPagingBehavior());
return new ResourceRepositoryStubImpl<>(this, Resource.class, resourceInformation, urlBuilder);
}
Aggregations