The Runtime Bootstrap API is how such bootstrapper code in the application will get everything going.
For instance if you just want to create an Application with one Layer and one Module in that Layer, you would do something like this;
// Create the Assembly for the Module.
Assembly assembly = ...;
// Obtain the ApplicationBuilderFactory.
ApplicationBuilderFactory factory =
is.getApplicationBuilderFactory();
// Create a helper.
ApplicationBuilderHelper helper = new ApplicationBuilderHelper( factory );
// Create the Application.
Application application = helper.newApplication( assembly );
// Create the Domain model
MyDomain domain = new MyDomainImpl( application );
domain.start();
Qi4j is = new Energy4Java();
Assembly[][][] assemblies = new Assembly[][][]
{
{ // View Layer
{ // Login Module
new MyAssembly( "login1" ),
new MyAssembly( "login2" )
},
{ // Main Workbench Module
new MyAssembly( "menus" ),
new MyAssembly( "contextmenus" ),
new MyAssembly( "perspectives" ),
new MyAssembly( "views" ),
new MyAssembly( "editors )
},
{ // Printing Module
new MyAssembly( "jasper" ),
new MyAssembly( "pdf" )
}
},
{ // Business Rules Layer
{ // Accounting Module
new MyAssembly( "bookkeeping" ),
new MyAssembly( "profitloss" ),
new MyAssembly( "cashflow" ),
new MyAssembly( "balancesheet" ),
new MyAssembly( "glue" )
},
{ // Inventory Module
new MyAssembly( "pricing" ),
new MyAssembly( "products" )
}
}
}
// Get the ApplicationBuilderFactory
ApplicationBuilderFactory factory =
is.getApplicationBuilderFactory();
// Create the helper
ApplicationBuilderHelper helper = new ApplicationBuilderHelper( factory );
// Create the Application instance.
Application application = helper.newApplication( assemblies );
// Use the the Application instance in the Domain Model.
ApplicationBuilder builder = sbf.newApplicationBuilder();
{
LayerBuilder applicationLayer = ab.newLayerBuilder();
{
{
ModuleBuilder mb = applicationLayer.newModuleBuilder();
mb.addAssembly( new ApplicationAssembly() );
}
}
LayerBuilder viewLayer = ab.newLayerBuilder();
{
{
ModuleBuilder mb = viewLayer.newModuleBuilder();
mb.addAssembly( new ViewAssembly() );
}
viewLayer.uses( applicationLayer );
}
}
Application application = builder.newApplication();