Java Lobby Announcements

Subscribe to Java Lobby Announcements feed
Recent posts in Java on
Updated: 1 hour 54 min ago

How to Become a Competent (Java) Developer

2 hours 23 min ago

For the past couple of years, government and societies have been trying to make “Geek” cool again. Presidents and prime ministers are recommending that computer programming be part of schools’ curriculum. Politics aside, becoming a competent programmer today is more challenging than ever. Just being an introvert genius no longer suffices.

Companies and organizations are looking for people with cognitive skills to add to their technical abilities. It is difficult to put a number on this as it is very company-dependent, but the 70/30 rule could be applied here. That means that people should possess roughly 70% technical skills and 30% soft (cognitive) skills. A “hardcore” developer hardly moves into management if he/she lacks the soft skills required. I have managed many teams across multiple verticals and developed some job descriptions and career progression paths along the way that are in use in some of the largest companies in the world. Let’s try to sum up a few aspects of what seems to be the pattern when companies are recruiting or promoting.

Categories: Java

Why I'm Using Java EE (Instead of Spring)

Wed, 2016-10-26 11:31

Just recently, after one of my sessions at JavaDay Kyiv, I was asked by an attendee what the reasons were for my use of Java EE. In the session, I mentioned that in the past, I was also a heavy user of Spring.

Actually, I always enjoyed programming in Spring, and I liked the declarative programming model with annotations and the fact that the technology evolves quite fast. I used Spring up to version 4 in real-world projects, and we always tried to use the latest approaches — like @RestControllers, or Java-based configuration back then.

Categories: Java

This Week in Spring: Spring Cloud Camden and Using Kotlin

Wed, 2016-10-26 10:01

Welcome to another installment of This Week in Spring! This week, I’ll be in Des Moines, Iowa, for the Prairie.Code conference. If you’re nearby, stop by and say hi!

As usual, we’ve got a lot to cover so let’s get to it.

Categories: Java

Apache Karaf Features at Startup

Wed, 2016-10-26 09:01

In a previous article, I provided an introduction to how Apache Karaf uses "features" to simplify adding OSGi bundles to a container, including handling dependencies.

As discussed in that article, Karaf has its own XML format for a "feature repository," an XML file that lists one or more features. Each feature lists features or bundles that it relies on, with support for versioning. The whole thing works because Karaf can retrieve both the feature repository XML files and the OSGi bundles from a variety of sources, including Maven.

Categories: Java

Shades of the Single Responsibility Principle

Wed, 2016-10-26 07:31

In the object-oriented world, each developer who wants to live long and prosper should know the SOLID rules. SOLID is just an acronym of basic tips for writing maintainable, readable code. We all know many developers who follow these rules. And we all know many who know them, but don't use them. And finally, plenty of programmers have heard something about SOLID, but don't bother to learn anything about it. However well we use it, we can agree that sticking to SOLID is a good practice. But there are always compromises.

In fact, in the real world, we have to know that each letter in SOLID has own shades and gradients — they are not simply white or black. In this article, I want to tell you something about the Single Responsibility Principle (SRP), which covers the first letter in our acronym. What is it?

Categories: Java

Parallel Database Streams Using Java 8

Wed, 2016-10-26 06:31
What is a Parallel Database Stream?

With the introduction of Java 8, we got the long-awaited Stream library. One of the advantages with streams is that it is very easy to make streams parallel. Basically, we could take any stream and then just apply the method parallel() and we get a parallel stream instead of a sequential one. By default, parallel streams are executed by the common ForkJoinPool.

Parallel streams are good if the work items to be performed in the parallel stream pipelines are largely uncoupled and when the effort of dividing up the work in several threads is relatively low. Equally, the effort of combining the parallel results must also be relatively low.

Categories: Java

JTemplate: Template-Driven REST Services for Java

Tue, 2016-10-25 12:01

JTemplate is an open-source implementation of the CTemplate templating system (aka "Mustache") for Java. It also provides a set of classes for implementing template-driven REST services in Java.

This article introduces the JTemplate framework and provides an overview of its key features.

Categories: Java

Getting Started With IBM WAS Liberty

Tue, 2016-10-25 10:01

For a recent project requiring WebSockets and JMS, I needed to make use of IBM’s WAS Liberty Profile server, as WAS 8.5 ND only supports JEE 6. I want to share some of my learnings with you, starting with the basics: a short intro on what to expect and setting up a server.


Some highlights of WAS Liberty are:

Categories: Java

Simplifying Validations Using the Strategy(Enum) Pattern

Tue, 2016-10-25 09:01

Let's say we're dealing with a number of input fields that require validation. The validation logic might be simple or complex, involving many different factors or parameters to validate a single field. Normally, we use a number of if...else blocks to validate each and every input field. This approach will lead to concerns regarding maintainability, readability, and extensibility. Hence, I would like to discuss the best approach using the Strategy pattern, but using Enum for the implementation. This approach was already used in one of my previous projects and proved to be useful. Let's start our discussion.

Problem Statement

Let's assume that we ask the user to provide some of his personal and bank details when he applies for a loan. Once we receive the details, we might want to validate those. In real life, it might be many more fields and more complex validations. But, for our simple example, we will take around 10 fields and will perform simple validations — like whether the fields are empty. 

Categories: Java

Groovy Goodness: Interrupted Sleeping

Tue, 2016-10-25 07:31

Groovy adds a lot of useful methods to the Java JDK classes. One of them is the sleep method that is added to all objects. With the sleep method, we can add a pause to our code. The sleep method accepts a sleep time in milliseconds. The implementation of the method will always wait for the given amount of milliseconds, even if interrupted. But we can add a closure as an extra argument, which is invoked when the sleep method is interrupted. We should return true for the closure to really interrupt, otherwise we use false.

In the following example, we use the sleep method to pause the bedtime method of the User class. We run the bedtime method in a thread, and after 2000 milliseconds, we intercept the thread. The sleep method still waits for 5 seconds, before ending:

Categories: Java

LGPL: What You Need to Know

Tue, 2016-10-25 06:31

I often get questions about the LGPL license used for Kentor.AuthServices. I also often find it confused with GPL, which is something you should never, ever even consider to use in any closed source software that you intend to distribute. So this post is an effort to explain and answer common questions about the LGPL. Unfortunately, I have to add the disclaimer: I’m not a lawyer and the content of this post is only meant as an overview and introduction to the license. I might have got things wrong, so please read the real license yourself and involve appropriate legal counsel to be sure.

Intention of GPL and LGPL

The intention of the GPL (General Public License) is to promote free open source software. You can use the software under GPL, redistribute it, and modify it. But the result is always bound to be under the GPL license too. You can also combine GPL software with other software — as long as the combined work is licensed and distributed under GPL. This means that the GPL is “contagious” — if you use a GPL component in a system, the entire system has to be released under the GPL. The reasoning behind this is to promote open source. If a great library is only available under GPL it will force software that wants to use the library to be free and open source, too.

Categories: Java

Spring Boot Application Live Reload (Hot Swap) With Intellij IDEA

Mon, 2016-10-24 11:31

While developing Spring Boot Applications using Intellij IDEA, it was so annoying to restart the Spring Boot app after each and every change. Spring Boot provides live reload (hot swap) of application out of the box using the following dependency.

<dependency> <groupid>org.springframework.boot</groupid> <artifactid>spring-boot-devtools</artifactid> </dependency>

Categories: Java

Minor Release With Major Improvements: CUBA Platform 6.3

Mon, 2016-10-24 10:01

We are proud to announce the general availability of the new release of the CUBA Platform and Studio!
Perhaps this is one of the most feature-rich platform releases ever - there are important changes on all levels: architecture, extensibility, API usability, and performance.

This article covers major enhancements of the platform. The full list of changes is available in release notes:

Categories: Java

Vaadin + jOOQ: Implementing Business Web Applications in Plain Java

Mon, 2016-10-24 09:01

When speaking about business applications, you might find that a lot of them fall into the “data-centric” kind of application where SQL is frequently the key technology. Similarly, when speaking about web applications, you’ll end up with HTML rendered on the browser, most likely with the help of JavaScript. If we put this into the context of Java, web business applications can be implemented by directly using SQL, HTML, JavaScript, and of course Java. Vaadin and jOOQ enable you to implement data-centric web applications using only one language: Java.

This step by step guide shows you how to implement a Spring-based web application that connects to a MySQL server in order to query data that can be filtered from the UI. This guide assumes you know the very basics of Maven and Spring Framework (particularly the concept of dependency injection).

Categories: Java

How to Create and Release a JAR to Maven Central

Mon, 2016-10-24 07:31

I spend most of my time with Java writing stand-alone applications to support testing or code that we run as part of CI. I haven’t had to create a library that I make accessible to other people through Maven central.

I thought it was about time I did so.

Categories: Java

Apache Karaf Features for OSGi Deployment

Mon, 2016-10-24 06:31

I've worked on multiple teams that have successfully used Apache Karaf as an OSGi container. In addition to the usual need to understand OSGi bundles and class resolution in the context of multiple class loaders (which deserves at least one article all by itself), Karaf adds the concept of a "feature" on top of OSGi bundles. While there is detailed documentation on features, I've found that they can be confusing for new users, especially when they are resolved from Maven, since there seems to be so much behind the scenes magic involved.

Base OSGi

For everything that Karaf adds to OSGi, the basic unit of installation in the OSGi container is still the bundle. A bundle is a Java Archive (JAR) with some special information in its manifest that identifies it, gives a version, and specifies dependencies. When an OSGi container adds a bundle, it goes through a resolution process to make sure that the bundle's dependencies are met (and that it does not conflict with other installed bundles). However, that resolution process does not include any ability to obtain any dependencies; it just checks to see if they are available and delays or prevents the bundle from starting if a required dependency is missing.

Categories: Java

Tracing Spring Integration Flow With Spring Cloud Sleuth

Sun, 2016-10-23 10:01

Spring Cloud Sleuth is an awesome project that provides a way to trace requests that span multiple systems. Spring Cloud sleuth can optionally export this trace data to Zipkin where it can be visualized in a neat way. I especially love the fact that Spring Cloud Sleuth integrates deeply with Spring Integration and can nicely trace out the flow of a message.

Consider the following:

I have two different systems here — a work dispatcher producing "Work Unit"s and a Work Handler consuming them. They talk over a RabbitMQ broker. Just to mix the flow up a bit, I also have a retry mechanism in place which retries the message every 20 seconds in case of a processing failure

Both these systems are described using Spring Integration Java DSL, the outbound flow dispatching the WorkUnits looks like this:

@Configuration public class WorksOutbound { @Autowired private RabbitConfig rabbitConfig; @Bean public IntegrationFlow toOutboundQueueFlow() { return IntegrationFlows.from("worksChannel") .transform(Transformers.toJson()) .log() .handle(Amqp.outboundGateway(rabbitConfig.worksRabbitTemplate())) .transform(Transformers.fromJson(WorkUnitResponse.class)) .get(); } @Bean public IntegrationFlow handleErrors() { return IntegrationFlows.from("errorChannel") .transform((MessagingException e) -> e.getFailedMessage().getPayload()) .transform(Transformers.fromJson(WorkUnit.class)) .transform((WorkUnit failedWorkUnit) -> new WorkUnitResponse(failedWorkUnit.getId(), failedWorkUnit.getDefinition(), false)) .get(); } }
This is eminently readable — the "Work Unit" comes through a "works channel" and is dispatched to a RabbitMQ queue after tranforming to json. Note that the dispatch is via an outbound gateway, this means that the Spring integration would put the necessary infrastructure in place to wait for a reply to be back from the remote system. In case of an error, say if the reply does not appear in time, a stock response is provided back to the user.

 On the Work Handler side a similar flow handles the message:

@Configuration public class WorkInbound { @Autowired private RabbitConfig rabbitConfig; @Bean public IntegrationFlow inboundFlow() { return IntegrationFlows.from( Amqp.inboundGateway(rabbitConfig.workListenerContainer())) .transform(Transformers.fromJson(WorkUnit.class)) .log() .filter("(headers['x-death'] != null) ? headers['x-death'][0].count < 3: true", f -> f.discardChannel("nullChannel")) .handle("workHandler", "process") .transform(Transformers.toJson()) .get(); } }
The only wrinkle in this flow is the retry logic which discards the message after three retries. If you are interested in the details of how the retry is being hooked up, I have more details here.

So now, given this fairly involved flow, here is how Spring Cloud Sleuth with Zipkin integrated looks like:

Spring Cloud Sleuth intercepts every message channel and tags the message as it flows through the channel.
Now for something a little more interesting, if the flow were more complex with 3 retries each 20 seconds apart, again the flow is beautifully brought out by Spring Cloud Sleuth and its integration with Zipkin.

 If you maintain a Spring Integration based flow, Spring Cloud Sleuth is an addition to the project and can trace the runtime path of a message and show it visually using the Zipkin UI. I look forward to exploring more of the nuances of this excellent project.

The sample that I have demonstrated here is available in my GitHub repo —

Categories: Java

A Closer Look at Speedment 3.0.1 ''Forest'' Stream ORM

Sun, 2016-10-23 06:31
Following the Road

I have been contributing to the open-source project Speedment (which is a Stream ORM Java Toolkit and Runtime) and a new major version called 3.0.1 “Forest” was just released. Releases are named after the avenues in Palo Alto, California where most of the contributors work. Each new major release gets a new name by following Middlefield Road southwards. The new version is now modularized which helps developers keep up the good pace. There are also a large number of new features for Speedment users and in this article we will look into some of the things to discover!


People used to older ORMs can now use Speedment in the same way when creating, updating or removing entities from a database. For example, we can create entities in a database “JPA-style” like this:

Categories: Java

The 7 Best Java Frameworks for 2016

Sat, 2016-10-22 10:01

There is no doubt that Java is one of the programming languages that is most in demand these days. Here, we have scooped a handful of good info about trending frameworks that ease everyday lives of software developers around the globe.

As per a survey conducted by RebelLabs, the media ally for the online Java User Group (Virtual JUG), the lineup of best java frameworks for 2016 is the following:

Categories: Java

What's the Future of Software Development? [Video]

Sat, 2016-10-22 06:31

So… quick but powerful question: What's the future of software development?

A lot of people ask me about the future of software development. What the future holds for software development and for new and old programmers? Are there going to be new programming jobs in the future? Are there going to be new and exciting job creations when it comes to software development?

Categories: Java