JSR 250 (Common Annotations)

In this section, we will be looking at some of the useful annotations introduced in the JSR 250 (Common Annotations) specification. We will be looking into the following annotations:

  • javax.annotation.Resource
  • javax.annotation.PostConstruct
  • javax.annotation.PreDestroy

javax.annotation.Resource

This annotation is used to mark a WebServiceContext resource that is needed by a web service. It is applied to a field or a method for JAX-WS endpoints. The container will inject an instance of the WebServiceContext resource into the endpoint implementation when it is initialized. This annotation is illustrated in the following example:

@WebService public class HelloImpl { @Resource private WebServiceContext context; public String ...

Get Apache Axis2 Web Services Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.