Versions Compared

Key

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

...

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

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(new ArrayList().addCollections.singletonList(myFeature));
...

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

ClientProxyFactoryBean clientFactoryBean = new ArrayListClientProxyFactoryBean().add(myFeature));
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

...