Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
CXF provides several custom annotations that can be used to configure and customize the CXF runtime.

...



h3. org.apache.cxf.feature.Features

...


The @Features annotation is used to add [Features].   See the [FeaturesList] for the list of Features we provide "out of the box", but you can easily create your own.   In many cases, however, those features have Annotations themselves which can be used and provide greater control over configuration.

...



h3. org.apache.cxf.interceptor.InInterceptors,

...

 \\ org.apache.cxf.interceptor.OutInterceptors,

...

 \\ org.apache.cxf.interceptor.OutFaultInterceptors,

...

 \\ org.apache.cxf.interceptor.InFaultInterceptors

...


Add interceptors to the various chains used to process messages.  See [Interceptors] for more detail.

...




h3. org.apache.cxf.annotations.WSDLDocumentation

...

 \\ org.apache.cxf.annotations.WSDLDocumentationCollection  (since 2.3)

...


For "java first" scenarios where the WSDL is derived from the Java interfaces/code, these annotations allow adding wsd:documentation elements to various locations in the generated wsdl.

...

  

For example:

...


{code
:java
java
}
@WebService
@WSDLDocumentationCollection(
    {
        @WSDLDocumentation("My portType documentation"),
        @WSDLDocumentation(value = "My top level documentation",
                           placement = WSDLDocumentation.Placement.TOP),
        @WSDLDocumentation(value = "My binding doc",
                           placement = WSDLDocumentation.Placement.BINDING)
    }
)
public interface MyService {

    @WSDLDocumentation("The docs for echoString")
    String echoString(String s);

}
{code}

h3. org.apache.cxf.annotations.SchemaValidation  (since 2.3)

...


Turns on SchemaValidation for messages.   By default, for performance reasons, CXF does not validate message against the schema.   By turning on validation, problems with messages not matching the schema are easier to determine.

...




h3. org.apache.cxf.annotations.DataBinding  (since 2.2.4)

...


Sets the DataBinding class that is associated with the service.   By default, CXF assumes you are using the JAXB data binding.   However, CXF supports different databindings such as XMLBeans, Aegis, SDO, and possibly more.   This annotation can be used in place of configuration to select the databinding class.

...


{code
:java
java
}
@DataBinding(org.apache.cxf.sdo.SDODataBinding.class)
public interface MyService {
    public commonj.sdo.DataObject echoStruct(
        commonj.sdo.DataObject struct
    );
}
{code}

h3. org.apache.cxf.annotations.Logging  (since 2.3)

...


Turns on logging for the endpoint.   Can be used to control the size limits of what gets logged as well as the location.  It supports the following attributes:
|limit | Sets the size limit after which the message is truncated in the logs.  Default is 64K|
|inLocation | Sets the location to log incoming messages.  Can be <stderr>, <stdout>, <logger>, or a file: URL.  Default is <logger>|
|outLocation | Sets the location to log outgoing messages.  Can be <stderr>, <stdout>, <logger>, or a file: URL.  Default is <logger>|


{code}
@Logging(limit=16000, inLocation="<stdout>")
public interface MyService {

    String echoString(String s);

}
{code}


h3. org.apache.cxf.annotations.GZIP    (since 2.3)

...



Enables GZIP compression of on-the-wire data.  Supported attributes:
|threadhold|the threshold under which messages are not gzipped|
GZIP is a negotiated enhancement.  An initial request from a client will not be gzipped, but an Accept header will be added and if the server supports it, the response will be gzipped and any subsequent requests will be.


h3. org.apache.cxf.annotations.FastInfoset   (since 2.3)
Enables FastInfoset of on-the-wire data.  Supported attributes:
|force| forces the use of fastinfoset instead of negotiating.  Default is false|
FastInfoset is a negotiated enhancement.  An initial request from a client will not be in fastinfoset, but an Accept header will be added and if the server supports it, the response will be in fastinfoset and any subsequent requests will be.

h3. org.apache.cxf.annotations.EndpointProperty \\ org.apache.cxf.annotations.EndpointProperties (since 2.3)
Adds a property to an endpoint.  Many things such as WS-Security related things and such can be configured via endpoint properties.   Traditionally, these would be set via the <jaxws:properties> element on the <jaxws:endpoint> element in the spring config, but these annotations allow these properties to be configured into the code.

{code:java}
@WebService
@EndpointProperties(
    {
       @EndpointProperty(name = "my.property", value="some value"),
       @EndpointProperty(name = "my.other.property", value="some other value"),
    })
public interface MyService {
    String echoString(String s);
}