tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christopher Dodunski" <ChrisFromSquir...@christopher.net.nz>
Subject Re: Using custom Configurator with WebSockets
Date Wed, 24 Apr 2019 23:48:50 GMT
Thanks Mark, you've made it clear that annotating the interface is not an
option.

Converting my server endpoint from annotation based to programmatic is not
a problem, nor is implementing ServerApplicationConfig to configure what
were previously @ServerEndpoint elements: value, encoders, decoders,
configurator.

What is not clear is how this will solve the problem of Tomcat not
accepting an interface as an endpoint.  Afterall, the programmatic
approach still employs Configurator.getEndpointInstance(), and this is
where I came unstuck with annotations.

Below is the beginnings of my custom ServerApplicationConfig implementation.



public class CustomServerAppConfig implements ServerApplicationConfig {

    @Override
    public Set<ServerEndpointConfig> getEndpointConfigs(Set<Class<?
extends Endpoint>> endpointClasses) {
        Set<ServerEndpointConfig> result = new HashSet<>();
        for (Class epClass : endpointClasses) {
            if (epClass.equals(MyEndpointInterface.class)) {
                ServerEndpointConfig sec =
ServerEndpointConfig.Builder.create(epClass,
"/websocket").build();
                result.add(sec);
            }
        }
        return result;
    }

    @Override
    public Set<Class<?>> getAnnotatedEndpointClasses(Set<Class<?>>
scanned) {
        return Collections.emptySet();
    }
}


Regards,

Chris.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message