Features in CXF

A Feature in CXF is a way of adding capabilities to a Server, Client or Bus. For example, you could add the ability to log messages for each of these objects, by configuring them with a LoggingFeature. To implement a Feature, you must subclass AbstractFeature below. By default the initialize methods all delegate to initializeProvider(InterceptorProvider), so if you're simply adding interceptors to a Server, Client, or Bus, this allows you to add them easily.

Writing and configure the Feature

CXF provides several features to configure commonly used capabilities, such as logging, failover, policies, addressing, reliable messaging. You can go to the FeaturesList for more information.

Writing a Feature

It is very easy to write a new feature, your feature just need to extends the AbstractFeature and implement initializeProvider or write customizing code for configuring client or server interceptors. Here is an example for implementing the logging feature.

Adding a Feature programmatically

To add the feature to both server and client, you can use the Feature annotation on the service class

You can also add the feature to the server by using ServerFactoryBean, or the client by using the ClientFactoryBean

Adding a Feature through configuration

Here are some examples on using configuration files to add features. You can find more information about the CXF provides features at FeaturesList.