Package org.qi4j.api.structure

Examples of org.qi4j.api.structure.Application


{

    public static void main( String[] args )
            throws Exception
    {
        final Application application = new Energy4Java().newApplication( new AppAssembler() );
        application.activate();
        Runtime.getRuntime().addShutdownHook( new Thread( new Runnable()
        {
            @Override
            @SuppressWarnings( "CallToThreadDumpStack" )
            public void run()
            {
                try {
                    application.passivate();
                } catch ( Exception ex ) {
                    System.err.println( "Unable to passivate Qi4j application!" );
                    ex.printStackTrace();
                }
            }

        } ) );
        Module domainModule = application.findModule( "app", "domain" );

        int exitStatus = 0;

        try {

            UnitOfWork uow = domainModule.newUnitOfWork();
            EntityBuilder<PretextEntity> builder = uow.newEntityBuilder( PretextEntity.class );
            PretextEntity pretext = builder.instance();
            pretext.reason().set( "Testing purpose" );
            builder.newInstance();
            uow.complete();

            uow = domainModule.newUnitOfWork();
            QueryBuilder<PretextEntity> queryBuilder = domainModule.newQueryBuilder( PretextEntity.class );
            queryBuilder = queryBuilder.where( eq( templateFor( PretextEntity.class ).reason(), "Testing purpose" ) );
            Query<PretextEntity> query = uow.newQuery( queryBuilder );
            pretext = query.find();
            if ( pretext == null ) {
                System.err.println( "ERROR: Unable to find pretext!" );
                exitStatus = -1;
            } else {
                System.out.println( "SUCCESS: Found Pretext with reason: " + pretext.reason().get() );
            }
            uow.discard();

        } finally {
            deleteData( application.findModule( "infra", "persistence" ) );
        }

        System.exit( exitStatus );
    }
View Full Code Here


                  {
                      new AssemblerB()
                  }
                }
            };
        Application app = boot.newApplication( new ApplicationAssemblerAdapter( assemblers )
        {
        } );
        app.activate();
        ObjectA object = app.findModule( "Layer 1", "Module A" ).newObject( ObjectA.class );
        object.test();
    }
View Full Code Here

                    layer.initialize( createdLayers );
                }
                return assembly;
            }
        } );
        Application application = model.newInstance( qi4j.api() );
        for( ActivationEventListener activationListener : activationListeners )
        {
            application.registerActivationEventListener( activationListener );
        }
        beforeActivation();
        application.activate();
        afterActivation();
        return application;
    }
View Full Code Here

     */
    public static void main( String[] args )
        throws JSONException, ActivationException, AssemblyException
    {
        ApplicationBuilder builder = fromJson( System.in );
        Application application = builder.newApplication();
        Runtime.getRuntime().addShutdownHook( new ApplicationPassivationThread( application, System.err ) );
    }
View Full Code Here

                    instantiateOnStartup();
            }
        } );
        appBuilder.registerActivationEventListener( new TestActivationEventListener() );

        Application app = appBuilder.newApplication();

        try
        {
            Module moduleA = app.findModule( "Layer 1", "Module A" );
            TestService service = moduleA.findService( TestService.class ).get();
            assertThat( service.hello(), equalTo( "Hello Qi4j!" ) );
        }
        finally
        {
            try
            {
                app.passivate();
                fail( "No PassivationException" );
            }
            catch( PassivationException ex )
            {
                ex.printStackTrace();
View Full Code Here

    @Test
    public void canCreateAndQueryWithNativeRdfAndJdbm()
        throws Exception
    {
        Application application = createApplication( nativeRdf, jdbmStore, domain );
        try
        {
            application.activate();
            Module domain = application.findModule( "Domain", "Domain" );
            UnitOfWorkFactory unitOfWorkFactory = domain;
            createABunchOfStuffAndDoQueries( unitOfWorkFactory, domain );
        }
        finally
        {
            application.passivate();
        }
    }
View Full Code Here

    @Test
    public void canCreateAndQueryWithAllInMemory()
        throws Exception
    {
        Application application = createApplication( inMemoryRdf, inMemoryStore, domain );
        try
        {
            application.activate();
            Module domain = application.findModule( "Domain", "Domain" );
            UnitOfWorkFactory unitOfWorkFactory = domain;
            createABunchOfStuffAndDoQueries( unitOfWorkFactory, domain );
        }
        finally
        {
            application.passivate();
        }
    }
View Full Code Here

    @Test
    public void canCreateAndQueryWithNativeRdfWithInMemoryStore()
        throws Exception
    {
        Application application = createApplication( nativeRdf, inMemoryStore, domain );
        try
        {
            application.activate();
            Module domain = application.findModule( "Domain", "Domain" );
            UnitOfWorkFactory unitOfWorkFactory = domain;
            createABunchOfStuffAndDoQueries( unitOfWorkFactory, domain );
        }
        finally
        {
            application.passivate();
        }
    }
View Full Code Here

    @Test
    public void canCreateAndQueryWithInMemoryRdfWithJdbm()
        throws Exception
    {
        Application application = createApplication( inMemoryRdf, jdbmStore, domain );
        try
        {
            application.activate();

            Module domain = application.findModule( "Domain", "Domain" );
            UnitOfWorkFactory unitOfWorkFactory = domain;
            createABunchOfStuffAndDoQueries( unitOfWorkFactory, domain );
        }
        finally
        {
            application.passivate();
        }
    }
View Full Code Here

                                              final LayerAssemblyBuilder domainLayerBuilder
    )
        throws AssemblyException
    {
        Energy4Java qi4j = new Energy4Java();
        Application application = qi4j.newApplication( new ApplicationAssembler()
        {
            @Override
            public ApplicationAssembly assemble( ApplicationAssemblyFactory applicationFactory )
                throws AssemblyException
            {
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.