Manuel Faux
Manuel Faux

Reputation: 2477

JAX-WS implementation annotations vs. interface annotnations

I configure my JAX-WS web service using annotations. I use an endpoint interface which is annotated with some values and is used by the server as well as by the client, so they share the interface.

My interface looks like this:

@WebService(name = Constants.NAME, serviceName = Constants.SERVICE_NAME, targetNamespace = Constants.NAMESPACE)
@SOAPBinding
public interface IManagementBean {
    @WebMethod(operationName = "getStatistics")
    IGetStatsResponse getStatistics(IGetStatsRequest request,
        @WebParam(name = "gridName", header = true, partName = "gridName") String gridName)
        throws WebServiceException;
}

In the corresponding implementation I use the same annotations, which looks quite redundant to me.

Is there a way to tell the implementation to "pull" the annotations from the interface instead of defining them on both sides?

Upvotes: 2

Views: 1686

Answers (1)

Paul Vargas
Paul Vargas

Reputation: 42060

If you don't like the interface, avoid the interface.

You can safely start without any interfaces and introduce them later as the need arises. This approach is fundamentally different from that in Java EE 5. Compared to Java 2 Platform, Enterprise Edition (J2EE) from 2003, Java EE 6 code is simpler, in terms of the elimination of several layers, indirections, and abstractions. Unlike J2EE, Java EE 6 consists of annotated classes without any dependencies on the platform. This approach eliminates the need to separate business logic from the infrastructure and makes the majority of J2EE patterns and best practices superfluous. In Java EE 6, simple cases can be solved with two layers: presentation and business logic.

Java EE 6: Simplicity by Design - Adam Bien

Upvotes: 3

Related Questions