Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
java
java
import org.apache.cxf.frontend.ServerFactoryBean;
import org.apache.cxf.frontend.ClientFactoryBean;
import org.apache.cxf.frontend.ClientProxyFactoryBean;
...
ServerFactoryBean serverFactoryBean = new ServerFactoryBean();
MyFeature myFeature = new MyFeature();
// added my feature to the serverFactoryBean
serverFactoryBean.setFeatures(Collections.singletonList(myFeature));
...

ClientFactoryBean clientFactoryBean = new ClientFactoryBean();
clientFactoryBean.setFeatures(Collections.singletonList(myFeature));
...

ClientProxyFactoryBean clientFactoryBean = new ClientProxyFactoryBean();
clientFactoryBean.setFeatures(Collections.singletonList(policyFeature)); 

It is also possible to add a feature when publishing an Endpoint via Endpoint.publish. For example, the Logging feature can be added as follows:

Code Block
languagejava
titleEndpoint.publish
import javax.xml.ws.Endpoint;
import org.apache.cxf.ext.logging.LoggingFeature;
...
CustomerService implementor = new CustomerServiceImpl();
Endpoint.publish("http://localhost:9090/CustomerServicePort",
                 implementor,
                 new LoggingFeature());

 

Adding a Feature through configuration

...