Fuse Services Framework provides four Java annotations that allow a developer to specify the interceptor chains used by an endpoint. Unlike the other means of attaching interceptors to endpoints, the annotations are attached to application-level artifacts. The artifact that is used determines the scope of the annotation's effect.
The annotations can be placed on the following artifacts:
the service endpoint interface(SEI) defining the endpoint
If the annotations are placed on an SEI, all of the service providers that implement the interface and all of the consumers that use the SEI to create proxies will be affected.
a service implementation class
If the annotations are placed on an implementation class, all of the service providers using the implementation class will be affected.
The annotations are all in the org.apache.cxf.interceptor package and are described in Table 5.2.
Table 5.2. Interceptor chain annotations
The list of interceptors is specified as a list of fully qualified class names using the syntax shown in Example 5.7.
Example 5.7. Syntax for listing interceptors in a chain annotation
interceptors={"interceptor1
", "interceptor2
", ..., "interceptorN
"}
Example 5.8 shows annotations that attach two interceptors to
the inbound interceptor chain of endpoints that use the logic provided by
SayHiImpl
.
Example 5.8. Attaching interceptors to a service implementation
import org.apache.cxf.interceptor.InInterceptors;
@InInterceptors(interceptors={"com.sayhi.interceptors.FirstLast", "com.sayhi.interceptors.LogName"})
public class SayHiImpl implements SayHi
{
...
}