Skip to content

🔥 Simple dependency injection framework in java 🔥

Notifications You must be signed in to change notification settings

nakshay/DepInjector

Repository files navigation

DepInjector

🔥Simple dependency injection framework in java 🔥

This framework is inspired from Spring core framework https://github.com/spring-projects/spring-framework and uses Java Reflection API.

work in progress!

API may change in future.

What is working?

  • Creating instance via Injector#inject('id'), fully qualified class name must be present in config file

Ex.

Injector injector = new DepInjector("resources/config.xml");

MyClass instance= (MyClass)injector.inject("myclass");

  • Creating instance by using @Instance Annotation and getting the object via Injector#inject('id'), here id must be equal to ClassName (case sensitve), assigning short id is work in progress

Ex.

AnnotedClass inst = (AnnotedClass)injector.inject("AnnotedClass");

inst.printMessage();

  • Object instantiation via Annotation

Ex.

@Inject

AnotherAnnotedClass annotedInstance;

annotedInstance.printMessage();

To be done.

  1. getting instance by passing class type to inject method to remove parsing step.(not a priority currently)

injector.inject("myclass", MyClass.class);

Dependencies

https://github.com/ronmamo/reflections

P.S. Pull request is appreciated

About

🔥 Simple dependency injection framework in java 🔥

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages