Java Lobby Announcements

Subscribe to Java Lobby Announcements feed
Recent posts in Java on
Updated: 4 hours 5 min ago

Hazelcast Uses Infinispan and Apache Ignite's Own Benchmarks and Beats Them

Mon, 2015-11-09 08:23

We should start calling Hazelcast, Hazelfast. Hazelcast 3.6 EA shipped last week, and it is very fast. Compared to what, you ask? Well, compared to everything. How do we know this? Well, our competitors made their own comparative benchmarking tools, YardStick and RadarGun. And we ran them against Hazelcast as we were developing 3.6. We were getting faster anyway thanks to our dedicated performance team, but there is nothing like competition to spur improvement.

Hazelcast Versus Infinispan/JBoss Data Grid

On RadarGun, the Infinispan tool, we are faster in all tests with the biggest margin begin 80%.

Categories: Java

JPA in Case of Asynchronous Processing

Mon, 2015-11-09 07:45

A few years ago in the Java world it was almost obvious that every "enterprise" class project needed JPA to communicate with a database. JPA is a perfect example of "leaky abstraction" described by Joel Spolsky. Great and easy at the beginning but hard to tune and limiting at the end. Hacking and working directly with caches, flushes, and native queries is a daily routine for many backend developers involved in the data access layer. There are enough problems and workarounds to write a dedicated book "JPA for hackers", but in this article I'll focus only on concurrent entity processing.

Let's assume this situation: we have Person entity in which some business process is updated by some service.

Categories: Java

JavaOne the 20th Edition – Ten Takeaways

Mon, 2015-11-09 07:27

We have just had the twentieth edition of JavaOne in San Francisco. This would be my twelfth attendance in unbroken series since 2004. What are the biggest lessons that potentially shed a light on Java’s future.

  1. Modularization; the effort – it has taken almost nine years from the first mention of modules at Java 2007, or rather by the time that JDK 9 is released in September 2016 as general availability. In fact, it will be 11 solid years, ever since JSR 277 the Java Module System. When we think about this effort, it will be more a decade of activity and thought (See Stanley Ho’s original announcement). Oracle’s modularization of the JDK effort requires a biography of its own. Perhaps, Mark Reinhold, will get around to writing it one day, may be as the mythical man-month of the 21st century.

    It is frightening to think rewriting, effectively, Java so that it follows HIGH COHESION and LOOSE COUPLING took almost decade. Everyone else not in the JDK engineer should be extremely scared, especially if the business that you are involved in, has it own humongous mountain of TECHNICAL DEBT. Many institution cannot afford to upgrade, rewrite and reorder legacy classes, packages, let alone modules. Indeed, the cost of maintainability is about to go astronomical for those businesses that struggle under the weight and remain entrenched with Classic Java (JDK 1.0 to 7.0) For Oracle, they had no choice to pay the entire cost of development, design and architecture for the benefit of the entire Java platform and community in order to move forward to better and greater deads in the future. Oracle ought be immensely congratulated when we do reach JDK 9 GA in 2016.
  2. Modularization, the future – the new proverbial no brainer – I do believe Java and the practicing developer, designer and architect community have a LINE-IN-THE-SAND (aka DEMARCATION POINT or DISRUPTION LAYER), which we will pass through in 2016.  A modular system can change faster than the JDK platform. If Project Jigsaw is designed correctly, then you no longer have to contend with CORBA or the old fashion IBM derived java.util.Date and java.util.Calendar. In theory, you ought to be able to replace these module services and remove them if they are unnecessary. If you do not need Swing, then that module can go, same for JavaFX and AWT for server only deployment. Whilst backwards compatibility for Java platform is guaranteed, then it means opportunity for experimentation and new ideas.

    For recruitment sector, I predict, in 2017, JDK 9 will be CAMEL’S BROKEN BACK. I believe nobody will want to touch Java SE 7 or before (Classic Java) with a barge pole when they can move ahead quicker.  The top engineers will look at your job specification and run hundred miles if there is even an hint of classic Java there. You can offer £1000 per day for 6 months, but who seriously would go through technical debt and attempt to re-modularise ancient Java code, when the next women in the business down the road, is cracking on with the modern modular Java frameworks, gaining considerable experience, moving ahead of the pack, building the next greatest thing on JDK 9. On the other hand, Modularisation does not solve the technical debt, mountains or hill of it. If your business’s mission critical software is an unassailable ball of mud, then you will continue suffer the debt unless there is Agile change of behaviour. I think this is reason why the Oracle JDK 9  team want us to be the early-access early adopters in order to test their enterprise software as much as possible.
  3. More Push Java in the Cloud – At JavaOne 2015 there were a lot ideas and conference talks on Micro services and building Cloud enterprise applications.  The exhibition had a few cloud vendors like JElastic, Red Hat, Pivotal and CloudFoundry. Oracle released its own long-awaited cloud offering called the Oracle Java Cloud.  Ironically, their PaaS solution offers server clustered with Oracle Coherence, which used to be called Tangasol. Cameron Purdy, a very recent ex-Vice President of Oracle, created this early distributed grid and caching solution and, actually, one of his advocates, Brian Oliver, came to the JAVAWUG BOF 26 back in 2007 and gave a talk on Coherence.

    Arun Gupta for Refactor your Java EE Applications with Microservices and Containers (CON1700)

Categories: Java

Synchronized java.util.HashMap vs. java.util.concurrent.ConcurrentHashMap

Mon, 2015-11-09 07:07

Using java.util.HashMap from many threads without any synchronization leads to race conditions. So we need some kind of synchronization. The easiest way is to synchronize the complete class. Another way is to use a java.util.concurrent.ConcurrentHashMap. But what does this mean to the performance of the application?
As an example we use a HashMap to count the occurrence of a String:

import java.math.BigInteger; import; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; @State(Scope.Benchmark) public class MyBenchmark { private HashMapBasedCollectionmap = new HashMapBasedCollection(); private String nextSessionId(SecureRandom random) { return new BigInteger(130, random).toString(32); } public String[] buildNames(int size) { SecureRandom random = new SecureRandom(); String[] result = new String[size]; for (int i = 0; i < size; i++) { result[i] = nextSessionId(random); } return result; } @Benchmark public void testMethod() { String[] array = buildNames(40); for (int j = 0; j < 200; j++) { for (int i = 0; i < 40; i++) { map.addOne(array[i]); } } } }import java.util.HashMap; import java.util.function.BiFunction; public class HashMapBasedCollection { private HashMap<String,Integer> map = new HashMap<String,Integer>(); public static final BiFunction<String, Integer, Integer> fun = new BiFunction<String, Integer, Integer>() { @Override public Integer apply(String t, Integer u) { if( u == null ) { return new Integer(0); } return u + 1; } }; /** * * Warning: not thread safe * */ public void addOne(String key) { map.compute(key, fun); } }

As expected if we run the method “testMethod()” with two threads we see a race condition. Output from vmlens, a tool to detect race conditions:

Categories: Java

JSON Serialization in Scala Using SBT and Play

Sun, 2015-11-08 09:44

Working with JSON is a very common task. In Scala, you can do it in many ways, either with the help of Java popular libraries such as Jackson or using Scala specific libraries. How do you choose from Spray JSON, Play JSON, Argonaut, Jackson, Rapture and others?

One day I received a test task on an interview. I had to implement a JSON serialization and deserialization of a Checkout object in the context of e-commerce.

Categories: Java

Seeing How The Other Side Lives, A Package Manager Overview For Go Developers

Sat, 2015-11-07 14:28

Debating and discussing Go package management has become a popular topic. Most people agree that the out of the box package management is insufficient. But, what should be used to complement the Go toolchain and what changes, if any, should the Go toolchain make?

Package management for programming languages is nothing new. It’s worth learning and discussing how package management is handled by other languages. This can fuel our discussions and decision making. I’ve personally been studying this as part of my work on Glide.

Categories: Java

Applying IDE Inspections to Custom Java Annotations

Fri, 2015-11-06 11:51

The introduction of annotations with J2SE 5 has changed how we write and process Java. Besides Java SE's predefined annotations, frameworks, IDEs, and toolkits have introduced their own custom annotations. The Checker Framework has provided examples of how custom annotations can be used to add greater type safety in Java. In this post, I look at the writing of a simple custom annotation and using it in NetBeans (8.0.2) and IntelliJ IDEA (14.0.3) to help developers identify issues in their code that need further attention.

In the article Making the Most of Java's Metadata, Part 2: Custom Annotations, Jason Hunter demonstrates an @Unfinished annotation as an example of writing a custom Java annotation. I will demonstrate a different implementation of an @Unfinished annotation in this post. That's the beauty of custom annotations: one can write an annotation to best fit one's needs. The code for my @Unfinished annotation is shown in the next code listing.

Categories: Java

Java EE App Servers: Are They Still Relevant in a World of Docker Containers?

Fri, 2015-11-06 08:44

This year at JavaOne 2015 there was a recurring theme across many of the Cloud and DevOps tech sessions that were promoting self-contained deployable JARs (not EARs or WARs) as a more efficient approach for deploying lightweight Java based services. This approach also plays well for a microservices type architecture and can also easily make use of containers, like Docker, PaaS offerings like CloudFoundry or Heroku, or even Oracle’s new Java SE Cloud Services offering.

Being able to deploy small, self-contained services (compared to large, monolithic EARs) brings a whole range of benefits, like being able to deploy more often, and deploy individual services individually without touching or impacting any of the other deployed services.

Categories: Java

Implementing Auto Retry in Java EE Applications

Fri, 2015-11-06 07:47

Initially, I wanted to call this blog – ‘Flexible timeouts with interceptor driven retry policies‘ – but then I thought it would be too ‘heavy’. This statement, along with the revised title should (hopefully) give you an idea of what this post might talk about ;-)

The Trigger

This post is primarily driven by one of the comment/questions I received on one of my earlier posts which briefly discussed timeout mechanisms and how they can be used to define ‘concurrency policies’ for Stateful and Singleton EJBs.

Categories: Java

For Java Developers - Akka HTTP In The Cloud With Maven and Docker

Fri, 2015-11-06 07:05

From time to time it is necessary to just take the little effort to think outside the box. This is a good habit for every developer and even if you just spend 10% of your time, with new and noteworthy technology, you will gain experience and broaden your knowledge. I wanted to look into Scala and Akka since a while. Both well known old acquaintances on many conference agendas. But honestly, I've never felt the need to take a second look. This changed quite a bit when I started to look deeper into microservices and relevant concepts around it. Let's get started and see what's in there.

What Is Akka? And Why Scala?

Categories: Java

Under The Boot – Spring Boot

Thu, 2015-11-05 09:57

Remember the times when we had to register dispatchers, viewResolvers, etc. to make our spring application web app? Then there was @EnableWebMvc annotation, and now even this is redundant.

These days the only thing you need to do is to add org.springframework.boot:spring-boot-starter-web dependency to your project and everything else is done automagically.

Categories: Java

What Might a New @Deprecated Look Like?

Thu, 2015-11-05 09:51

JDK Enhancement Proposal (JEP) 277 ("Enhanced Deprecation") proposes to "revamp the deprecation annotation and provide tools to strengthen the tail end of the feature life cycle." Some of the limitations of the current @java.lang.Deprecated have bothered me for some time. I particularly would like to be able to provide text with @Deprecated rather than being forced to place explanatory text in a corresponding Javadoc @deprecated comment. In this post, I look at a custom annotation that gives a feel for the type of extra metadata JEP 277 proposes be included in a new and improved @Deprecated annotation.

The code listing that follows contains the definition of dustin.examples.annotations.Deprecated, an implementation which mostly mirrors what is described in the JEP 277 proposal.

Categories: Java

Working With Java 8 Optionals

Thu, 2015-11-05 08:48

In this post we are going to cover working with the Optional class introduced in Java 8. The introduction of Optional was new only to Java. Guava has had a version of Optional and Scala has had the Option type for some time. Here’s a description of Optional from the Java API docs:

A container object which may or may not contain a non-null value.

Categories: Java

How to Debug a Groovy Script From Shell

Thu, 2015-11-05 07:37

Groovy is a scripting language, so it is possible to run Groovy code without compiling to Java byte code. The necessary condition is that Groovy is installed on your machine. Then, running a Groovy script in a shell looks like the following line:

~>groovy TestScript.groovy

Now, something is wrong with the script on a special environment. You want to debug your Groovy script from the shell.

Categories: Java

Java Memory Architecture Cheat Sheet

Wed, 2015-11-04 21:39

The diagram below is the Java Memory Model for the Heap as well as the PermGen for any Java Application running in the Java Virtual Machine (JVM). The ratios are also provided to get a fair understanding of how the distribution of allowed memory is done across each of the generation types. All of the info is completely applicable up to Java 1.7 (inclusive). This diagram is also known as the 'Managed Area' of the memory model.

Java Memory Architecture (Java Memory Model)

Categories: Java

Code Challenge Series: Substring Search

Wed, 2015-11-04 08:14
Last week we had Fizz Buzz code golf and the Winner was Mark Ogden in Perl with an amazing 63 characters. There were a couple of answers that were also very close to that as well so well done to them too.

This weeks challenge is a little harder and should really tax your brains. Basically I would like you to find the first instance of an arbitrary length substring within a string without using regular expressions or the find/indexOf/search functions of the String object. So writing it in a low level aproach at a character level.

So in the case of the above example I am looking for the index of the first letter of the word end in the string you see there.

Categories: Java

Github Flavored Markdown + OSGi + dotCMS

Wed, 2015-11-04 07:22

As a Java based CMS, dotCMS handles a lot of different use cases for managing and delivering content. Recently, we were asked if dotCMS can deliver Github flavored markdown content. We thought that this would be a great example of how easy it is to extend dotCMS with OSGi plugins. (As a side note, this blog - as seen on -  is actually written using the plugin).


Some background for developers stuck in 2008, Markdown is a text to html parser originally written by John Gruber. It provides a user a simple, small set of markup tags that is parsed and rendered as standard HTML for consumption by browsers or even less capable views or viewports. Github Flavored Markdown, or GFM, offers a few extensions for further formatting, including support for strikethrough, url auto-linking, syntax highlighting and tables, Because of the ubiquity of github as a coding resource, GFM has become a de facto standard for commenting, documentation and other online authoring tools that needs support for formatting, but want to limit, uh, “creativity”.

Categories: Java

A New Java Library: ParallelGit

Wed, 2015-11-04 00:17

Hi all. Just published an open source library to the Maven Central Repository. As the author of this project, I am here to shout out the exciting news :)

ParallelGit is a library to help you manipulate your local Git repository. It allows you to access your repository as it were a native file system (via Java 7 nio FileSystem interface).

Categories: Java

JetBrains Releases IntelliJ IDEA 15

Tue, 2015-11-03 17:43

Today, JetBrains announced a new release of their popular IDE IntelliJ IDEA. The company promised the new release brings a new set of features and tools, UI improvements, and improved coding assistance. 

In addition, JetBrains' new in-development JVM language, Kotlin, has gone into Beta. Naturally, the new language is supported in IntelliJ IDEA 15. 

Categories: Java

DZone's Zone Leader Spotlight – Dave Fecak

Tue, 2015-11-03 17:42
Background: What is a Zone Leader? 

Recently I've taken charge on what I think is a great opportunity for writers and topic experts in the devsphere—our new Zone Leader Program. In a nutshell, the Zone Leader Program is an effort to put topic experts and practioners in the software industry at the helm of the content we publish on DZone. A sizeable portion of the content you've been reading on DZone recently has actually been written or published by Zone Leaders!

If you're interested in learning more and maybe being a Zone Leader yourself, shoot me an email.

Categories: Java