Skip to content

nakshay/DepInjector

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
bin
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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