Java Reference
In-Depth Information
Creating our first endpoint
Let's start with a simple example:
package com.packtpub.wflydevelopment.chapter8.boundary;
import javax.websocket.EndpointConfig;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
public class HelloEndpoint {
public void open( Session session, EndpointConfig conf)
throws IOException {
Java EE 7 specification has taken into account developer friendliness, which can be clearly
seen in the given example. In order to define your WebSocket endpoint, you just need a
few annotations on a Plain Old Java Object ( POJO ). The first annotation @Server-
Endpoint("/hello") defines a path to your endpoint. It's a good time to discuss the
endpoint's full address. We placed this sample in the application named ticket-
agency-websockets . During the deployment of application, you can spot information
in the WildFly log about endpoints creation, as shown in the following command line:
02:21:35,182 INFO [io.undertow.websockets.jsr] (MSC service
thread 1-7) UT026003: Adding annotated server endpoint class
for path /hello
02:21:35,401 INFO
[org.jboss.resteasy.spi.ResteasyDeployment] (MSC service
thread 1-7) Deploying class
Search WWH ::

Custom Search