private static LayerAssembly createRuntimeLayer( ApplicationAssembly app ) { return app.layer( "runtime-layer" ); }
@Override public void assemble( ModuleAssembly module ) { module.layer().application().setName( name ); } }
protected void assembleApplication() { assembly.setName( name ); assembly.setVersion( version ); assembly.setMode( mode ); assembleLayers( assembly ); }
public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory ) throws AssemblyException { ApplicationAssembly appass = applicationFactory.newApplicationAssembly(); // END SNIPPET: bootstrap // Assemble your application here appass.setName( APP_NAME ); ModuleAssembly module = appass.layer( "Layer 1" ).module( "Module 1" ); module.transients( UselessComposite.class ); // START SNIPPET: bootstrap return appass; }
ApplicationDescriptor model = polygene.newApplicationModel( factory -> { ApplicationAssembly assembly = factory.newApplicationAssembly(); assembly.setName( applicationName ); if( applicationVersion != null ) assembly.setVersion( applicationVersion ); assembly.setMode( applicationMode ); assembly.setMetaInfo( metaInfo );
public void assemble( ModuleAssembly module ) throws AssemblyException { module.layer().application().setMode( Application.Mode.development ); } }.application().mode();
@Override public void assemble( ModuleAssembly module ) { super.assemble( module ); String applicationName = module.layer().application().name(); Preferences root = Preferences.userRoot(); Preferences node = root.node( applicationName ); PreferencesEntityStoreInfo info = new PreferencesEntityStoreInfo( node ); ServiceDeclaration service = module.services( PreferencesEntityStoreService.class ) .setMetaInfo( info ) .visibleIn( visibility() ) .instantiateOnStartup(); if( hasIdentity() ) { service.identifiedBy( identity() ); } } }
public static void main( String[] args ) throws Exception { // Create a Polygene Runtime polygene = new Energy4Java(); // Create the application application = polygene.newApplication( factory -> { ApplicationAssembly assembly = factory.newApplicationAssembly(); assembly.setMetaInfo( new DalvikAssemblyHelper() ); // END SNIPPET: customAssemblyHelper // START SNIPPET: customAssemblyHelper return assembly; } ); // Activate the application application.activate(); }
moduleAssembly -> { MigrationTest.this.assemble( moduleAssembly ); moduleAssembly.layer().application().setVersion( "1.0" ); moduleAssembly -> { MigrationTest.this.assemble( moduleAssembly ); moduleAssembly.layer().application().setVersion( "1.1" ); moduleAssembly -> { MigrationTest.this.assemble( moduleAssembly ); moduleAssembly.layer().application().setVersion( "2.0" ); moduleAssembly -> { MigrationTest.this.assemble( moduleAssembly ); moduleAssembly.layer().application().setVersion( "3.0" );
@Test public void testModel2XML() throws AssemblyException, TransformerException { Energy4Java polygene = new Energy4Java( ); ApplicationDescriptor model = polygene.newApplicationModel( factory -> { ApplicationAssembly assembly = factory.newApplicationAssembly(); assembly.setName( "Test application" ); LayerAssembly webLayer = assembly.layer( "Web" ); LayerAssembly domainLayer = assembly.layer( "Domain" ); LayerAssembly infrastructureLayer = assembly.layer( "Infrastructure" ); webLayer.uses( domainLayer, infrastructureLayer ); domainLayer.uses( infrastructureLayer ); ModuleAssembly rest = webLayer.module( "REST" ); rest.transients( TestTransient.class ).visibleIn( Visibility.layer ); domainLayer.module( "Domain" ); infrastructureLayer.module( "Database" ); return assembly; } ); Document document = new Model2XML().apply( model ); TransformerFactory transformerFactory = TransformerFactory.newInstance(); Transformer transformer = transformerFactory.newTransformer(); transformer.setOutputProperty( "indent", "yes" ); transformer.setOutputProperty( "{http://xml.apache.org/xslt}indent-amount", "2" ); transformer.transform( new DOMSource( document ), new StreamResult( System.out ) ); }
ApplicationDescriptor model = polygene.newApplicationModel( factory -> { ApplicationAssembly assembly = factory.newApplicationAssembly(); assembly.setName( applicationName ); if( applicationVersion != null ) assembly.setVersion( applicationVersion ); assembly.setMode( applicationMode ); assembly.setMetaInfo( metaInfo );
public void assemble( ModuleAssembly module ) throws AssemblyException { module.layer().application().setMode( Application.Mode.production ); } }.application().mode();
@Override public void assemble( ModuleAssembly module ) { super.assemble( module ); String applicationName = module.layer().application().name(); Preferences root = Preferences.userRoot(); Preferences node = root.node( applicationName ); PreferencesEntityStoreInfo info = new PreferencesEntityStoreInfo( node ); ServiceDeclaration service = module.services( PreferencesEntityStoreService.class ) .setMetaInfo( info ) .visibleIn( visibility() ) .instantiateOnStartup(); if( hasIdentity() ) { service.identifiedBy( identity() ); } } }
private static LayerAssembly createDesignerLayer( ApplicationAssembly app ) { return app.layer( "designer-layer" ); }
@Override protected final void defineApplication( ApplicationAssembly app ) { app.setName( "app" ); LayerAssembly domain = app.layer( "domain" ); ModuleAssembly model = domain.module( "model" ); model.entities( Person.class, PersonList.class ) .visibleIn( Visibility.layer ); ModuleAssembly services = domain.module( "services" ); services.services( Commands.class, Queries.class ) .instantiateOnStartup() .visibleIn( Visibility.application ); LayerAssembly config = app.layer( "config" ); ModuleAssembly configModule = config.module( "config" ); new EntityTestAssembler() .visibleIn( Visibility.module ) .assemble( configModule ); LayerAssembly infra = app.layer( "infra" ); ModuleAssembly storage = infra.module( "storage" ); entityStoreAssembler( configModule, Visibility.application ) .visibleIn( Visibility.application ) .assemble( storage ); metricsAssembler() .visibleIn( Visibility.application ) .assemble( infra.module( "metrics" ) ); domain.uses( infra ); infra.uses( config ); }
@Override public void assemble( ModuleAssembly module ) { module.layer().application().setName( name ); } }
protected void assembleApplication() { assembly.setName( name ); assembly.setVersion( version ); assembly.setMode( mode ); assembleLayers( assembly ); }
public void assemble( ModuleAssembly module ) throws AssemblyException { module.layer().application().setMode( Application.Mode.test ); } }.application().mode();
@Override protected void defineStorageModule( ModuleAssembly module ) { module.defaultServices(); String applicationName = module.layer().application().name(); rootNode = Preferences.userRoot().node( applicationName ); new PreferencesEntityStoreAssembler() .visibleIn( Visibility.application ) .assemble( module ); }
private static LayerAssembly createPersistenceLayer( ApplicationAssembly app ) { return app.layer( "persistence-layer" ); }