j'ai ce websocket simple,tomcat embarqué avec java ee 7 websocket
@ServerEndpoint(
value="/data",
encoders = {WsCommandEncoder.class},
decoders = {WsCommandDecoder.class}
)
public class DataWebSocket {
//...impl
}
et j'initialiser mon tomcat intégré dans la fonction principale
public static void main(String[] args) throws Exception{
Tomcat tomcat = new Tomcat();
tomcat.setPort(6000);
//how do i add the websocket to my tomcat instance?
String webDir = "/web";
tomcat.addWebapp("/", new File(webDir).getAbsolutePath());
System.out.println("configuring app with basedir: " + new File("./" + webDir).getAbsolutePath());
tomcat.start();
tomcat.getServer().await();
}
Je n'ai jamais utilisé tomcat embarqué auparavant, il y avait généralement le web.xml mais je ne veux pas utiliser webxml et je veux ajouter le point final directement dans le code, alors comment ajouter le websocket à mon instance de tomcat?
J'utilise Tomcat 8.0.9 et java ee 7
i avait l'air ils étaient tous sur l'ajout servelets, pas d'exemples WebSocket – FPGA
Alors vous n'avez pas l'air très dur. http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/tomcat/websocket/TestWsRemoteEndpoint.java?view=annotate –