Showing how to use @Websocket to register a WebSocket handler in
Eclipse Dirigible.
sample-java-websocket-decorator/ # Dirigible project (registry path)
└── demo/
└── websocket/
├── ChatHandler.java # @Websocket — registers "java-chat" endpoint
└── WebsocketStatus.java # @Controller — reports whether the handler is registered
Drop this project into the Dirigible IDE (clone via the Git perspective and publish, or copy it
to /registry/public/sample-java-websocket-decorator/). The synchronizer compiles ChatHandler.java
and registers it in JavaWebsocketRegistry. Verify via:
GET /services/java/sample-java-websocket-decorator/demo/websocket/WebsocketStatus/status
Returns {"registered": true} when the "java-chat" endpoint is active.
Two ways to write a Java WebSocket handler — pick one per @Component class (never both), like Spring:
- Strong interface —
ChatHandleris a@Componentthat implementsWebsocketHandlerand supplies its ownendpoint()(likeTextWebSocketHandler); no@Websocketannotation. - Method-level annotations —
TickerHandleris a@Websocket(endpoint = …)class with@OnOpen/@OnMessage/@OnClosemethods (Jakarta@ServerEndpointstyle — the endpoint has no method-level home).
See the Develop guide and the Java SDK.