Spring internals #2: Implementing our own JSON Application Context

Aleksei Novikov
5 min readFeb 26, 2023

In this article, we will implement our own application context based on JSON configuration.

ApplicationContext class is an entry point into Spring’s DI container. The functionality of this class is described in the previous article. So, let’s get started.

First of all, we should what we want from our implementation. To not overcomplicate our example, we define our requirements like this:

  • the application context should be described as a JSON file stored in the classpath of the application
  • the JSON file should describe a set of beans
  • every bean description should contain the bean’s name, class name, and init method

So, we bootstrap a simple gradle project with dependencies:

plugins {
id 'java'
}

group = 'me.alekseinovikov'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '17'

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework:spring-context:6.0.5'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.2'
}

We just added spring context dependency for spring DI and application context functionality and Jackson for JSON parsing purposes.

--

--