Oracle Logo

Interception Factory in CDI 2.0

 

Interception Factory Introduction

CDI 2.0 introduces the javax.enterprise.inject.spi.InterceptionFactory<T> interface, which allows to create a wrapper instance whose method invocations are intercepted by method interceptors and forwarded to a provided instance.

An InterceptionFactory can be obtained by calling BeanManager.createInterceptionFactory() as defined in Obtain an InterceptionFactory.

Description of the Example

This example demonstrates a producer method definition using InterceptionFactory. The produced bean instance will be a wrapper of MyGreetingImpl with single interceptor associated by HelloAdder. First please enter a name, then click the Submit button. A complete message including your input and the wrapped message will be displayed.

Use This Example