Monday Apr 29, 2013

JSR 356, Java API for WebSocket

A new article, now up on otn/java, by Java Champion Johan Vos, titled “JSR 356, Java API for WebSocket,” shows developers how to integrate WebSockets into their applications. JSR 356, part of the Java EE 7 platform, specifies the API that Java developers can use when they want to integrate WebSockets into their applications on both on the Java server and client side. The API is highly flexible, and frees developers to write WebSocket-based applications independent of the underlying WebSocket implementation, thus preventing vendor lock in. It also allows for more choice in libraries and application servers. Web clients or native clients leveraging any WebSocket implementation can more easily communicate with a Java back end.

As part of the Java EE 7 standard, all Java EE 7-compliant application servers will have an implementation of the WebSocket protocol that adheres to JSR 356. Vos explains:

“Once they are established, WebSocket client and server peers are symmetrical. The difference between a client API and a server API is, therefore, minimal. JSR 356 defines a Java client API as well, which is a subset of the full API required in Java EE 7….

The Java API for WebSocket is very powerful, because it allows any Java object to be sent or received as a WebSocket message.

Basically, there are three different types of messages:

* Text-based messages
* Binary messages
* Pong messages, which are about the WebSocket connection itself

When using the interface-driven model, each session can register at most one MessageHandler for each of these three different types of messages.

When using the annotation-driven model, for each different type of message, one @onMessage annotated method is allowed. The allowed parameters for specifying the message content in the annotated methods are dependent on the type of the message.”

Check out the article here and learn how to integrate WebSockets into your applications.

Tuesday Oct 18, 2011

The Heads and Tails of Project Coin

JavaOne 2011 - Joseph Darcy, Member of the Oracle Technical Staff, spoke to a very large,
packed conference room in his “The Heads and Tails of Project Coin” (22641) session Tuesday.
Project Coin, a central part of Java 7, was described by Darcy as “a suite of language and
library changes to make things programmers do everyday easier.”

Project Coin makes life easier by removing extra text to make programs more readable;  
encouraging the writing of programs that are more reliable; and by integrating well with past and future changes.
Darcy emphasized that these are small language changes related to specification, implementation and testing;
there are no JVM changes. Project Coin was written to coordinate with forthcoming larger language changes.

Project Coin has strong IDE support:
• IntelliJ IDEA 10.5 and later                                                                                                
• Eclipse 3.7.1 and later                                                                                                                  
• NetBeans 7.0 and later

The six Project Coin features are:  
• Binary literals and underscores in literals                                                                                
• Strings in switch                                                                                                                          
• Diamond                                                                                                                                     
• Multi-catch and more precise rethrow                                                                                
• try-with-resources                                                                                                               
• Varargs warnings

Diamond and varargs warnings enable easier-to-use generics. Multi-catch and try-with-resources allow for more concise error handling. Strings-in-switch and literal improvements result in greater consistency and clarity.

Darcy proceeded to demonstrate five of the six Project Coin features to a highly engaged audience.
Check out his session slides and you can also view this talk @ http://parleys.com/d/2663.

What’s ahead for Project Coin in Java 8? Look for very small language changes on the horizon.

About

Insider News from the Java Team at Oracle!

duke
javeone logo
Links


Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
2
5
6
7
12
13
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today