Reputation: 3046
I'm a new Guice user, having been a long-time user of Spring IoC. I have a number of @Singleton
classes for my service tier, which I understand is roughly equivalent to Spring's default bean scope.
However, when I am using @Inject
in my Wicket pages a CGLib proxy of the target objects is created each time the page is constructed, thus creating new instances of my supposed-singletons.
Note that I'm injecting concrete classes, not interfaces.
How can I use @Inject
and retrieve the single singleton instance of my Guice-injected objects?
Updated: Solution as per Sven's accepted answer
Inject interfaces in Wicket components rather than concrete classes. Despite much discussion on the subject in the linked thread, this appear to be the only practical solution.
Upvotes: 1
Views: 422
Reputation: 5681
The following issue gives some background:
https://issues.apache.org/jira/browse/WICKET-1130
Upvotes: 1