use of org.qi4j.bootstrap.LayerAssembly in project qi4j-sdk by Qi4j.
the class ApplicationDocs method createAssembly.
private static ApplicationAssembly createAssembly(ApplicationAssemblyFactory factory) throws AssemblyException {
String applicationName = "Example Application";
ApplicationAssembly app = factory.newApplicationAssembly();
app.setName(applicationName);
LayerAssembly webLayer = createWebLayer(app);
LayerAssembly domainLayer = createDomainLayer(app);
LayerAssembly infraLayer = createInfrastructureLayer(app);
webLayer.uses(domainLayer);
// Accesses the WebService
webLayer.uses(infraLayer);
// For persistence
domainLayer.uses(infraLayer);
return app;
}
use of org.qi4j.bootstrap.LayerAssembly in project qi4j-sdk by Qi4j.
the class ApplicationDocs method createDomainLayer.
private static LayerAssembly createDomainLayer(ApplicationAssembly application) {
LayerAssembly layer = application.layer("Domain Layer");
createCustomerDomainModule(layer);
// :
return layer;
}
use of org.qi4j.bootstrap.LayerAssembly in project qi4j-sdk by Qi4j.
the class ApplicationDocs method createInfrastructureLayer.
private static LayerAssembly createInfrastructureLayer(ApplicationAssembly application) throws AssemblyException {
LayerAssembly layer = application.layer("Infrastructure Layer");
createWebServiceModule(layer);
createPersistenceModule(layer);
return layer;
}
use of org.qi4j.bootstrap.LayerAssembly in project qi4j-sdk by Qi4j.
the class ServiceInjectionTest method testInjectionServiceBetweenLayers.
@Test
public void testInjectionServiceBetweenLayers() throws ActivationException, AssemblyException {
SingletonAssembler assembly = new SingletonAssembler() {
public void assemble(ModuleAssembly module) throws AssemblyException {
module.services(MyServiceComposite.class).identifiedBy("Foo").setMetaInfo(new ServiceName("Foo"));
module.services(StringService.class, LongService.class);
LayerAssembly layerAssembly = module.layer();
module.objects(ServiceUser.class);
ApplicationAssembly applicationAssembly = layerAssembly.application();
LayerAssembly layer2Assembly = applicationAssembly.layer("Other layer");
layerAssembly.uses(layer2Assembly);
ModuleAssembly module2 = layer2Assembly.module("Other module");
ServiceDeclaration service2Decl = module2.services(MyServiceComposite2.class);
service2Decl.identifiedBy("Bar").setMetaInfo(new ServiceName("Bar")).visibleIn(application);
}
};
testInjection(assembly);
}
use of org.qi4j.bootstrap.LayerAssembly in project qi4j-sdk by Qi4j.
the class IssueTest method testLayersCanBeCreatedInOrderDifferentFromTheirDependency.
@Test
public void testLayersCanBeCreatedInOrderDifferentFromTheirDependency() throws AssemblyException {
Energy4Java qi4j = new Energy4Java();
Application app = qi4j.newApplication(new ApplicationAssembler() {
public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
ApplicationAssembly assembly = applicationFactory.newApplicationAssembly();
LayerAssembly domainLayer = assembly.layer(null);
domainLayer.setName("Domain");
LayerAssembly infrastructureLayer = assembly.layer(null);
infrastructureLayer.setName("Infrastructure");
domainLayer.uses(infrastructureLayer);
return assembly;
}
});
ApplicationDescriptor model = app.descriptor();
model.accept(new HierarchicalVisitorAdapter<Object, Object, RuntimeException>() {
@Override
public boolean visitEnter(Object visited) throws RuntimeException {
return visited instanceof ApplicationDescriptor;
}
@Override
public boolean visitLeave(Object visited) throws RuntimeException {
return visited instanceof LayerDescriptor;
}
@Override
public boolean visit(Object visited) throws RuntimeException {
if (visited instanceof LayerDescriptor) {
Iterable<? extends LayerDescriptor> usedLayers = ((LayerDescriptor) visited).usedLayers().layers();
for (LayerDescriptor usedLayerModel : usedLayers) {
Assert.assertNotNull("Used layer model is null", usedLayerModel);
}
}
return false;
}
});
}
Aggregations