Maybe, but with the jersey one I can increment an instance variable each
call, and it keeps going up. So won't that happen with the request object
as well, it'll get the request object for another user?
Really, what I'm trying to do, is create a session aware injection
resolver, so I can have my own annotations with metadata. As it is, I'm
not seeing any way of getting my annotation metadata to a factory, so
factories don't appear to be able to do what I need. So, if the injection
resolver is sharing instance data, I can't use it that way.
On Thu, Apr 21, 2016 at 6:34 PM, john wells <john.wells_at_oracle.com> wrote:
> You may be confusing the HttpRequest implemention in the example with the
> one from Jersey. The one from Jersey is in a proxiable scope. The thing
> actually injected is a proxy, basically a shell around the true
> implementation, which is changed behind the scenes whenever the request is
> modified.
>
> As far as documentation over code, I'd have to look at the example again
> and make sure it is still correct, sometimes things change and we don't
> always get all the places in the documentation that cover that specific
> behavior.
>
> Hope that helps!
>
>
> On 4/21/2016 2:07 AM, Trenton D. Adams wrote:
>
> 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.
>>
>
>
>