Search in sources :

Example 1 with ResourceRepositoryStubImpl

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);
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) ResourceRepositoryStubImpl(io.crnk.client.internal.ResourceRepositoryStubImpl) DefaultResourceList(io.crnk.core.resource.list.DefaultResourceList) ModuleRegistry(io.crnk.core.module.ModuleRegistry) ClientProxyFactoryContext(io.crnk.client.internal.proxy.ClientProxyFactoryContext)

Example 2 with ResourceRepositoryStubImpl

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;
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) ResourceRepositoryInformation(io.crnk.core.engine.information.repository.ResourceRepositoryInformation) DirectResponseResourceEntry(io.crnk.legacy.internal.DirectResponseResourceEntry) DirectResponseRelationshipEntry(io.crnk.legacy.internal.DirectResponseRelationshipEntry) ResourceField(io.crnk.core.engine.information.resource.ResourceField) ResourceRepositoryStubImpl(io.crnk.client.internal.ResourceRepositoryStubImpl) ResourceRepositoryInformationImpl(io.crnk.core.engine.internal.information.repository.ResourceRepositoryInformationImpl) DirectResponseResourceEntry(io.crnk.legacy.internal.DirectResponseResourceEntry) ResourceInformationProvider(io.crnk.core.engine.information.resource.ResourceInformationProvider) RepositoryInstanceBuilder(io.crnk.legacy.registry.RepositoryInstanceBuilder)

Example 3 with ResourceRepositoryStubImpl

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);
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) OffsetLimitPagingBehavior(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior) ResourceRepositoryStubImpl(io.crnk.client.internal.ResourceRepositoryStubImpl)

Aggregations

ResourceRepositoryStubImpl (io.crnk.client.internal.ResourceRepositoryStubImpl)3 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)3 ClientProxyFactoryContext (io.crnk.client.internal.proxy.ClientProxyFactoryContext)1 ResourceRepositoryInformation (io.crnk.core.engine.information.repository.ResourceRepositoryInformation)1 ResourceField (io.crnk.core.engine.information.resource.ResourceField)1 ResourceInformationProvider (io.crnk.core.engine.information.resource.ResourceInformationProvider)1 ResourceRepositoryInformationImpl (io.crnk.core.engine.internal.information.repository.ResourceRepositoryInformationImpl)1 ModuleRegistry (io.crnk.core.module.ModuleRegistry)1 OffsetLimitPagingBehavior (io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior)1 DefaultResourceList (io.crnk.core.resource.list.DefaultResourceList)1 DirectResponseRelationshipEntry (io.crnk.legacy.internal.DirectResponseRelationshipEntry)1 DirectResponseResourceEntry (io.crnk.legacy.internal.DirectResponseResourceEntry)1 RepositoryInstanceBuilder (io.crnk.legacy.registry.RepositoryInstanceBuilder)1