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();
}
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");
}
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);
}
}
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);
}
}
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;
}
Aggregations