Subscribe: Javalobby - The heart of the Java developer community
Added By: Feedage Forager Feedage Grade A rated
Language: English
blueprint  boot  collections  create  file  files  git  java  jshell  json  list  microservices  smart  spring boot  spring  string 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Javalobby - The heart of the Java developer community

DZone Java Zone

Recent posts in Java on


Finding (Buggy) Calls of java.lang.object.equals() With Incompatible Types

Wed, 22 Feb 2017 08:01:00 GMT

All this started from a change (and a mistake) made by one of my co-workers. It involved a small change in the code with rather dramatic consequences.

So, imagine we have a (java) class T having a private field f of type String:

JOOQ Tuesdays: What it Takes to Write the Fastest Java Connection Pool

Wed, 22 Feb 2017 04:01:00 GMT

Welcome to the jOOQ Tuesdays series. In this series, we’ll publish an article on the third Tuesday every other month where we interview someone we find exciting in our industry from a jOOQ perspective. This includes people who work with SQL, Java, Open Source, and a variety of other related topics.

I’m very excited to feature today Brett Wooldridge, creator of HikariCP, the fastest connection pool available for Java.

OSGi Blueprint Visualization

Tue, 21 Feb 2017 21:01:00 GMT

A blueprint is a dependency injection framework for OSGi bundles. It could be written by hand or generated using the Blueprint Maven Plugin. A blueprint file is just an XML file describing beans, services, and references. Each OSGi bundle could have one or more blueprint files.

Blueprint files represent the architecture of our bundle. Let's visualize it using Groovy and graphviz, available in my GitHub repository and analyze.

Multi-Tenancy Using JPA, Spring, and Hibernate (Part 2)

Tue, 21 Feb 2017 17:01:00 GMT

To understand how tenants work in Spring, it is important to first understand what multi-tenancy is and how it is implemented in JPA.

As I said in part 1, Hibernate/JPA knows the current tenant through the CurrentTenantIdentifierResolver, which is resolved by Spring. So the real question here is, “How does Spring know what tenants exist?” The answer to this question has a lot of different ways to be implemented, which is why it’s difficult to find a good reference.

Git Submodules: Core Concept, Workflows, And Tips

Tue, 21 Feb 2017 11:01:00 GMT

Including submodules as part of your Git development allows you to include other projects in your codebase, keeping their history separate but synchronized with yours. It's a convenient way to solve the vendor library and dependency problems. As usual with everything git, the approach is opinionated and encourages a bit of study before it can be used proficiently. There is already good and detailed information about submodules out and about so I won't rehash things. What I'll do here is share some interesting things that will help you make the most of this feature.

Core Concept

First, let me provide a brief explanation on a core concept about submodules that will make them easier to work with.

Java String Format Examples

Tue, 21 Feb 2017 08:01:00 GMT

Have you tried to read and understand Java’s String format documentation? I have and found it hard to understand. While it does include all the information, the organization leaves something to be desired.

This guide is an attempt to bring some clarity and ease the usage of string formatting in java.

Java 9: Factory Methods to Create Immutable Collections

Tue, 21 Feb 2017 05:01:00 GMT

In this article, we will see another JDK 9 feature — creating immutable collections. Until Java 8, if we wanted to create immutable collections, we used to call unmodifiableXXX() methods on java.util.Collections. For example,  To create an unmodifiable list, we should write:

jshell> List list = new ArrayList();
list ==> []

jshell> list.add("Smart")
$2 ==> true

jshell> list.add("Techie")
$3 ==> true

jshell> System.out.println("The values are: "+ list);
The list values are: [Smart, Techie]

jshell> // make the list unmodifiable

jshell>    List immutablelist = Collections.unmodifiableList(list);
immutablelist ==> [Smart, Techie]

jshell> // try to modify the list

jshell>    immutablelist.add("Smart_1
|  java.lang.UnsupportedOperationException thrown:
|        at Collections$UnmodifiableCollection.add (
|        at (#6:1)


Groovy Goodness: Creating a Root JSON Array

Mon, 20 Feb 2017 21:01:00 GMT

Creating JSON output with Groovy is easy using JsonBuilder and StreamingJsonBuilder. In the samples mentioned in the links, we create a JSON object with a key and values. But what if we want to create JSON with a root JSON array using JsonBuilder or StreamingJsonBuilder? It turns out to be very simple — by passing a list of values using the constructor or using the implicit method call.

In the following example, we use JsonBuilder to create a root JSON array:

JShell: The Java Shell and the Read-Eval-Print Loop

Mon, 20 Feb 2017 17:01:01 GMT

Let's talk about JShell. We can explore it with the JDK 9 Early Access Release. As of now, the general availability of JDK9 is scheduled for 27 July, 2017, and the JShell feature was proposed as part of JEP 222. The motivation behind it is to provide interactive command line tools to quickly explore the features of Java.

From what I've seen, it is a very useful tool to get a glimpse of Java features very quickly, which is especially useful for new learners. Already, Java is incorporating functional programming features from Scala. Consider the move to a REPL (Read-Eval-Print Loop) interactive shell for Java, just like Scala, Ruby, JavaScript, Haskell, Clojure, and Python.

An Interview Question on Spring Singletons

Mon, 20 Feb 2017 11:01:00 GMT

While interviewing for positions using Spring Core, I often ask a certain question, "What do you mean by Spring Singleton scope?"

Most of the time, I get an answer like, "Spring Singleton scope manages only one object in the container."

Java 8 Lambda Limitations: Closures

Mon, 20 Feb 2017 08:01:00 GMT

Suppose we want to create a simple thread that only prints something on the console:

int answer = 42;
Thread t = new Thread(
  () -> System.out.println("The answer is: " + answer)

Lesser Known Git Commands

Mon, 20 Feb 2017 05:01:00 GMT

Git has a strong commitment to backwards compatibility: many powerful features are hidden behind options rather than exposed as default behavior. Fortunately, Git also supports aliases, so you can create your own commands that do all manner of Git magic. Here’s a selection of the more useful (or at least entertaining) aliases defined in my .gitconfig:

Git Please

$ git config --global alias.please 'push --force-with-lease'

Contexts and Dependency Injection (CDI): Eager Extensions

Sun, 19 Feb 2017 06:01:00 GMT

CDI does not provide eager extensions out of the box. Even though there is @ApplicationScoped, which is intended to work in a similar way to eager instantiation, it does not behave in the specified fashion. 

I am going to describe how to use CDI extensions to get eagerly instantiated beans following the CDI lifecycle — inside the container. I have used this in Wildfly 8.0. 

Five Tips for CI-Friendly Git Repos

Sat, 18 Feb 2017 06:01:00 GMT

If you follow Atlassian, you know we're big on continuous integration("CI") and Git–separately, sure: but even bigger on the power that the two offer in combination. Today I want to share some tips for getting your CI system to interact optimally with your repository, which is where it all begins.

1: Avoid Tracking Large Files in Your Repo

One of the things you often hear about Git is that you should avoid putting large files into your repository: binaries, media files, archived artifacts, etc. This is because once you add a file, it will always be there in the repo’s history, which means every time the repo is cloned, that huge heavy file will be cloned along with it. And getting a file out of the repo’s history is very tricky, It’s the equivalent of performing a lobotomy on your code base. And this surgical file extraction alters the whole history of the repo, so you no longer have a clear picture of what changes were made and when. All good reasons to avoid large files as a general rule.

A Disk-Based Collection in Java

Fri, 17 Feb 2017 21:01:00 GMT

The FileBasedCollection was developed to store more elements in a collection than the memory can hold. This is not necessarily big data, but it is a technique to deal with a lot of data. Big in relation to the heap size. In Java, this threshold is easily reached because the heap size is usually limited to some level far below the actual amount of available memory. The FileBasedCollection is developed for a use case where the heap would have to be several dozens of Gigabytes. This is not a problem for 64-bit JVMs, but you can't size the heap space to exactly fit the job. The FileBasedCollection is a semi-modifiable collection with an iterator, which swaps to disk if the internal store is filled up to a certain threshold. The iterator allows the programmer to go through the data from beginning to the end. The total number of elements that can be stored is unlimited, but at some point, your hard disk will run out of space.

Use FileBasedIterator With Try-With-Resources

This example creates a FileBasedCollection with the try-with-resources syntax. The FileBasedIterator is also created with the try-with-resources syntax. First, a million integers are added to the FileBasedCollection, then the FileBasedIterator iterates over the collection and sums the values. If try-with-resources isn't used then the iterator and collection must be closed with the close() statement. It is therefore recommended to use try-with-resources.

IntelliJ IDEA 2017.1 EAP: Async Smart Step Into and Faster Git File History

Fri, 17 Feb 2017 17:01:00 GMT

Last week, we published the EAP of the upcoming IntelliJ IDEA 2017.1, which included initial support for async stacktraces. Today, along with a fresh EAP build, we’re happy to introduce another improvement aimed at making debugging asynchronous code easier: a step into that supports lambda expressions executed on other threads:

Earlier, this was only possible when you manually added a breakpoint directly at a lambda expression, but now you can just Smart Step Into to debug asynchronous code.

From Microservices to Distributed Systems: A Survival Guide for Java Devs

Fri, 17 Feb 2017 11:01:00 GMT

It kind of feel like the hype for microservices is slowly coming down to earth. Our industry is starting to realize that a system, according to the architectural paradigms behind microservices, can't easily be created by just exposing some HTTP interfaces on top of existing components. We do seem to have agreement on the necessity of having service-optimized infrastructures, cultural, and organizational changes and last but not least the outer architecture or orchestration for these architectures. The parts that many Java developers still seem to struggle with are the concrete system architecture and the fact that microservices are nothing other than distributed systems. Unfortunately, it's exactly these knowledge areas that decide the success of failure of your project. For a little bit of background, I suggest reading the wonderful InfoQ interview with Uwe and Adrian done by Daniel Bryant.

Why Microservices Again? Can't I Just Be Happy and Write EJBs and Servlets?

The key idea with microservices is supporting their independence from the rest of the application landscape and quick evolvability. Additionally, they should scale independently and require fewer resources than application server-based applications. In a world with constantly changing business requirements and a growing number of application clients, centralized infrastructures are getting way too expensive to operate and scale towards unpredictable load or load peaks. If we were stuck with application servers, we wouldn't have Netflix, Twitter, or Amazon. So... no. You can't just stay where you are.

Spring Boot: Changing/Configuring the Default Embedded Server

Fri, 17 Feb 2017 08:01:00 GMT

In a previous post, we created a web-based Spring Boot application that uses Embedded Tomcat as the default server running on the default port, 8080. Spring Boot supports Tomcat, Undertow, and Jetty as embedded servers. Now, we will change and/or configure the default embedded server and common properties to all the available servers.

Spring Boot provides a convenient way of configuring dependencies with its starters. For changing the embedded server, we will user its spring-boot-starter-undertow.

Bind Your Contexts, Don’t Hurt Them!

Fri, 17 Feb 2017 05:01:00 GMT

This article is a response to a comment under one of my previous ones – Layered Architecture Is Good. The comment says:

Domain driven design does not conflict with layered architecture! The first example has a strict separation of layers.

Spring Tips: jOOQ [Video]

Thu, 16 Feb 2017 21:01:00 GMT

Speaker: Josh Long

Hi, Spring fans! In this tip, we’ll look at jOOQ (a fluent API for typesafe SQL query construction and execution) to quickly and easily interface with our SQL database.