On Tue, Apr 9, 2019 at 3:56 AM Christopher Dodunski <
chrisfromtapes...@christopher.net.nz> wrote:

> public class CdiAwareConfigurator extends
> ServerEndpointConfig.Configurator {
>
>     public <T> T getEndpointInstance(Class<T> endpointClass) throws
> InstantiationException {
>         return CDI.current().select(endpointClass).get();
>     }
> }
>
>
> Does the Tapestry 5 IoC/DI layer also support acquiring of an instance of
> a ServerEndpoint service class?  This seems to be the approach of several
> other frameworks.
>

It seems to be the other frameworks don't support ServerEndpoint classes
directly. Instead, the examples are just picking the endpoint object from
the other IoC frameworks. If your VesselTrackerService instance to be used
by the WebSocket endpoint isn't going to be shared with Tapestry pages OR
it doesn't keep state, you can use the examples you posted here, but
adapting them to Tapestry-IoC to just instantiate the Registry itself and
get the service instance through registry.getService(). For Tapestry pages,
the Registry is started up by TapestryFilter. Otherwise, follow the
documentation here:
https://tapestry.apache.org/starting-the-ioc-registry.html. Example:

Registry registry = RegistryBuilder.buildAndStartupRegistry(OneModule.class,
EndpointModule.class, ...);
YourEndpoint endpoint = registry.getService(YourEndpoint.class); //
YourEndpoint uses VesselStateTracker



> 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