It’s not sheer coincidence or a random choice that the default scope in Spring is the singleton. The vast majority of business logic in our applications is placed in stateless objects, which thanks to the lack of state can be safely reused across the whole code base. However, sometimes some data needs to be stored between sequential calls to object’s methods. In that case we need to have more control over the life cycle of such object. Spring provides us with several scopes which live shorter than singletons and perfectly fit for short term data storage. The problem appears when you try to inject such scoped bean into a singleton. This post describes the possible options to access shorter living object inside these that reside in the container for longer periods. Although all examples will focus on a prototype inside a singleton, presented information applies to other scopes as well.
Spring Framework provides a comprehensive abstraction for common caching scenarios without coupling to any of supported cache implementations. However, declaration of expiration time for a particular storage is not a part of this abstraction. If we want to set Time To Live of a cache, the configuration of the chosen cache provider must be tuned. From this post you will learn how to prepare setup for several Caffeine caches with different TTL configurations.
Although built-in validation support in Spring is largely sufficient for standard use cases, sooner or later every developer runs into a situation when the sets of validation annotations provided by JSR 303 or Hibernate Validator are not enough. In this post you will learn how to create a simple constraint annotation served by a custom validator with access to the Spring context of a Spring Boot application.
The Spring framework is the most widely adopted open source project in enterprise class applications. As the framework consists of dozens of modules, every team is interested only in a subset of changes introduces in the latest release. This post covers the list of new features that shouldn’t be missed by any developer whose application’s API relies on Spring 4 and is preparing for the upgrade in the foreseeable future.
Sending an e-mail from the backend application part is a quite common use case in the world of enterprise applications. Although HTML content isn’t standardized message format, numerous mail clients support at least a subset of the markup language. In this post you will learn how to send an e-mail using standard Spring Boot modules and prepare HTML content for a message using Thymeleaf template engine.
In the previous post you could read about separate Spring Boot builds for a local development machine and public environments. It’s highly possible that in addition to such setup you would like to load different Spring properties files based on the active Maven profile. In this note you will learn how to accomplish the desired result in a few easy steps.
The great thing about Spring Boot is no need for an external servlet container. All that is needed reside inside a single runnable JAR file. In a very few steps, development of a new application can be started without installation or configuration of any additional software. Yet, sometimes you might want to deploy your application to some server as a regular WAR file. For instance, you convert an existing application and want to keep your continuous delivery pipe untouched or a particular container is enforced by a company’s policy. The reason for building a WAR file may vary across teams, but for development purpose a simple executable JAR file with an embedded server might be preferable.
SharePoint is widely known among .NET developers, but not so recognized in the group of JVM worshippers. Yet, sometimes integration between these two universes is required and one of possible choices to perform the connection is the set of SOAP web services exposed by the platform. It this article you’ll learn how to communicate your Spring application with a SharePoint instance.