Skip to content
Sebastian Hoß edited this page Oct 3, 2013 · 3 revisions

To use CDI together with UEL, 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-uel</artifactId>
    <version>${contracts-version}</version>
  </dependency>
</dependencies>

then expose the provided @UEL ContractContextFactory as the @Default ContractContextFactory

import javax.enterprise.inject.Default;
import javax.enterprise.inject.Produces;

import com.github.sebhoss.contract.annotation.UEL;
import com.github.sebhoss.contract.verifier.ContractContextFactory;

class ContractContextFactoryProducer {

    @Produces
    @Default
    ContractContextFactory contextFactory(final @UEL ContractContextFactory uelFactory) {
        return uelFactory;
    }

}

and annotate your business methods as usual using unified expression language. Consult the example project for more details.