Unity Logo

JSR 181 Annotations

We are working on adding JSR 181 2.0 support for annotations in XFire via Java 5 and commons-attributes. The Java 5 implementation will follow the JSR 181 spec and the commons-attributes implementation will mimic the spec in a pre-Java 5 way.

Currently we have not passed the TCK and this is available only in early access form only. However, what we have is fairly stable and we are working on passing the TCK as soon as it is out. (Yes we know the JSR 181 1.0 TCK is out, be we are intent on passing the 2.0 version as we are implementing JAX-WS as well).

As covered before, ServiceFactories are used to create services from classes. The default ServiceFactory is ObjectServiceFactory. To use annotations you must use the AnnotationsServiceFactory. You must pass it an annotation reader in the constructor which will read the particular type of annotation you are using.

Using Java 5 Annotations

In your services.xml, it would look like this:


The jar with the Java 5 JSR 181 annotations can be found here

Using Commons-Attributes Annotations

To use the commons-attributes annotations, you will need to follow these instructions on how to install the commons-attributes ant or maven plugin.

In your services.xml, it would look like this:

Writing Services with Annotations

Javadocs (See the javax.jws packages only).


Alternatively you can place your annotations in your interface and have your implementation refer to it as shown below.

The interface:

and the implementation:

To do this with commons-attributes instead, you will need to import the attributes from a different location and use the commons-attributes syntax:

Using custom annotations 

Additionaly XFire provides some annotations which are not part of JSR 181, but allows to use XFire specific functionality .

@EnableMTOM - enable MTOM on service

@ServiceProperty - allows to specify property on given serwise ( instead of creating <poperties><property key="propertyKey">propertyValue</property></properties> tags in service configuration file )

@ServicesProperties - allows to specify as many properties as you want, at once. 

© 2003-2008 Codehaus