Definitely one of the most interesting talks this year at Devoxx was the one detailing all the new changes in the JEE landscape part of the next major specification upgrade JEE7. The talk was presented by Arun Gupta (@arungupta) and Antonio Goncalves (@agoncal). In this blogpost I’ll try to give an overview of the most important changes and additions in JEE7.
A lot of the specs got an overhaul of some sorts and there are also some new specs introduced. The picture below gives an overview.
A common theme in the updated specs is the introduction of CDI annotations (CDI was introduced in JEE6). CDI itself also has a new minor version upgrade of the spec. The most important change there is that the beans.xml file is no longer mandatory to turn a class into a CDI bean. Also a lot of standard default resources have been defined (like java:comp/DefaultJMSConnectionFactory). I’ll try to summarise the most interesting changes and additions.
One common pitfall in JEE before version 7 was the use of Threads. The use of user threads in JEE programming is considered a really bad practice, because thread management should be handled by the container. To standardise multithreading in a JEE application the Concurrency API is introduced.
With the help of the ManagedExecutorService and ManagedExecutorScheduledService (scheduled) jobs can be run asynchronously in a separate thread. Both services can be injected by using annotations. The ManagedThreadFactory can also be injected and provides a means to get a handle on a factory class for the creation of container managed threads.
Some powerful new features have been added to the specs. Schema generation, a feature that’s been present in Hibernate for a long time has been standardised and added to the JPA specs. It’s also possible to define indexes now by making use of the @Index annotation. Stored procedures can now be defined and called by using the @NamedStoredProcedureQuery annotation. Finally for conversion between a database type and a Java type a converter class can be defined annotated with the @Converter annotation.
For the first time in many a year the JMS specs sees a major overhaul. In the past JMS programming required a lot of boiler plating. This has been addressed in the new version of the spec. The API has been simplified and now makes heavy use of method chaining. Exceptions have been converted to Runtime Exceptions also simplifying and shortening JMS processing code. The Autocloseable interface furthermore reduces boilerplating. And last but not least connection factories and destinations (queues/topics) can now be defined programmatically using annotations (@JMSConnectionFactoryDefinition, @JMSDestinationDefinition).
Similar to the JAXP specification for XML processing the JSON-P spec provides an abstraction layer for JSON processing. There are classes which provide builder functionality for creating a JsonObject in Java (similar to DOM building for XML) and there is a JsonParser class (similar to SAX). It is expected that in a future version of JEE a JSON-B spec will arise (similar to JAXB) which standardises Java to JSON binding.
Heavily borrowing from Spring Batch (actually the Spring guys contributed a lot to the spec) the Batch 1.0 specification standardises batch processing in JEE. Batch steps, jobs, flows and listeners are all orchestrated in XML. Standard interfaces like ItemReader, ItemProcessor and ItemWriter and abstract classes are available for implementing the building blocks in a batch job.
All in all some powerful features have been introduced along with some completely new and highly anticipated specifications.
You can find the slides for the Devoxx presentation “Java EE 7: What’s New in the Java EE platform” on Slideshare. The Java JEE7 code samples are on Github.Overzicht blogs
Geef jouw meningReactie plaatsen