Package org.qi4j.api.structure

Examples of org.qi4j.api.structure.Application


            {
                application.registerActivationEventListener( new EventsRecorder( events ) );
            }

        };
        Application application = assembler.application();
        application.passivate();

        Iterator<ActivationEvent> it = events.iterator();

        // Activation
        assertEvent( it.next(), ACTIVATING, "Application" );
        assertEvent( it.next(), ACTIVATING, "Layer" );
        assertEvent( it.next(), ACTIVATING, "Module" );
        // Lazy Service NOT activated
        assertEvent( it.next(), ACTIVATED, "Module" );
        assertEvent( it.next(), ACTIVATED, "Layer" );
        assertEvent( it.next(), ACTIVATED, "Application" );

        // Passivation
        assertEvent( it.next(), PASSIVATING, "Application" );
        assertEvent( it.next(), PASSIVATING, "Layer" );
        assertEvent( it.next(), PASSIVATING, "Module" );
        // Lazy Service NOT passivated
        assertEvent( it.next(), PASSIVATED, "Module" );
        assertEvent( it.next(), PASSIVATED, "Layer" );
        assertEvent( it.next(), PASSIVATED, "Application" );

        assertFalse( it.hasNext() );

        events.clear();
        application.activate();
        Module module = assembler.module();
        module.findService( TestService.class ).get().test();
        application.passivate();

        for( ActivationEvent event : events ) {
            System.out.println( event );
        }
View Full Code Here


    {

        Energy4Java qi4j = new Energy4Java();

        // Instantiate the Application Model.
        Application application = qi4j.newApplication( new ApplicationAssembler()
        {
            @Override
            public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException
            {
                return applicationFactory.newApplicationAssembly( new MyAssembler()) ;
            }
        });

        application.activate();

    }
View Full Code Here

    {
        Energy4Java is = new Energy4Java(  );

        Server server = new Server( Protocol.HTTP, 8888 );

        Application app = is.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);
View Full Code Here

    @Ignore( "Must fix the TODOs below. This example relied on ability to set Service MetaInfo at runtime, it seems it's not possible anymore." )
    public void testPlugins()
        throws Exception
    {
        Energy4Java runtime = new Energy4Java();
        Application app = runtime.newApplication( new MainApplicationAssembler() );
        app.activate();
    }
View Full Code Here

                        accountsDomainAssembler,
                      }
                    }
                };
            Energy4Java qi4j = new Energy4Java();
            Application app = qi4j.newApplication( new ApplicationAssembler()
            {

                @Override
                public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
                    throws AssemblyException
                {
                    return applicationFactory.newApplicationAssembly( assemblers );
                }
            } );
            app.activate();
// END SNIPPET: application2
        }
    }
View Full Code Here

                throws AssemblyException
            {
                return createAssembly( applicationFactory );
            }
        } );
        Application application = model.newInstance( qi4j.spi() );
    }
View Full Code Here

    // TODO Move to SPI !
    // TODO Include in each ValueSerialization extensions documentation
    public void assembledWithValuesModuleSerialization()
        throws Exception
    {
        Application app = new Energy4Java().newApplication( new ApplicationAssembler()
        {
            @Override
            public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
                throws AssemblyException
            {
                Assembler[][][] pancakes = new Assembler[][][]
                {
                    {
                        {
                            new Assembler()
                            {
                                @Override
                                public void assemble( ModuleAssembly valuesModule )
                                    throws AssemblyException
                                {
                                    valuesModule.layer().setName( "SINGLE-Layer" );
                                    valuesModule.setName( "VALUES-Module" );

                                    valuesModule.values( SomeValue.class );
                                }
                            }
                        },
                        {
                            new Assembler()
                            {
                                @Override
                                public void assemble( ModuleAssembly servicesModule )
                                    throws AssemblyException
                                {
                                    servicesModule.setName( "SERVICES-Module" );

                                    Function<Application, Module> valuesModuleFinder = new Function<Application, Module>()
                                    {
                                        @Override
                                        public Module map( Application app )
                                        {
                                            return app.findModule( "SINGLE-Layer", "VALUES-Module" );
                                        }
                                    };
                                    new OrgJsonValueSerializationAssembler().
                                        withValuesModuleFinder( valuesModuleFinder ).
                                        assemble( servicesModule );
                                }
                            }
                        }
                    }
                };
                return applicationFactory.newApplicationAssembly( pancakes );
            }
        } );
        app.activate();
        try
        {
            Module valuesModule = app.findModule( "SINGLE-Layer", "VALUES-Module" );
            SomeValue someValue = someNewValueInstance( valuesModule );

            Module servicesModule = app.findModule( "SINGLE-Layer", "SERVICES-Module" );
            ValueSerialization valueSerialization = servicesModule.findService( ValueSerialization.class ).get();

            String json = valueSerialization.serialize( someValue );
            assertThat( json, equalTo( "{\"foo\":\"bar\"}" ) );

            SomeValue someNewValue = valueSerialization.deserialize( SomeValue.class, json );
            assertThat( someNewValue, equalTo( someValue ) );
        }
        finally
        {
            app.passivate();
        }
    }
View Full Code Here

                module.withActivators( TestedActivator.class );
            }

        };
        // Activate
        Application application = assembly.application();

        // Assert activated
        Assert.assertEquals( "Activation Level", 2, activationLevel );

        // Passivate
        application.passivate();

        // Assert passivated
        Assert.assertEquals( "Passivation Level", 2, passivationLevel );
    }
View Full Code Here

        throws Exception
    {
        System.setProperty( "qi4j.compacttrace", "off" );

        Energy4Java is = new Energy4Java();
        Application app = is.newApplication( new ApplicationAssembler()
        {
            public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
                throws AssemblyException
            {
                return applicationFactory.newApplicationAssembly( new Assembler[][][]{
                    {
                        {
                            new Assembler()
                            {
                                public void assemble( ModuleAssembly module )
                                    throws AssemblyException
                                {
                                    module.objects( PrivateEntityUnitOfWorkTest.class );
                                }
                            }
                        }
                    },
                    {
                        {
                            new Assembler()
                            {
                                public void assemble( ModuleAssembly module )
                                    throws AssemblyException
                                {
                                    module.entities( ProductEntity.class );
                                    module.entities( ProductCatalogEntity.class ).visibleIn( application );
                                    module.values( ProductInfo.class );
                                    new EntityTestAssembler().assemble( module );
                                }
                            }
                        }
                    }
                } );
            }
        } );
        app.activate();

        Module module = app.findModule( "Layer 1", "Module 1" );
        module.injectTo( this );

        UnitOfWork unitOfWork = uowf.newUnitOfWork();

        try
View Full Code Here

                module.layer().withActivators( TestedActivator.class );
            }

        };
        // Activate
        Application application = assembly.application();

        // Assert activated
        Assert.assertEquals( "Activation Level", 2, activationLevel );

        // Passivate
        application.passivate();

        // Assert passivated
        Assert.assertEquals( "Passivation Level", 2, passivationLevel );
    }
View Full Code Here

TOP

Related Classes of org.qi4j.api.structure.Application

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.