Java 9 comes quietly to Java ecosystem and Spring Framework already successfully tested the build on early release on the new Java version. If we add to this the backward compatibility between Java 8, 7 and 6, we could ask us the question: How does it succeed that ?
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.
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.
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.
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.
Through 4 previous articles, we saw that Spring adopts a big number of creational and structural design patterns. They're not so much behavioral ones and it's why we discover two of them in this article, the last one about design patterns used in Spring.
This article is the 4th about design patterns used in Spring framework. It'll present new 3 patterns implemented in this framework.
In two previous articles we saw some of design patterns implemented in Spring framework. This time we'll discover 3 new patterns used by this popular framework.
The last time we talked about design patterns in Spring, we discovered 3 creational and 1 behavioral patterns. This time we'll focus more on structural and behavioral ones.
Design patterns help to follow good practices of programming. Spring framework, as one of the most popular web frameworks, also uses some of them.
Sometimes you will need to share properties values through multiple configuration files. They can, for example, have the same authentication information about database user, but, they can use different databases. In Spring we can resolve this problem with properties placeholders.
Events, and generally callback idea, are very popular in technologies associated to GUI (JavaScript, Swing). On the server side of web applications they're less popular. However it doesn't mean that we can't implement one event-oriented architecture on it. Above all when we're working with Spring.
Annotations in Java let us, programmers, to transfer some of configuration from configuration files into Java classes. For example, in Spring, we can configure URL mapping directly inside the controllers thanks to @RequestMapping annotation. But it couldn't be possible without several utilitary classes, like AnnotationUtils, described here.
We've already discovered the bean post processor factory in Spring. However, they left one similar concept to explain, bean post processors.
Spring allows us to make a lot of operations with beans. We can decide if they should be unique instance on container (singleton) or not (prototype). We can also make some of operations "in the fly", thanks to bean factory post processors.
Dependency injection in Spring facilitates development. You can simply put @Autowired annotation, followed by visibility tag and object, to can use every object managed by Spring context. But beware, all of these objects are a kind of Spring-managed singleton.
Like we already know, application context is the container where Spring-managed beans live. But the question that we didn't ask, is how this context is created ? We'll reply to this question in this article.
Previously we've told that Spring beans were living in application context. In this article we'll develop this idea and present application context more in detail.
Previously we discovered the basics of integration testing in Spring. So now it's a great time to deepen this subject.
Making the code testable is one of the crucial points of maintainable software. Without the tests, the code is exposed to surprising bugs on every change.