# Developing EJB 3.1 Applications

You can use the workbench to develop and test enterprise beans that conform to the distributed component architecture defined in the Sun Microsystems Enterprise JavaBeans (EJB) 3.10 specification.

Using this specification, you can develop beans more simply than in the 2.1 standard. You can annotate your Java source code to provide information that was previously contained in XML deployment descriptors. Using Java™ annotations allows you to create EJBs and Java Persistence Architecture (JPA) beans quickly and easily from “plain old Java objects (POJOs). For EJBs, these can be created without implementing EnterpriseBean interfaces.

This product supports the Enterprise JavaBeans 2.1 and 3.0 specification levels. All of the EJB tools in the product are accessible from the Java EE perspective in the workbench. You can create session beans (stateful or stateless) or message-driven beans, by simply specifying the component defining annotation in your POJO. Additional configuration for your bean can be done by specifying additional annotations in the Java class. The Java editor provides validation, content assistance and QuickFixes for your EJB 3.0 annotations, as well as support for refactoring beans. For richer assistance with the EJB 3.0 annotations, you can use the Annotations view to add or delete annotations, and to modify the attribute values of annotations. Deployment descriptors for your EJB 3.0 modules are optional, but can be created for additional configuration.

New in EJB 3.1 (JSR 318)

- Singleton beans (@Singleton)
  - Before EJB 3.1, there was no easy way to share data throughout the application; the EJB 3.1 Singleton is an application-wide singleton.
  - Concurrency can be managed either by the container or by the Bean Developer

Java EE 5 streamlines EJB development in the following ways:

- Fewer required classes and interfaces
  - Home and object interfaces are no longer required – you need the business interface only
  - No need to implement javax.ejb.SessionBean
  - No need to declare checked exceptions
- Optional deployment descriptors
  - Annotations provide component definition and dependency injection
- Simple lookups
  - new EJBContext() interface method replaces JNDI calls
- Lightweight persistence for object-relational mapping
  - Entities are POJOs that provide an object-oriented view of the data stored in relational database
- New Interceptors class (new in Java EE 5)
  - Interceptors are objects that can intercept a call to a business method (to handle security for example)
  - Similar in purpose and action to servlet filter or Web services handler
  - Provide limited form of aspect-oriented programming

For further additional information on EJB 3.0, see the official specification: JSR 220: Enterprise JavaBeans™ 3.0

- Creating EJB projects
  An EJB project is used to organize the resources contained in an EJB module.
- Content assist and EJB 3.1
  The content assist tool is a feature of the workbench. You can type code in your Java editor and the content assist tool recommends possibilities to complete your code.

Parent topic: EJB 2.x application development