When migrating a legacy project to dependency injection based on Spring you often need dependencies to be injected found in legacy code which has no Spring support. This library provides class path scanning to create bean definitions for typical singleton and factory patterns found in legacy code. You may also access Spring beans from legacy code.
To use a singleton bean from a Spring context, you should obtain it using
LegacySpringAccess.getSpringBean()
.
Have a look into the example and how it is used in the
integration test. The usage has to be prepared using a Spring
configuration including the LegacySpringAccess
which can be easily
imported from your own configuration.
Instead of directly access legacy singletons from new code, you should use DI as provided by Spring. To support this, register all singletons from legacy code as Spring beans. The post processor is configured using a static bean method in your config. Have a look into the example and how it is used in the integration test.
To integrate the library in your project, add the artifact spring-legacy
of group de.diergo
to your Java dependency
management. At JitPack you can find examples for Gradle and Maven.
The library has no external dependencies except Spring Framework (spring-context starting with 5.3.0). For the release notes, have a look at the change log.
This library is published under Apache License Version 2.0.