I'm further confused by this. The custom-resolver example in the source
does this...
@Inject
private HttpRequest request;
The problem with that, is that it's a singleton, and you could have
synchronization issues, thereby share user data in different requests.
I've taken a quick look at the HK2 source, and I do not see any
synchronization over injecting into a resolver and then calling it, which
is why there's no guarantee that "request" is in fact the one related to
the current HttpRequest.
Am I missing something in the code? I know the code is quite complex, so I
might be.
On Wed, Apr 20, 2016 at 5:30 PM, Trenton D. Adams <trenton.d.adams_at_gmail.com
> wrote:
> According to the documentation, custom injection resolvers do not need to
> be of the Singleton scope. But there's code in HK2 that forces them to be
> in that scope. Is this a design problem, or a documentation problem?
>
> https://hk2.java.net/custom-resolver-example.html
>
> It says...
> The AlternateInjectResolver is in the @Singleton context, which is the
> usual context for implementations of InjectionResolver
> <https://hk2.java.net/apidocs/org/glassfish/hk2/api/InjectionResolver.html>.
> In general however implementations of InjectionResolver
> <https://hk2.java.net/apidocs/org/glassfish/hk2/api/InjectionResolver.html> may
> be in any context.
>