code
docs
tests
Zest™ supports that Spring Application Context is imported into the Zest™ runtime, and the declared Spring beans will be available as Zest™ services. The most important things to remember are;
new SpringImporterAssembler( appContext ).assemble( module );
It is also possible to run a Zest™ Application as a Spring Bean and export its Services to Spring.
Steps to export Zest™ service:
To bootstrap the Zest™ runtime in Spring, you should have a bootstrap bean that extends the
org.qi4j.library.spring.bootstrap.Qi4jApplicationBootstrap
and implement the
org.springframework.context.ApplicationContextAware
.
A new bean will appear in the application context, called "qi4jApplication"
which is only
intended for internal use of this library.
Example application context;
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:qi4j="http://www.qi4j.org/schema/qi4j/spring" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.qi4j.org/schema/qi4j/spring http://www.qi4j.org/schema/qi4j/spring/spring-0.5.xsd"> <!-- class that implements Qi4jApplicationBootstrap --> <qi4j:bootstrap class="org.hedhman.niclas.MyZestBootstrapper"/> <bean id="someService" class="org.hedhman.niclas.SomeService"> <constructor-arg ref="someService"/> <!-- Reference qi4j comment service --> </bean>
public class MyZestBootstrapper extends Qi4jApplicationBootstrap implements ApplicationContextAware { private ApplicationContext applicationContext; @Override public void assemble(ApplicationAssembly assembly) throws AssemblyException { // Normal assembly of an application. [...snip...] } @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; } }