Personal notes on Java
For other technologies like HTML, CSS, .NET, PHP, etc. check my other blog

Main packages

  • javax.servlet.annotation: contains Servlet related annotations;
  • javax.ejb: Contains the Enterprise JavaBeans classes and interfaces that define the contracts between the enterprise bean and its clients and between the enterprise bean and the EJB container.
    Contains annotations like:
    @EJB; @Stateless; @Statefull; @Singleton; @MessageDriven; @PostActivate; @PrePassivate; @Local; @Remote; etc.
  • javax.annotation: defines common annotations.
    Contains annotations like:
    @ManagedBean; @PostConstruct; @PreDestroy; @Resource

Misc Annotations
  • @EJB [1]: Can be used to provide client access to an enterprise bean through dependency injection. The container performs any dependency injection needed;
  • @Local [1]: 
  • @PostConstruct [2]:
  • @Remote [1]: 
  • @WebMethod [1]: The @WebMethod annotation may be used to customize the behavior of web service methods. If the @WebMethod annotation is used to decorate the bean class’s methods, only those methods decorated with @WebMethod are exposed to web service clients.
  • @Entity[3]: Marks the class as an entity bean. Each entity bean corresponds to a database row.
  • @PersistenceContext[4]: In the EJB 3.0 technology code sample, the @PersistenceContext annotation injects an EntityManager with a transactional persistence context, on which the session bean has a dependency. The container then takes care of obtaining the reference to the needed resource and providing it to the bean. Dependency injection can dramatically simplify what you have to code to obtain resource and environmental references.

Servlet Annotations

Check the javax.servlet.annotation package: this package contains a number of annotations that allow users to use annotations to declare servlets, filters, listeners and specify the metadata for the declared component.

Some of the annotations defined in this package are:
  • @WebServlet: lets you define url patterns that a Servlet will manage (click the link for more info);



Resources:
[1] - Accessing Enterprise Beans
[2] - The Lifecycles of Enterprise Beans
[3] - EJB Bean Annotation
[4] - The Java Persistence API - A Simpler Programming Model for Entity Persistence

Sem comentários:

Enviar um comentário