Search in sources :

Example 31 with Energy4Java

use of org.qi4j.bootstrap.Energy4Java in project qi4j-sdk by Qi4j.

the class AbstractQi4jBaseTest method setUp.

@Before
public void setUp() throws Exception {
    qi4j = new Energy4Java();
    applicationModel = newApplication();
    if (applicationModel == null) {
        // An AssemblyException has occurred that the Test wants to check for.
        return;
    }
    application = newApplicationInstance(applicationModel);
    initApplication(application);
    api = spi = qi4j.spi();
    application.activate();
}
Also used : Energy4Java(org.qi4j.bootstrap.Energy4Java) Before(org.junit.Before)

Example 32 with Energy4Java

use of org.qi4j.bootstrap.Energy4Java in project qi4j-sdk by Qi4j.

the class AbstractQi4jScenarioTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    qi4j = new Energy4Java();
    applicationModel = newApplication();
    if (applicationModel == null) {
        // An AssemblyException has occurred that the Test wants to check for.
        return;
    }
    application = applicationModel.newInstance(qi4j.spi());
    initApplication(application);
    api = spi = qi4j.spi();
    application.activate();
    // Assume only one module
    module = application.findModule("Layer 1", "Module 1");
}
Also used : Energy4Java(org.qi4j.bootstrap.Energy4Java) BeforeClass(org.junit.BeforeClass)

Example 33 with Energy4Java

use of org.qi4j.bootstrap.Energy4Java in project qi4j-sdk by Qi4j.

the class WicketQi4jApplication method startQi4j.

private void startQi4j() {
    try {
        logger.info("Starting Qi4j application");
        Energy4Java qi4j = new Energy4Java();
        qi4jApp = qi4j.newApplication(getAssembler());
        qi4jApp.activate();
        qi4jModule = qi4jApp.findModule(defaultLayerName(), defaultModuleName());
        // Qi4j injects @Structure and @Service elements into this application instance
        //qi4jModule.newObject( WicketQi4jApplication.class );
        qi4jModule.injectTo(this);
        logger.info("Started Qi4j application");
    } catch (Exception e) {
        logger.error("Could not start Qi4j application.");
        e.printStackTrace();
        System.exit(100);
    }
}
Also used : Energy4Java(org.qi4j.bootstrap.Energy4Java) ConcurrentEntityModificationException(org.qi4j.api.unitofwork.ConcurrentEntityModificationException) UnitOfWorkCompletionException(org.qi4j.api.unitofwork.UnitOfWorkCompletionException)

Example 34 with Energy4Java

use of org.qi4j.bootstrap.Energy4Java in project qi4j-sdk by Qi4j.

the class AbstractQi4jServletBootstrap method contextInitialized.

@Override
public final void contextInitialized(ServletContextEvent sce) {
    try {
        ServletContext context = sce.getServletContext();
        LOGGER.trace("Assembling Application");
        qi4j = new Energy4Java();
        applicationModel = qi4j.newApplicationModel(this);
        LOGGER.trace("Instanciating and activating Application");
        application = applicationModel.newInstance(qi4j.api());
        api = qi4j.api();
        beforeApplicationActivation(application);
        application.activate();
        afterApplicationActivation(application);
        LOGGER.trace("Storing Application in ServletContext");
        context.setAttribute(Qi4jServletSupport.APP_IN_CTX, application);
    } catch (Exception ex) {
        if (application != null) {
            try {
                beforeApplicationPassivation(application);
                application.passivate();
                afterApplicationPassivation(application);
            } catch (Exception ex1) {
                LOGGER.warn("Application not null and could not passivate it.", ex1);
            }
        }
        throw new InvalidApplicationException("Unexpected error during ServletContext initialization, see previous log for errors.", ex);
    }
}
Also used : ServletContext(javax.servlet.ServletContext) Energy4Java(org.qi4j.bootstrap.Energy4Java) InvalidApplicationException(org.qi4j.api.common.InvalidApplicationException) InvalidApplicationException(org.qi4j.api.common.InvalidApplicationException)

Example 35 with Energy4Java

use of org.qi4j.bootstrap.Energy4Java in project qi4j-sdk by Qi4j.

the class Qi4jApplicationBootstrapListener method createNewApplication.

private Application createNewApplication(ServletContext context) {
    Energy4Java qi4j = new Energy4Java();
    // Try create assembler
    final ApplicationAssembler assembler = createAssembler();
    if (assembler != null) {
        try {
            return qi4j.newApplication(assembler);
        } catch (AssemblyException e) {
            throw new IllegalStateException(e);
        }
    }
    return null;
}
Also used : AssemblyException(org.qi4j.bootstrap.AssemblyException) ApplicationAssembler(org.qi4j.bootstrap.ApplicationAssembler) Energy4Java(org.qi4j.bootstrap.Energy4Java)

Aggregations

Energy4Java (org.qi4j.bootstrap.Energy4Java)39 Assembler (org.qi4j.bootstrap.Assembler)19 Application (org.qi4j.api.structure.Application)18 ApplicationAssemblerAdapter (org.qi4j.bootstrap.ApplicationAssemblerAdapter)17 Test (org.junit.Test)15 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)12 ApplicationAssembler (org.qi4j.bootstrap.ApplicationAssembler)11 ApplicationDescriptor (org.qi4j.api.structure.ApplicationDescriptor)8 AssemblyException (org.qi4j.bootstrap.AssemblyException)8 Before (org.junit.Before)7 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)7 ApplicationAssemblyFactory (org.qi4j.bootstrap.ApplicationAssemblyFactory)7 Module (org.qi4j.api.structure.Module)6 EntityTestAssembler (org.qi4j.test.EntityTestAssembler)6 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)4 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)3 Envisage (org.qi4j.envisage.Envisage)3 UnitOfWorkCompletionException (org.qi4j.api.unitofwork.UnitOfWorkCompletionException)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1