On Tue, Apr 9, 2019 at 10:07 PM Christopher Dodunski <
chrisfromtapes...@christopher.net.nz> wrote:

> Thank you very much for responding Thiago.
>

You're welcome!


> Perhaps my understanding of the problem is wrong, so please feel free to
> correct me.  My endpoint service is configured to be autobuilt by the
> bind() method in AppModule in the same way as other services I've created,
> so I'd be surprised if Tapestry-IoC isn't recognising it as such.


I believe you're wrong here. Tapestry-IoC is recognizing it as such. Your
endpoint class instance which isn't being taken from Tapestry-IoC.


> What Isuspect is happening is that Tomcat, on receiving a WebSocket
> connection
> request, is instantiating my endpoint but OUTSIDE of the Tapestry
> application's context, meaning not only that any injected services never
> get realised (they remain null),


That's correct. Being pedantic, I'd say that Tomcat isn't using the
endpoint instance created by Tapestry-IoC.


> but also any class (static) field values
> don't get shared across all instances of the endpoint class (those within
> the registry versus those not).
>

Static fields in Java are basically global variables, but actually aren't,
but I guess this isn't working for you because you have live class
reloading turned on (it's on by default) for your endpoint service. Live
class reloading works by creating new versions (i.e. java.lang.Class
instances), so you set the static fields of one version, but then another
was actually being used.


> So my solution was to have Tomcat get endpoint instances from the
> Tapestry-IoC registry rather than instantiate them itself.  Hence the idea
> of a custom Configurator, where I override the getEndpointInstance()
> method to return an endpoint instance from the registry.
>

That's exactly what I suggested in my last e-mail and that's the correct
way of doing it IMHO. :) I guess I didn't explain it very well. :(


>
> Interested in your thoughts on this.
>
> Kind regards,
>
> Chris.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

-- 
Thiago

Reply via email to