Java Weekly 51/15: Fluent APIs, CDI beans, J9 version scheme
This week in Java news: the cause of Java 9 delays becomes clearer, Java is to get a new version string scheme and the Streams debate continues. Java news updates and new knowledge resources in Thorben Janssen’s Java Weekly.
This post originally appeared on Thorben Janssen’s Java EE blog, where Java news is published weekly: thoughts-on-java.org.
Fluent APIs have become very popular because they are easy to use. The problem is that most of the existing Java APIs, patterns and concepts are not a good fit for fluent APIs.
Thierry Wasylczenko has a look at other languages and the new Java 8 APIs to show the beauty and advantages of a fluent API and discusses if and how you can create fluent APIs on top of existing concepts like JavaBeans: A Fluent API or not a fluent API? That is the Question!
Streams are an often discussed topic. There was a huge hype around them in the early days of Java 8. That has changed a little during the last months. Streams are still very popular, but there are also some critical discussions about them.
Lukas Eder summarized the most popular arguments against
Stream.forEach() in his recent post: 3 Reasons why You Shouldn’t Replace Your for-loops by Stream.forEach().
Java is finally getting a new version string scheme. The community was complaining for so long about the old version scheme that many developers had gotten used to it. But there will be no more need to complain. Java 9 will change the scheme to MAJOR.MINOR.SECURITY: A New JDK 9 Version String Scheme.
Do you know the difference between a bean and a bean instance in CDI? And which one do you use in your application?
Antoine Sabot-Durand wrote a very detailed post explaining the important difference between beans and bean instances, how injection works in CDI and the different kinds of CDI beans: How to recognize different types of beans from quite a long way away.
And if you want to learn even more about CDI, you should have a look at Antonio Goncalves post about his Four CDI articles in the Java Magazine, which explain the most important concepts in CDI.
Which logging configuration do you use for Hibernate during development and in production? Do you use the same or two different ones? I prefer two different ones to get a lot of useful information during development and the best possible performance in production: Hibernate Logging Guide – Use the right config for development and production.
JPA 2.1 introduced the unsynchronized PersistenceContext which provides an easy way to implement conversations with JPA. But what to do if you have to work with JPA 2.0? Abhishek Gupta shows in his recent post how you can use the transaction handling to get a similar behavior: Pre Java EE 7 alternative to JPA 2.1 unsynchronized persistence context.