JVM articles

Testing views with HtmlUnit in Spring

Testing view part of web applications in Spring isn't a simple task. But to simplify it, you can use libraries as HtmlUnit, a kind of command-line browser written in Java. And Spring Test MVC HtmlUnit allows to integrate this library inside Spring test cases and to write more complex test cases.

Continue Reading β†’

Defining tests in Play Framework

Previously we discovered how to setup test environment in Play Framework. Now we can focus on more pragmatic aspect, test writing.

Continue Reading β†’

Anonymous inner classes in Java

Sometimes when you want to write a code "proof of concept", you can define classes without names, inside methods. It's for example the case of very common new Thread(new Runnable() {}).start() which launches new Java's thread. In this article we'll focus on these classes, called anonymous inner classes.

Continue Reading β†’

Reading Java methods in bytecode

Last time we discovered the very basic elements of Java's bytecode, as methods or fields representations. This time we will treat more advanced subject, methods in general.

Continue Reading β†’

Introduction to Java's bytecode reading

When you're learning Java concurrency, you surely hear very often about barriers. These barriers are expressed explicitly in bytecode, a intermediary form between code wrote by human and interpreted by machine. In this article we'll begin to learn the interpretation of bytecode to understand better what happen with it after, when machine uses it.

Continue Reading β†’

Navigable collections in Java

Java's collection framework is a very large subject. We can find there collections sorted by natural key name, containing only single element of given value, able to be extended thanks to no-fixed size needed at initialization. We can find there also collections considered as navigable.

Continue Reading β†’

Transaction isolation in Hibernate

Working with databases implies the respect of ACID principle. One of "tools" used to ensure this respect are transactions.

Continue Reading β†’

Google Guava : cache

Google Guava provides a lot of programming shortcuts. It contains a simplified version of String and primitives management. These features seem a little bit basic. However, Google's library simplifies also the work with more complex stuff as cache.

Continue Reading β†’

Google Guava: input/output operations

Working with files in Java, and more precisely, reading file streams, was always a little bit complicated. It's the reason why each new version of Java contains some improvements for that. And Google Guava, once again, appears as an alternative.

Continue Reading β†’

Repositories with Criteria queries in Spring Data

Previously we discovered the advantages of repositories compared to classic DAO layer. We saw that repositories supported both native SQL and JPQL queries. But do they support other features of JPA, as Criteria API ? Yes, and we'll see it in this article.

Continue Reading β†’

SpEL in Spring Data queries

Spring Expression Language (SpEL) est is used often in Spring Security project. But Spring Data also supports it.

Continue Reading β†’

JPA criteria queries

Querying database with JPQL queries is quite simple. But a main drawback of this solution is its static character. To create dynamic queries, a more adapted solution exists, JPA Criteria.

Continue Reading β†’

Static metamodel in JPA

Entity modeling looks like the most important and the single meta data associated with a Java class in JPA. But it's not alone. Static metamodels are a meta data describing entity too. Unless, they are used in different purposes.

Continue Reading β†’

Asynchronous events in Spring

Synchronous events have one major drawback: they're natively executed in the calling thread. If the listener handling on of synchronous events takes 5 seconds to respond, the final user won't able to see the response within at least 5 seconds. However, one alternative solution is proposed to this problem - asynchronous events.

Continue Reading β†’

Asynchronous and scheduled tasks in Spring

Native Java offers a lot of possibilities to create thread pools, retrieve task results as Future instances. But Spring isn't worse and with its scheduling package allows to work with threads executed in background.

Continue Reading β†’

Google Guava : future chaining and transformation

In one of previous articles we saw that Google Guava provides a listenable futures which are able to invoke callback methods. But it's not theirs single feature.

Continue Reading β†’

Just-in-time compilation in Java

Like some other programming languages, Java is also commonly called "compiled language". However sometimes you may be confused when somebody tells you that Java is JIT compiled.

Continue Reading β†’

Custom filter in Spring Security

Until now we've working with filters belonging to Spring Security project. However we can also add our own custom filters which must only follow some basic rules.

Continue Reading β†’

Effects of bad filter order in Spring Security

Spring Security is based on filter chain. Every filter can be invoked for appropriate request and executed to provide supplementary layer of protection. But one important thing must be respected - filters order.

Continue Reading β†’

Custom namespace parser in Spring

In Spring we can configure dependencies in several ways: with XML files or directly in Java using annotations. This first way is usual considered as clearer and simpler to maintain. And if you're working with it, you certainly met some of Spring XML namespaces, as those one for Spring Security or Spring MVC projects. In this article we'll focus on this aspect of Spring.

Continue Reading β†’