🔥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.
- 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();
- getting instance by passing class type to inject method to remove parsing step.(not a priority currently)
injector.inject("myclass", MyClass.class);
https://github.com/ronmamo/reflections
P.S. Pull request is appreciated