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.
Continue reading “Accessing prototype bean in singleton”
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.
Continue reading “Multiple TTL caches in Spring Boot”
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.
Continue reading “Spring 4.3 recap for API-centric apps”
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.
Continue reading “Spring Boot properties per Maven profile”
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.
Continue reading “Dual jar/war build for Spring Boot”
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.
Continue reading “SharePoint Web Services, Spring, and NTLM authentication”