Search in sources :

Example 1 with ValueAssembler

use of org.qi4j.library.rest.common.ValueAssembler in project qi4j-sdk by Qi4j.

the class ContinuousIntegrationTest method assemble.

@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
    // General setup of client and server
    new OrgJsonValueSerializationAssembler().assemble(module);
    new ClientAssembler().assemble(module);
    new ValueAssembler().assemble(module);
    new RestServerAssembler().assemble(module);
    module.objects(NullCommandResult.class);
    module.importedServices(CommandResult.class).importedBy(NEW_OBJECT);
    module.importedServices(MetadataService.class).importedBy(NEW_OBJECT);
    module.objects(MetadataService.class);
    // Test specific setup
    module.values(BuildSpec.class, BuildResult.class, ServerStatus.class, TagBuildCommand.class, RunBuildCommand.class);
    module.objects(RootRestlet.class, RootResource.class, RootContext.class);
}
Also used : RestServerAssembler(org.qi4j.library.rest.server.assembler.RestServerAssembler) ValueAssembler(org.qi4j.library.rest.common.ValueAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler) MetadataService(org.restlet.service.MetadataService) NullCommandResult(org.qi4j.library.rest.server.restlet.NullCommandResult) CommandResult(org.qi4j.library.rest.server.spi.CommandResult)

Example 2 with ValueAssembler

use of org.qi4j.library.rest.common.ValueAssembler in project qi4j-sdk by Qi4j.

the class ContextResourceClientFactoryTest method assemble.

@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
    // General setup of client and server
    new OrgJsonValueSerializationAssembler().assemble(module);
    new ClientAssembler().assemble(module);
    new ValueAssembler().assemble(module);
    new RestServerAssembler().assemble(module);
    module.objects(NullCommandResult.class);
    module.importedServices(CommandResult.class).importedBy(NEW_OBJECT);
    module.importedServices(MetadataService.class).importedBy(NEW_OBJECT);
    module.objects(MetadataService.class);
    // Test specific setup
    module.values(TestQuery.class, TestResult.class, TestCommand.class);
    module.forMixin(TestQuery.class).declareDefaults().abc().set("def");
    module.objects(RootRestlet.class, RootResource.class, RootContext.class, SubResource1.class, PagesResource.class);
    module.objects(DescribableContext.class);
    module.transients(TestComposite.class);
}
Also used : RestServerAssembler(org.qi4j.library.rest.server.assembler.RestServerAssembler) ValueAssembler(org.qi4j.library.rest.common.ValueAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler) MetadataService(org.restlet.service.MetadataService) NullCommandResult(org.qi4j.library.rest.server.restlet.NullCommandResult) CommandResult(org.qi4j.library.rest.server.spi.CommandResult)

Example 3 with ValueAssembler

use of org.qi4j.library.rest.common.ValueAssembler in project qi4j-sdk by Qi4j.

the class RssReaderTest method assemble.

@Override
public void assemble(ModuleAssembly module) throws AssemblyException {
    // General setup of client
    new OrgJsonValueSerializationAssembler().assemble(module);
    new ClientAssembler().assemble(module);
    new ValueAssembler().assemble(module);
}
Also used : ValueAssembler(org.qi4j.library.rest.common.ValueAssembler) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)

Example 4 with ValueAssembler

use of org.qi4j.library.rest.common.ValueAssembler in project qi4j-sdk by Qi4j.

the class ForumAssembler method assemble.

@Override
public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
    ApplicationAssembly assembly = applicationFactory.newApplicationAssembly();
    assembly.setName("Forum");
    LayerAssembly configuration = assembly.layer("Configuration");
    {
        ModuleAssembly configModule = configuration.module("Configuration");
        configModule.entities(NeoConfiguration.class).visibleIn(Visibility.application);
        configModule.services(MemoryEntityStoreService.class);
        configModule.services(UuidIdentityGeneratorService.class);
        new OrgJsonValueSerializationAssembler().assemble(configModule);
    }
    LayerAssembly infrastructure = assembly.layer("Infrastructure").uses(configuration);
    {
        ModuleAssembly entityStore = infrastructure.module("EntityStore");
        entityStore.services(FileConfigurationService.class);
        entityStore.services(NeoEntityStoreService.class).visibleIn(Visibility.application);
        entityStore.services(UuidIdentityGeneratorService.class).visibleIn(Visibility.application);
        new OrgJsonValueSerializationAssembler().visibleIn(Visibility.application).withValuesModuleFinder(new Function<Application, Module>() {

            @Override
            public Module map(Application app) {
                return app.findModule("REST", "Values");
            }
        }).assemble(entityStore);
    }
    LayerAssembly data = assembly.layer("Data").uses(infrastructure);
    {
        ModuleAssembly forum = data.module("Forum");
        for (Class<?> dataClass : filter(hasModifier(Modifier.INTERFACE), filter(isAssignableFrom(EntityComposite.class), ClassScanner.findClasses(User.class)))) {
            forum.entities(dataClass).visibleIn(Visibility.application);
        }
    }
    LayerAssembly context = assembly.layer("Context").uses(data);
    {
        ModuleAssembly contexts = context.module("Context");
        for (Class<?> contextClass : filter(not(hasModifier(Modifier.INTERFACE)), ClassScanner.findClasses(Context.class))) {
            if (contextClass.getName().contains("$")) {
                contexts.transients(contextClass).visibleIn(Visibility.application);
            } else {
                contexts.objects(contextClass).visibleIn(Visibility.application);
            }
        }
        for (Class<?> valueClass : filter(isAssignableFrom(ValueComposite.class), ClassScanner.findClasses(Context.class))) {
            contexts.values(valueClass).visibleIn(Visibility.application);
        }
        contexts.services(EventsService.class);
        context.module("Domain events").values(DomainEventValue.class, ParameterValue.class).visibleIn(Visibility.application);
    }
    LayerAssembly services = assembly.layer("Service").uses(data);
    {
        ModuleAssembly bootstrap = services.module("Bootstrap");
        bootstrap.services(BootstrapData.class).identifiedBy("bootstrap").instantiateOnStartup();
    }
    LayerAssembly rest = assembly.layer("REST").uses(context, data);
    {
        ModuleAssembly values = rest.module("Values");
        {
            new ValueAssembler().assemble(values);
        }
        ModuleAssembly transformation = rest.module("Transformation");
        {
            new RestServerAssembler().assemble(transformation);
            transformation.objects(RequestReaderDelegator.class, ResponseWriterDelegator.class).visibleIn(Visibility.layer);
            new OrgJsonValueSerializationAssembler().assemble(transformation);
        }
        ModuleAssembly resources = rest.module("Resources");
        for (Class<?> resourceClass : ClassScanner.findClasses(RootResource.class)) {
            resources.objects(resourceClass).visibleIn(Visibility.layer);
        }
        ModuleAssembly restlet = rest.module("Restlet");
        restlet.objects(ForumRestlet.class);
        restlet.importedServices(CommandResult.class).setMetaInfo(new DomainCommandResult());
        restlet.importedServices(MetadataService.class);
    }
    return assembly;
}
Also used : MemoryEntityStoreService(org.qi4j.entitystore.memory.MemoryEntityStoreService) UuidIdentityGeneratorService(org.qi4j.spi.uuid.UuidIdentityGeneratorService) RootResource(org.qi4j.samples.forum.rest.resource.RootResource) EntityComposite(org.qi4j.api.entity.EntityComposite) User(org.qi4j.samples.forum.data.entity.User) ResponseWriterDelegator(org.qi4j.library.rest.server.restlet.ResponseWriterDelegator) BootstrapData(org.qi4j.samples.forum.service.BootstrapData) ApplicationAssembly(org.qi4j.bootstrap.ApplicationAssembly) DomainCommandResult(org.qi4j.samples.forum.domainevent.DomainCommandResult) LayerAssembly(org.qi4j.bootstrap.LayerAssembly) MetadataService(org.restlet.service.MetadataService) ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) FileConfigurationService(org.qi4j.library.fileconfig.FileConfigurationService) RequestReaderDelegator(org.qi4j.library.rest.server.restlet.RequestReaderDelegator) RestServerAssembler(org.qi4j.library.rest.server.assembler.RestServerAssembler) Module(org.qi4j.api.structure.Module) ValueAssembler(org.qi4j.library.rest.common.ValueAssembler) Application(org.qi4j.api.structure.Application) EventsService(org.qi4j.samples.forum.context.EventsService) ForumRestlet(org.qi4j.samples.forum.rest.ForumRestlet) OrgJsonValueSerializationAssembler(org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)

Aggregations

ValueAssembler (org.qi4j.library.rest.common.ValueAssembler)4 OrgJsonValueSerializationAssembler (org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler)4 RestServerAssembler (org.qi4j.library.rest.server.assembler.RestServerAssembler)3 MetadataService (org.restlet.service.MetadataService)3 NullCommandResult (org.qi4j.library.rest.server.restlet.NullCommandResult)2 CommandResult (org.qi4j.library.rest.server.spi.CommandResult)2 EntityComposite (org.qi4j.api.entity.EntityComposite)1 Application (org.qi4j.api.structure.Application)1 Module (org.qi4j.api.structure.Module)1 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)1 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)1 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)1 MemoryEntityStoreService (org.qi4j.entitystore.memory.MemoryEntityStoreService)1 FileConfigurationService (org.qi4j.library.fileconfig.FileConfigurationService)1 RequestReaderDelegator (org.qi4j.library.rest.server.restlet.RequestReaderDelegator)1 ResponseWriterDelegator (org.qi4j.library.rest.server.restlet.ResponseWriterDelegator)1 EventsService (org.qi4j.samples.forum.context.EventsService)1 User (org.qi4j.samples.forum.data.entity.User)1 DomainCommandResult (org.qi4j.samples.forum.domainevent.DomainCommandResult)1 ForumRestlet (org.qi4j.samples.forum.rest.ForumRestlet)1