Skip to content
/ mikron Public

A minimalistic microkernel, IoC container for dependency injection and configuration externalization.

License

Notifications You must be signed in to change notification settings

reevik/mikron

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build License JDK Release Javadocs

Mikron is a minimalistic web-free IoC container for dependency injection and externalized configuration management for Java. To use the Maven-based project, you can add the following dependency:

<dependency>
  <groupId>net.reevik</groupId>
  <artifactId>mikron</artifactId>
  <version>${latest}</version>
</dependency>

Usage

You will use Mikron annotations to initialize the Mikron context in your Java application. In the following example, we declare a "Mikron Application" by using @ManagedApplication annotation, and instantiate the Mikron context. MikronContext is the implementation of IoC container, where managed instances reside:

@ManagedApplication(packages = {"your.package.to.scan"})
public class Main {

  public static void main(String[] args) {
    Optional<AnnotatedManagedClass> instance;
    try (MikronContext context = MikronContext.init(Main.class)) {
      instance = context.getInstance(AnnotatedManagedClass.class.getName());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}

Mikron context is the container where the managed instances reside and the dependencies between managed objects get wired. You will use @Managed annotation to declare managed instances:

@Managed
public class ManagedObject {

  @Configurable(name = "config.temp")
  private Integer temperature;

  @Wire
  private ManagedDependency managedDependency;
}

and the @Wire annotation introduces dependency injection point whereas @Configurable annotation is used to inject externalized configurations.

Documentation

You can check out the Mikron Wiki for the documentation and API Docs.

Bugs and Feedback

For bugs, questions and discussions please use the GitHub Issues.

LICENSE

Copyright 2024 Erhan Bagdemir

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

A minimalistic microkernel, IoC container for dependency injection and configuration externalization.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages