Skip to content

sabomichal/spring-injector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Maven Central

spring-injector

A fast alternative to the Spring @Configurable magic.

Do you need to inject spring beans into non managed e.g. domain objects? Are you tired of slow aspectj compilation or load-time weaving? Then spring-injector is the solution.

This project is based on the Spring Injector from Apache Wicket project.

Usage

In order to inject dependents into any object just call SpringInjector.get().inject(this). And that's it!

public class DependentComponent implements Serializable {
	private static final long serialVersionUID = 1L;

	@Inject
	private InjectedComponent injectedComponent;

	public DependentComponent() {
		SpringInjector.get().inject(this);
	}

	public int answer() {
		return injectedComponent.answer();
	}
}

See the test classes for more detailed use case.

If you like it, give it a star, if you don't, please write an issue.