If you are using CDI in your project and if you are using it in such a way that there are circular dependencies:
You are likely to end up with issues like:
@Singleton @AC
class A {
@Inject @DC D d;
}
@Singleton @DC
class D {
@Inject @AC A a;
}
org.jboss.weld.exceptions.DeploymentException: WELD-001443: Pseudo scoped bean has circular dependencies. Dependency path:
You can go ahead and use the javax.inject.Provider to resolve these issues in such a way.
Then you may get the instance of Class A within any method of D as follows:
@Singleton @AC
class A {
@Inject @DC D d;
}
@Singleton @DC
class D {
@Provider Provider<A> a;
}
Then you may get the instance of Class A within any method of D as follows:
A aInstance = a.get();
This way you can solve circular dependency issues of such nature.
No comments:
Post a Comment