private Application createApplicationInstance() { return polygene.newApplication( applicationFactory -> applicationFactory.newApplicationAssembly( SingletonAssembler.this ) ); }
private Application createApplicationInstance() { return polygene.newApplication( applicationFactory -> applicationFactory.newApplicationAssembly( SingletonAssembler.this ) ); }
public static void main(String[] args) throws Exception { Energy4Java polygene = new Energy4Java(); // Instantiate the Application Model. Application application = polygene.newApplication( factory -> factory.newApplicationAssembly( new MyAssembler()) ); application.activate(); } }
private Application createApplication() { Energy4Java polygene = new Energy4Java(); try { return polygene.newApplication( factory -> { ApplicationAssembly applicationAssembly = factory.newApplicationAssembly(); applicationBootstrap.assemble( applicationAssembly ); return applicationAssembly; } ); } catch ( AssemblyException e ) { throw new BeanInitializationException( "Fail to bootstrap Polygene application.", e ); } }
public Main() throws Exception { Energy4Java polygene = new Energy4Java(); application = polygene.newApplication( new MainAssembler() ); application.activate(); }
public static void main( String[] args ) throws Exception { // Create a Polygene Runtime polygene = new Energy4Java(); // Create the application application = polygene.newApplication( factory -> buildAssembly( factory.newApplicationAssembly() ) ); // Activate the application application.activate(); }
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(); }
public Application givenFixture1() throws AssemblyException { Energy4Java polygene = new Energy4Java(); return polygene.newApplication( factory -> factory.newApplicationAssembly( new Assembler[][][] { { { module -> module.transients( TestComposite1.class ) }, { module -> module.transients( TestComposite2.class ).visibleIn( Visibility.layer ) } } } ) ); }
public static void main( String[] args ) throws Exception { Energy4Java polygene = new Energy4Java( ); Server server = new Server( Protocol.HTTP, 8888 ); Application app = polygene.newApplication( new ForumAssembler(), new MetadataService() ); app.activate(); ContextRestlet restlet = app.findModule( "REST", "Restlet" ).newObject( ContextRestlet.class, new org.restlet.Context() ); ChallengeAuthenticator guard = new ChallengeAuthenticator(null, ChallengeScheme.HTTP_BASIC, "testRealm"); MapVerifier mapVerifier = new MapVerifier(); mapVerifier.getLocalSecrets().put("rickard", "secret".toCharArray()); guard.setVerifier(mapVerifier); guard.setNext(restlet); server.setNext( restlet ); server.start(); } }
public static void main( String[] args ) throws Exception { // Bootstrap Polygene Runtime // Create a Polygene Runtime polygene = new Energy4Java(); // Instantiate the Application Model. application = polygene.newApplication( factory -> { ApplicationAssembly assembly = factory.newApplicationAssembly(); LayerAssembly runtime = createRuntimeLayer( assembly ); LayerAssembly designer = createDesignerLayer( assembly ); LayerAssembly domain = createDomainLayer( assembly ); LayerAssembly messaging = createMessagingLayer( assembly ); LayerAssembly persistence = createPersistenceLayer( assembly ); // declare structure between layers domain.uses( messaging ); domain.uses( persistence ); designer.uses( persistence ); designer.uses( domain ); runtime.uses( domain ); return assembly; } ); // We need to handle shutdown. installShutdownHook(); // Activate the Application Runtime. application.activate(); }
@Test( expected = NoSuchTransientTypeException.class ) public void testPrivateCompositeVisibility() throws Exception { Energy4Java polygene = new Energy4Java(); Assembler[][][] assemblers = new Assembler[][][] { { // Layer { new AssemblerA() }, { new AssemblerB() } } }; Application app = polygene.newApplication( new ApplicationAssemblerAdapter( assemblers ) { } ); app.activate(); ObjectA object = app.findModule( "Layer 1", "Module A" ).newObject( ObjectA.class ); object.test(); }
private Application createApplication( final ModuleAssemblyBuilder queryServiceModuleBuilder, final ModuleAssemblyBuilder entityStoreModuleBuilder, final LayerAssemblyBuilder domainLayerBuilder ) throws AssemblyException { Energy4Java polygene = new Energy4Java(); Application application = polygene.newApplication( factory -> { ApplicationAssembly applicationAssembly = factory.newApplicationAssembly(); LayerAssembly configLayer = applicationAssembly.layer( "Config" ); configModule.buildModuleAssembly( configLayer, "Configuration" ); LayerAssembly infrastructureLayer = applicationAssembly.layer( "Infrastructure" ); infrastructureLayer.uses( configLayer ); queryServiceModuleBuilder.buildModuleAssembly( infrastructureLayer, "Query Service" ); entityStoreModuleBuilder.buildModuleAssembly( infrastructureLayer, "Entity Store" ); LayerAssembly domainLayer = domainLayerBuilder.buildLayerAssembly( applicationAssembly ); domainLayer.uses( infrastructureLayer ); return applicationAssembly; } ); return application; }
app = polygene.newApplication( new ApplicationAssemblerAdapter( assemblers )
@Test public void createApplicationUsingApplicationAssembly() throws AssemblyException { Energy4Java polygene = new Energy4Java(); polygene.newApplication( factory -> { ApplicationAssembly applicationAssembly = factory.newApplicationAssembly(); // Application Layer LayerAssembly applicationLayer = applicationAssembly.layer( "Application" ); ModuleAssembly applicationModule = applicationLayer.module( "Application" ); new DomainApplicationAssembler().assemble( applicationModule ); // View Layer LayerAssembly viewLayer = applicationAssembly.layer( "View" ); ModuleAssembly viewModule = viewLayer.module( "View" ); new ViewAssembler().assemble( viewModule ); viewLayer.uses( applicationLayer ); return applicationAssembly; } ); }
@Test public void testMixinInModuleIsVisible() throws Exception { Energy4Java polygene = new Energy4Java(); Assembler[][][] assemblers = new Assembler[][][] { { // Layer { // Module 1 module -> { module.setName( "Module A" ); module.transients( B1Composite.class ); module.objects( ObjectA.class ); } } } }; Application app = polygene.newApplication( new ApplicationAssemblerAdapter( assemblers ) { } ); app.activate(); ObjectA object = app.findModule( "Layer 1", "Module A" ).newObject( ObjectA.class ); assertEquals( "ok", object.test1() ); assertEquals( "abc", object.test2() ); }
@Test( expected = AmbiguousTypeException.class ) public void testMultipleMixinsInModuleWillFail() throws Exception { Energy4Java polygene = new Energy4Java(); Assembler[][][] assemblers = new Assembler[][][] { { // Layer { // Module 1 module -> { module.setName( "Module A" ); module.transients( B1Composite.class, B2Composite.class ); module.objects( ObjectA.class ); } } } }; Application app = polygene.newApplication( new ApplicationAssemblerAdapter( assemblers ) { } ); app.activate(); ObjectA object = app.findModule( "Layer 1", "Module A" ).newObject( ObjectA.class ); assertEquals( "ok", object.test1() ); assertEquals( "abc", object.test2() ); }
private Application createApplication() throws AssemblyException { Energy4Java polygene = new Energy4Java(); return polygene.newApplication( appFactory -> { ApplicationAssembly appAssembly = appFactory.newApplicationAssembly(); LayerAssembly layer1 = appAssembly.layer( "layer1" ); ModuleAssembly myModule = layer1.module( "My Module" ); ModuleAssembly yourModule = layer1.module( "Your Module" ); ModuleAssembly infraModule = layer1.module( "Infra Module" ); myModule.services( MyService.class ); myModule.entities( MyEntity.class ); yourModule.entities( YourEntity.class ); yourModule.services( YourService.class ).visibleIn( Visibility.layer ); new EntityTestAssembler().visibleIn( Visibility.layer ).assemble( infraModule ); return appAssembly; } ); } }
@Test( expected = NoSuchTransientTypeException.class ) public void testMixinInLayerIsNotVisible() throws Exception { Energy4Java polygene = new Energy4Java(); Assembler[][][] assemblers = new Assembler[][][] { { // Layer { module -> { module.setName( "Module A" ); module.objects( ObjectA.class ); } }, { module -> { module.setName( "Module B" ); module.transients( B1Composite.class ); } } } }; Application app = polygene.newApplication( new ApplicationAssemblerAdapter( assemblers ) { } ); app.activate(); ObjectA object = app.findModule( "Layer 1", "Module A" ).newObject( ObjectA.class ); assertEquals( "ok", object.test1() ); assertEquals( "abc", object.test2() ); }
Application app = polygene.newApplication( new ApplicationAssemblerAdapter( assemblers )
Application app = polygene.newApplication( new ApplicationAssemblerAdapter( assemblers )