users@tyrus.java.net

Re: _at_Inject question

From: Ray Jenkins <ray.jenkins_at_gmail.com>
Date: Tue, 14 Jan 2014 12:39:16 -0800

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
>
>
>