lecousin.net Java framework - injection

Dependency injection functionalities

License

License

Categories

Categories

Net
GroupId

GroupId

net.lecousin.framework
ArtifactId

ArtifactId

injection
Last Version

Last Version

0.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

lecousin.net Java framework - injection
Dependency injection functionalities
Project URL

Project URL

https://github.com/lecousin/java-framework-injection
Source Code Management

Source Code Management

https://github.com/lecousin/java-framework-injection

Download injection

How to add to project

<!-- https://jarcasting.com/artifacts/net.lecousin.framework/injection/ -->
<dependency>
    <groupId>net.lecousin.framework</groupId>
    <artifactId>injection</artifactId>
    <version>0.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/net.lecousin.framework/injection/
implementation 'net.lecousin.framework:injection:0.2.1'
// https://jarcasting.com/artifacts/net.lecousin.framework/injection/
implementation ("net.lecousin.framework:injection:0.2.1")
'net.lecousin.framework:injection:jar:0.2.1'
<dependency org="net.lecousin.framework" name="injection" rev="0.2.1">
  <artifact name="injection" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.lecousin.framework', module='injection', version='0.2.1')
)
libraryDependencies += "net.lecousin.framework" % "injection" % "0.2.1"
[net.lecousin.framework/injection "0.2.1"]

Dependencies

compile (1)

Group / Artifact Type Version
net.lecousin : core jar 0.15.0

test (3)

Group / Artifact Type Version
net.lecousin : core test-jar 0.15.0
junit : junit jar 4.12
org.apache.commons : commons-math3 jar 3.2

Project Modules

There are no modules declared in this project.

lecousin.net - Java framework - Injection

This library provides dependency injection functionalities.

It depends on the net.lecousin.core library mainly for parsing configuration files.

An object to inject can be a singleton, or using a factory. When using a factory, a new object is created by the factory each time it needs to be injected.

When an object needs to be injected, it can be injected

  • by ID: by specifying the ID of the object or the factory
  • by type: we look for an object matching the given type, and inject it

In addition, conditions can be given to specify when an injectable object (or factory) is eligible, based on properties. For example, a production implementation can be injected when a property is set to 'PROD', else a mock implementation can be injected.

An injectable object can also declare an initialization method to be called once it is instantiated and its dependencies have been injected if any.

Injection is done in an Injection Context, a context being composed of:

  • Properties, that can be used in a configuration file or in the @InjectableWhen annotation
  • Singletons, which are instances of objects ready to be injected
  • Factories, which can be used to create an instance each time an object needs to be injected
  • An optional parent context. If it has a parent, a context inherits from its content.

Build status

Current version - branch master

Maven Central Javadoc

build status build status Codecov

Development branch

build status build status Codecov

Versions

Version
0.2.1
0.2.0
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0