UsingCDIWithMVEL
Sebastian Hoß edited this page Oct 3, 2013
·
3 revisions
To use CDI together with MVEL, declare the following dependencies
<dependencies>
<dependency>
<groupId>com.github.sebhoss.contract</groupId>
<artifactId>contract-cdi</artifactId>
<version>${contracts-version}</version>
</dependency>
<dependency>
<groupId>com.github.sebhoss.contract</groupId>
<artifactId>contract-mvel</artifactId>
<version>${contracts-version}</version>
</dependency>
</dependencies>
then expose the provided @MVEL ContractContextFactory
as the @Default ContractContextFactory
import javax.enterprise.inject.Default; import javax.enterprise.inject.Produces;
import com.github.sebhoss.contract.annotation.MVEL; import com.github.sebhoss.contract.verifier.ContractContextFactory;
class ContractContextFactoryProducer {
@Produces @Default ContractContextFactory contextFactory(final @MVEL ContractContextFactory mvelFactory) { return mvelFactory; }
}
and annotate your business methods as usual using MVEL. Consult the example project for more details.