users@tyrus.java.net

Re: _at_Inject question

From: <ray.jenkins_at_gmail.com>
Date: Tue, 14 Jan 2014 15:37:11 -0800

That sounds excellent thank you very much for the help will follow up later.

Sent from my iPhone

> On Jan 14, 2014, at 1:24 PM, Pavel Bucek <pavel.bucek_at_oracle.com> wrote:
>
> Well, Jersey currently cannot run without HK2, which acts there as dependency injection container, so @Inject can work. Tyrus does not have anything like that.
>
> You can store your properties to EndpointConfig (see EndpointConfig#getUserProperties()). Endpoint config can be then put as a parameter to @OnOpen method (please have in mind potential synchronization issues when sharing configuration among several connections). Overriding getEndpointInstance is also possible solution, but user properties are simpler to use.
>
> Please let me know whether that worked for you.
>
> Regards,
> Pavel
>
>> On 14/01/14 21:39, Ray Jenkins wrote:
>> Hi Pavel,
>>
>> Thanks for responding., I don't need @Inject per-se, but I would like to be able to pass dependencies into my endpoints somehow, whether by constructor or otherwise
>>
>> Having a look at TyrusWebSocketEngine it looks like you can only register endpoints via
>>
>> public void register(Class<?> endpointClass, String contextPath);
>> or.
>> public void register(ServerEndpointConfig serverConfig, String contextPath)
>>
>> With these methods it looks like instantiation of endpoints is delegated and the only way to override that is to implement a ServerEndpointConfig.Configurator and override the public <T> T getEndpointInstance(Class<T> endpointClass).
>>
>> I am trying to just inject a simple POJO, I'm probably just missing something simple, any suggestions?
>>
>> Here's the project I'm working on https://github.com/rjenkins/ursus @Inject is working for my Jersey resources via the GrizzlyHttpContainer and an AbstractBinder. Would be nice to accomplish the same or have the ability to pass dependencies into ServerEnpoints.
>>
>> Thanks,
>> Ray
>>
>>> On Tue, Jan 14, 2014 at 8:26 AM, Pavel Bucek <pavel.bucek_at_oracle.com> wrote:
>>> Hi Ray,
>>>
>>> @Inject will work only on Java EE container, so Glassfish or WebLogic. Grizzly is lightweight container which provides some basic http request/response parsing and more low level stuff, there is no DI container involved.
>>>
>>> Why do you need @Inject? Isn't there another way how you could solve your issue? What are you trying to inject?
>>>
>>> Regards,
>>> Pavel
>>>
>>>
>>> On 14/01/14 16:56, ray.jenkins_at_gmail.com wrote:
>>>> Hi,
>>>>
>>>> I'm looking for a bit of direction in regards to understanding how Tyrus supports javax.inject.Inject. As per the documentation https://tyrus.java.net/documentation/1.3/user-guide.html#d0e785 Tyrus provides @Inject support. I'm using Tyrus in Grizzly and I'm making use of an instance of TyrusWebSocketEngine to register my @ServerEndpoint classes and can't seem to get Injection working. Could you point me towards where this is implemented?
>>>>
>>>> Thanks,
>>>> Ray
>>>>
>>>> Sent from my iPhone
>