DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • How To Validate Archives and Identify Invalid Documents in Java
  • How To Check Office Files for Macros Using Java
  • How to Automatically Detect Multiple Cybersecurity Threats from an Input Text String in Java
  • How To Get the Comments From a DOCX Document in Java

Trending

  • Apache Flink
  • DevSecOps: Integrating Security Into Your DevOps Workflow
  • Securing Your Applications With Spring Security
  • Monkey-Patching in Java
  1. DZone
  2. Data Engineering
  3. Databases
  4. Java WebSocket API: Difference Between Endpoint and RemoteEndpoint

Java WebSocket API: Difference Between Endpoint and RemoteEndpoint

Wondering the differences between Endpoint and RemoteEndpoint? Here's a look at the class , which represents a WebSocket endpoint, and the interface.

Abhishek Gupta user avatar by
Abhishek Gupta
CORE ·
Nov. 26, 15 · Analysis
Like (4)
Save
Tweet
Share
5.85K Views

Join the DZone community and get the full member experience.

Join For Free

If you encounter the Endpoint and RemoteEndpoint artefacts from the Java WebSocket API for the first time, you might think they represent the same concept or you might even guess that they are hierarchical in nature. It is not the case.

javaee-logowebsocket_logo

Endpoint: The Class

javax.websocket.Endpoint is a simple (abstract) class which represents a WebSocket endpoint itself – either a server or a client endpoint. The Java WebSocket API itself provides both annotation and programmatic APIs to develop and design endpoints. An annotation based endpoint can be developed with the help of the following annotations

  • @ServerEndpoint or @ClientEndpoint
  • @OnMessage
  • @OnClose
  • @OnMessage and
  • @OnError

When you deploy an annotated WebSocket endpoint using Tyrus (WebSocket Reference Implementation), it internally creates an instance oforg.glassfish.tyrus.core.AnnotatedEndpoint which extends (and implements the abstractonOpen method)

tyrus-annotated-endpoint-impl

In case you want to use the programmatic API, you would need to extend the Endpoint class and override the (abstract) onOpen method yourself.

RemoteEndpoint: The Interface

WebSocket is just a protocol using which two parties (client and server) communicate.javax.websocket.RemoteEndpoint is an abstraction which represents the entity at the other end. It is available is two avatars

  • Synchronous: RemoteEndpoint.Basic
  • Asynchronous: RemoteEndpoint.Async

A RemoteEndpoint instance is encapsulated within the javax.websocket.Session object and can be obtained using the getBasicRemote or getAsyncRemote methods (for sync and async operation respectively). Here is the Tyrus implementation – org.glassfish.tyrus.core. TyrusRemoteEndpoint

Cheers!

API WebSocket Java (programming language)

Published at DZone with permission of Abhishek Gupta, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How To Validate Archives and Identify Invalid Documents in Java
  • How To Check Office Files for Macros Using Java
  • How to Automatically Detect Multiple Cybersecurity Threats from an Input Text String in Java
  • How To Get the Comments From a DOCX Document in Java

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: