The Java EE 6 specification hits you flat in the face when you're back from the conference where it was so loudly applauded. Where to start? What to do first? Is it all hype? What does it all mean really for real? No need to panic, since literally the entire Java EE 6 specification is deeply integrated into NetBeans IDE 7.1.

Without further ado, let's look at the specification and map its various parts to the related tools provided by the IDE.

JPA 2.0

The Java Persistence specification defines how relational data is mapped to Java objects, standardizing Object/Relational mapping. In the IDE, a wizard is provided that connects to a registered database (which can also be viewed and changed in a database exploration tool in the IDE), lets you select tables, and then generates Java objects from them. Each generated Java object is annotated as an entity following JPA 2.0 standards, a persistence.xml file defining the database connection is created, and named queries (such as "Customer.findAll", which maps to an SQL query) are optionally inserted into the Java objects.

As a result, your database is accessible from cleanly generated Java POJOs, in a matter of seconds. Either you can now inspect the generated entities and extend them for your own applications (for example, code completion is available to help you get started with the new Criteria API) or you can use the generated entities as a learning device while becoming comfortable with the JPA specification.

EJB 3.1

Earlier releases of the Enterprise JavaBeans specification were complicated and verbose. In contrast, EJB 3.1 is remarkably lightweight, requiring very little coding. They're simply there to help you create a business layer. Think "C" in "MVC" and you've got it. In the IDE, when you build them, EJBs are included in the application's WAR file, instead of being archived in separate EAR files, which is one of the great enhancements in EJB 3.1. Templates are provided by the IDE for creating new beans of various kinds: session bean, timer session bean, message-driven bean, as well as session beans generated from entity classes.

Using the IDE, you quickly see that EJBs are no longer defined by the interfaces they implement. Instead, a session bean is a simple POJO with annotations such as @Stateless and @LocalBean. When Alt-Insert is pressed inside the Java Editor, code snippets can be created, such as code for injecting the persistence.xml file via the @PersistenceContext annotation and referring to it via the JPA EntityManager class. Further help is provided, including a wizard for creating new business methods in an EJB. For each EJB in your application, a new node is added to the application structure in the Projects window, so that you can very easily see the artifacts made available by the application. Especially when the application becomes larger, and manageability concerns become more prominent, such global views into the project structure become more important.

JSF 2.0

Instead of using JSPs, you can now use XHTML files, defined by Facelets, which is now part of the Java Server Faces specification. One benefit is that you can now use CSS to style your view layer. Another advantage is that Facelets supports templating. In the IDE, you can use a wizard for creating a Facelets Template file, after which you can use another wizard to create a client of the generated template file.

When working within these files, tools exist in the IDE for extracting a set of tags into a JSF Composite Component, which is a separate XHTML file that can be reused across multiple Facelets files. In this way, component-based development is supported by JSF 2.0, supported by the IDE. A separate wizard is also provided in the IDE for creating new JSF composite components.

Moreover, JSF pages can be generated from entity classes. When the "JSF Pages from Entity Classes" wizard is selected, you can choose one or more entity classes, and then the IDE will generate four XHTML files for each selected class. Within the generated files, JSF tags are added enabling common CRUD operations to be perforemed on the underlying entity classes.

Servlets 3.0

By default, following the Java Servlets 3.0 specification, the IDE does not register a newly created servlet into the application's web.xml file. Instead, the @WebServlet annotation is added to the top of the Servlet class, with the "urlPatterns" attribute defining the URL pattern. That's very handy since now you don't need to switch between the web.xml editor and the Java Editor. Modifying the URL pattern can be done very easily, by changing the annotation on the class. Should a web.xml still be needed, a template exists for creating one.

Within the servlet, press Alt-Insert and then you can, as always, generate code. However, there are some powerful new additions in this code generator. Notably, a wizard can be started for selecting session beans. Code for injecting the selected session beans is created into the file, via the @EJB annotation.

CDI 1.0

The new Context and Dependency Injection specification lets you bind the lifecycle and interactions of stateful components to well-defined but extensible lifecycle contexts. In addition, it lets you inject components into an application in a typesafe way, including the ability to choose at deployment time which implementation of a particular interface to inject.

Since an application that uses CDI must have a file named beans.xml, the IDE provides templates for creating this file. If the file does not exist and you annotate EJBs with @Named, for example, which exposes it for injection via expression language into JSF files, the IDE automatically creates a beans.xml file in the META-INF folder for you. In a JSF Facelets file, when you use expression language to refer to your named EJB, the IDE offers code completion for the class names, as well as the methods within the class. In this way, you can very easily connect your view layer (provided by JSF Facelets files) with your business layer (provided by EJBs).

Furthermore, wizards are provided by the IDE for generating new qualifiers, stereotypes, interceptor binding types, and scope types. These files conform to the deeper aspects of the CDI specification, helping you to get started with them quickly, avoiding discouraging errors right at the start of your learning process.

JAX-RS 1.1

The Java API for RESTful Web Services 1.1 lets you quickly build lightweight web services that conform to the Representational State Transfer (REST) style of software architecture. JAX-RS is a standardized API for building RESTful web services in Java. In REST, you deal with resources, each of which can be referred to with a global identifier, that is, a URI. These can be created very easily in the IDE. In a session bean, add a @Path annotation, which denotes in JAX-RS 1.1 that the artifact should be exposed as a RESTful resource, and the IDE will immediately pop up a dialog that lets you configure the REST libraries and related resources.

Also, a library of wizards are provided for generating RESTful web services from a number of different sources: entity classes, patterns, and databases. Once the RESTful web services have been created, another wizard can be used for generating the client that consumes the web service's payload. More refined wizards are available for very specific use cases, such as for generating secure token services, logical handlers, and message handlers.

Miscellaneous

The Java EE 6 Platform provides a number of other APIs, in addition to those listed above. The IDE also supports these via templates, code completion, and a large set of documentation and tutorials. For example, the Bean Validation API is supported via new wizards that let you generate constraint classes, together with their related configuration files.

Conclusion

While code generators and tools such as those described here are great to help you get your feet wet, a danger is that a lot of code is generated that you don't understand and that you therefore do not know how to debug and maintain. It is advisable to use tools of this kind intelligently. Start small, focusing on specific APIs. Get to know them via the generated code and then slowly extend the application as you become more familiar with the Java EE 6 Platform. Once you are comfortable with the spec, the tools aim to help you become more productive: combining the leanness of the Java EE 6 Platform with the tools in the IDE, you'll be creating the real meat of your application before you know it!

In short, the 7.1 release of NetBeans, the IDE for the Java Platform, is a great place to start learning the ins and outs of the Java EE 6 Platform.

For further information, refer to the following resources: