use of io.crnk.core.module.ModuleRegistry 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.core.module.ModuleRegistry in project crnk-framework by crnk-project.
the class RegistryEntryTest method newRepositoryInformation.
private <T> ResourceRepositoryInformation newRepositoryInformation(Class<T> repositoryClass, String path) {
ModuleRegistry moduleRegistry = new ModuleRegistry();
TypeParser typeParser = moduleRegistry.getTypeParser();
return new ResourceRepositoryInformationImpl(path, new ResourceInformation(typeParser, Task.class, path, null, null, null, null), RepositoryMethodAccess.ALL);
}
use of io.crnk.core.module.ModuleRegistry in project crnk-framework by crnk-project.
the class CdiRunner method run.
public void run(GeneratorTrigger context) throws IOException {
Weld weld = new Weld();
try {
weld.setClassLoader(context.getClassLoader());
weld.initialize();
CrnkBoot boot = new CrnkBoot();
boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://<generator>"));
boot.boot();
ModuleRegistry moduleRegistry = boot.getModuleRegistry();
Optional<MetaModule> optionalModule = moduleRegistry.getModule(MetaModule.class);
if (!optionalModule.isPresent()) {
throw new IllegalStateException("add MetaModule to CDI setup, got: " + moduleRegistry.getModules() + " with " + boot.getServiceDiscovery());
}
MetaModule metaModule = optionalModule.get();
MetaLookup lookup = metaModule.getLookup();
context.generate(lookup);
} finally {
weld.shutdown();
}
}
use of io.crnk.core.module.ModuleRegistry in project crnk-framework by crnk-project.
the class ResourceRegistryTest method resetResourceRegistry.
@Before
public void resetResourceRegistry() {
moduleRegistry = new ModuleRegistry();
moduleRegistry.getHttpRequestContextProvider().setServiceUrlProvider(new ConstantServiceUrlProvider(TEST_MODELS_URL));
resourceRegistry = new ResourceRegistryImpl(new DefaultResourceRegistryPart(), moduleRegistry);
}
use of io.crnk.core.module.ModuleRegistry in project crnk-framework by crnk-project.
the class QueryParamsAdapterTest method test.
@Test
public void test() {
ModuleRegistry moduleRegistry = new ModuleRegistry();
moduleRegistry.getHttpRequestContextProvider().setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
ResourceRegistry resourceRegistry = new ResourceRegistryImpl(new DefaultResourceRegistryPart(), moduleRegistry);
QueryParams params = new QueryParams();
DefaultResourceInformationProvider builder = new DefaultResourceInformationProvider(new NullPropertiesProvider(), new OffsetLimitPagingBehavior(), new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider());
builder.init(new DefaultResourceInformationProviderContext(builder, new DefaultInformationBuilder(moduleRegistry.getTypeParser()), moduleRegistry.getTypeParser(), new ObjectMapper()));
ResourceInformation info = builder.build(Task.class);
QueryParamsAdapter adapter = new QueryParamsAdapter(info, params, moduleRegistry);
Assert.assertEquals(Task.class, adapter.getResourceInformation().getResourceClass());
Assert.assertEquals(resourceRegistry, adapter.getResourceRegistry());
}
Aggregations