Tuesday Feb 04, 2014

Java SE 8 and Java EE 7

"Revolutions just spread blood. Evolution - this is something that changes in the long term." (Marjane Satrapi

Java SE 8 is scheduled for release next month, i.e. March 2014. From a Java EE point of view, the Java EE 7 specification requires at least Java SE 7. So clearly, nothing prevents you from using Java SE 8 with Java EE 7. A lot of us are in fact using early builds of Java SE 8 with GlassFish on a daily basis without any problem!

Project Avatar, which currently runs on top of GlassFish 4 (and Java SE 8), leverages one of the new Java 8 feature : Project Nashorn, a new lightweight high-performance JavaScript engine. 

The introduction of Lambdas Expressions is another key feature of Java 8. Lambdas basically add Closures support to the Java language, they allows to pass functionality as an argument to another method. Lambdas are seen as one of the most fundamental evolution in the Java platform since Generics (if not more important than Generics!). Lambdas leads to a different way of thinking, a different (and cleaner) way of writing code.

Java EE developers shouldn't wait and need to learn how to use Lambdas Expressions today as they are not incompatible with Java EE 7. Here is, for example, a post from Gerard Davison of the JDeveloper Team that shows Lambdas used with the WebSocket API.

If you are using Lambdas or any other Java SE 8 feature(s) today in Java EE, please let us know!

Monday Jan 27, 2014

Tyrus/WebSocket Client on Android

At JavaOne San Francisco 2013 Ryan Cuprak, Bala Muthuvarathan and I presented a full-house session titled Android and iOS Development with Java EE 7. Ryan is the leader of the Connecticut JUG, a close friend and my co-author on the upcoming second edition of EJB 3 in Action. Bala is a friend and former colleague from CapTech Consulting. We picked the topic as we thought there was surprisingly little content on the topic despite the fact that many people use JAX-RS/Java EE as a mobile back-end platform today and Java EE 7 is an even stronger candidate for this development model. You can check out video for the event below. The demo code for the session is available on GitHub and the slide deck is available on SlideShare. One of the surprising things we came across is that Android still has very weak support for WebSocket development. As a result, I thought it would be great if the WebSocket client APIs standardized in Java EE 7 would work on Android, so I entered a JIRA issue against Tyrus asking for such support.

Some of you might be very pleasantly surprised that the Tyrus team actually addressed the issue! You can read the details of the initial work on Pavel Bucek's blog, including a sample application. If you find the feature useful, I would encourage you to explore the work further, share your thoughts on the Tyrus mailing list or via JIRA. You could even contribute to the sample code for the JavaOne talk :-) (currently the code uses the Autobahn Android library).

Wednesday Jan 08, 2014

Java EE@JogloCon

On December 27th, I did a virtual session via Google Hangout on the Java API for WebSocket (JSR 356) for JogloCon 2013. Organized by JUG Joglosemar, JogloCon is one of the largest Java conferences in the Yogyakarta area of Indonesia. This year, the conference focused on everything Java EE! Yosi Pramajaya and Deny Prasetyo of the JUG Joglosemar did an excellent job putting the conference together. This was JUG Joglosemar's first event after it's resurrection in 2013. The event was a full-house with over 200 registering. Enjoy the slideshow below of the conference:


Created with flickr slideshow.

The slide deck for my talk is available here. You can also take a look at the video of WebSocket specification lead Danny Coward's JavaOne 2013 talk on Parleys.com:

Let's hope to see great things from JUG Joglosemar, Yosi Pramajaya and Deny Prasetyo in the New Year!

Thursday Jan 02, 2014

Java EE@Peru JUG

On December 19, I did a virtual meetup via Google Hangout with the Peru JUG on the Java API for WebSocket (JSR 356). The relatively young Java user group is led by it's very capable leader Jose Diaz. Heather VanCura of the JCP was very kind in connecting the dots for this meeting (the Peru JUG is an active participant for Adopt-a-JSR). My colleague Bruno Borges also helped plan the event. Even despite the Holiday season, the meeting went quite well. In absence of the of the regional JavaOnes, virtual meetups like this one are a very effective way of engaging our global community. The video capture of the virtual meetup is below. The slide deck is available here.

Do drop me a note if you, your company or your JUG is interested in having a similar virtual meeting on any Java EE related topic. As daunting as it may initially sound, virtual meetings are surprisingly easy, hiccup free and still relatively personable.

Tuesday Dec 31, 2013

Using Socket.IO with the Java API for WebSocket?

If you have looked into how to use WebSocket with emergent JavaScript frameworks like Angular, Backbone, Ember or Knockout, it's very likely you've come across Socket.IO. While Socket.IO is a very useful library, it is mostly geared towards Node.js and significantly different from plain WebSockets as defined by the IETF and the W3C as well as the JCP/JSR 356 (the Java API for WebSocket). However, with a little bit of hacking, it's not too hard to get the Socket.IO client library to work with the Java API for WebSocket.

Lee Chuk Munn from the Advanced Technology Applications Practice for the National University of Singapore, Institute of Systems Science describes the problem space well and shows you how to hack a basic solution. Chuk plans on working on a framework that builds a more complete solution to marry Socket.IO and JSR 356. He used GlassFish 4 and NetBeans 7.4 for his work. Does this inspire you to hack a framework on top of JSR 356, join Chuk in his efforts or contribute to the GlassFish community in the New Year :-)?

Wednesday Dec 18, 2013

Want to Work on WebSocket/Tyrus? Oracle is Hiring!

The WebSocket team at Oracle is looking for another key contributor! If you want to become part of the dynamic, high-profile team that is working on the industry leading Java API for WebSocket (JSR 356) reference implementation Tyrus and related open standards, projects and products like Java EE, GlassFish and WebLogic, this is the time to update your resume/CV and share it with us. The job is based in Prague, Czech Republic.

The formal details of the job are on LinkedIn.

If you are interested and have any questions, please feel free to post your questions here, get in touch with the Tyrus team or drop an email directly to pavel dot bucek at oracle dot com.

Monday Dec 16, 2013

Java EE@Pune JUG

Pune JUG organized a meetup at the Symbiosis Institute of Computer Studies and Research (SICRSR) college campus on December 14th. Led by Harshad Oak (Java Champion and organizer of the IndicThreads conference), Pune JUG is the oldest JUG in India and boasts a vibrant developer community. This month's meetup was focused on the Java EE 7 platform and the ecosystem that is building up around it. The meeting was led by Oracle India's own Vijay Nair. Vijay is a good friend and a lead developer with Oracle's FLEXCUBE development group in India. Among many other things like evangelizing Java EE at local Java user groups and conferences, Vijay contributes heavily to the Cargo Tracker Java EE Blue Prints project in his spare time.

 The event saw an attendance of close to around 100 people with a lot of demos/code and high quality interactions with the audience. Vijay presented no less than three sessions at the meetup:

  • JavaEE.Next(): Java EE 7, 8, and Beyond - This is basically our flagship talk at the moment. The talk briefly covers the evolution of the platform, details the changes in Java EE 7 and invites developers to help shape Java EE 8. The materials for the talk is posted here.
  • Android and iOS Development with Java EE 7 - This was a fairly popular technical session at JavaOne San Francisco 2013 led by me, Ryan Cuprak and Bala Muthuvarathan. The session demonstrates how Java EE 7 acts as an excellent platform for building "headless" back-ends for native mobile applications with REST and WebSocket as the client communication protocols. The materials for the talk is posted here. The code is posted on GitHub.
  • Using NoSQL with JPA, EclipseLink and Java EE - This session explores the current state of the NoSQL landscape and how Java EE can be utilized to access NoSQL solutions such as Oracle NoSQL, MongoDB, Cassandra, etc utilizing JPA style facades or plain CDI. The materials for the talk is posted here. The code is posted on GitHub.

Overall, this was a very positive experience with developers giving two thumbs way up to the Java EE 7 platform!

Monday Nov 25, 2013

Asynchronous clients integration with Java EE 7

"The client is not always right." (Enzo Ferrari)

Integrating clients with a back-end server may pose some challenges as it involve a mix between asynchronous and synchronous behaviour and data exchange.

The 'communication related APIs' of Java EE 7 APIs have all some asynchronous capabilities, e.g. JAX-RS 2.0, WebSocket 1.0 , JMS 2.0, Servlet 3.1, JAX-WS 2.2. In his 'JavaFX Integration Strategies' article, Adam Bien explain some strategies to easily integrate JavaFX clients with a back-end using some of the asynchronous capabilities of Java EE 7. The article also illustrate how to push information from the server to the client using WebSocket.

The article uses JavaFX as the client side UI framework but the patterns and strategies described are not necessarily JavaFX specific and are easily applicable to almost any types of client. As Adam says "REST and JSON become the new, least common denominator for communication with HTML5 clients, Java applications, and even low-level devices.". Finally, the article also illustrate how Java SE 8 Lambda leads to a cleaner code.

Friday Nov 22, 2013

Optimized WebSocket broadcast

"When you have to make a choice and don't make it, that is in itself a choice."  (William James)  Tyrus logo

The Java API for WebSocket (JSR 356) is one of the API added to Java EE 7. It is a '1.0' release, that means that the API is complete and fully functional. It is often said that premature optimisation is the root of all evil, so an initial implementation can easily be optimised. The same is also true for features, choices had to made as it is impossible to implement all the desired features in an initial release. Clearly, they are different aspects that could easily be improved going forward.

Tyrus serves as the JSR 356 Reference Implementation, it is also a test-bed for potential new WebSocket features and improvements. As always, a proprietary feature of an implementation doesn't necessarily means that this particular feature will be included in a future revision of the specification. It could just remains a proprietary feature or an implementation specific optimisation.

In this post, Pavel Bucek, a Tyrus team member, discuss how a WebSocket Server Endpoint could be improved when it needs to broadcast a message to its connected remote endpoints. In Tyrus 1.3, a new broadcast() method has been introduced, it allows to broadcast a message by re-using the same data frame for all the remote endpoints, by doing so the overall performance should be improved.


Wednesday Nov 13, 2013

Tyrus 1.3 Released

Tyrus, the WebSocket 1.0 reference implementation included in GlassFish and WebLogic, released version 1.3 a few days ago. The release contains some valuable features like asynchronous handling of the client-side connectToServer method call, optimized broadcast support and lots of stability and performance improvements (listed below).

One issue that popped up a little too late for getting into 1.3 is TYRUS-263: Accessing SSL protected resource via HTTP proxy. This regression is already fixed in the Tyrus master branch, please let us know whether you consider this feature critical. It might be possible to release 1.3.1 just with this fix.

Tyrus 1.3 is already integrated into GlassFish trunk, so is included in the nightly releases. You can also just remove all tyrus related jars and replace it with the contents of the websocket-ri-archive artifact.

Below is a list of JIRA entries incorporated into Tyrus 1.3:

  • TYRUS-71: ErroCollector not properly used in AnnotatedEndpoint class.
  • TYRUS-262: @OnOpen fails for programmatically deployed annotated endpoint.
  • TYRUS-261: Text decoder disables Binary decoder if both are configured for the same server endpoint; endpoint cannot receive binary messages anymore.
  • TYRUS-248: Consolidate Extension representation
  • TYRUS-258: Tyrus always creates HTTP session
  • TYRUS-251: DecodeException is not passed to @OnError method
  • TYRUS-252: encoder for primitive types cannot be overridden
  • TYRUS-250: Sec-WebSocket-Protocol header cannot be present when there is no negotiated subprotocol
  • TYRUS-249: WebSocketContainer MaxSessionIdleTimeout is not propagated to Session (server side)
  • TYRUS-257: Async timeout value set on WebSocketContainer is not propagated to RemoteEndpoints (Session#getAsyncRemote())
  • TYRUS-253: DecodeException is not passed to @OnError method from session.getAsyncRemote().sendObject
  • TYRUS-243: WebSocketContainer.connectToServer can block for seconds
  • TYRUS-227: Build failure : AsyncBinaryTest
  • TYRUS-226: Tyrus build error : OnCloseTest
  • TYRUS-247: Make all samples use TestContainer for tests
  • TYRUS-238: Refactor WebSocketEngine (SPI and Impl)
  • TYRUS-157: Submitting tasks to an injected ManagedExecutorService in a ServerEndpoint does not work
  • TYRUS-137: Improve subprotocols/extensions headers parsing
  • TYRUS-133: Some Broadcast(er) API is needed in order to opmtimize chat-like usecases
  • TYRUS-245: ServerEndpointConfig#getConfiigurator returns Configurator not used when getNegotiatedExtensions has been called
  • TYRUS-240: clean up duplicated static fields (strings)
  • TYRUS-230: When Session is invalidated, the close reason is not 1006
  • TYRUS-190: Remove TyrusServetServerContainer (merge with TyrusServerContainer)
  • TYRUS-65: Implement common utilities for testing
  • TYRUS-242: Tyrus does not run on JDK8 compact2 profile
  • TYRUS-237: RemoteEndpoint.Async#sendBinary does not throw IllegalArgumentException when data is null
  • TYRUS-239: Improve WebSocketEngine ByteBuffer handling
  • TYRUS-232: Refactor grizzly/servlet container – Tyrus-SPI
  • TYRUS-235: Fix findbugs errors in tests/servlet
  • TYRUS-234: Remove support for older protocol version
  • TYRUS-229: Session#setMaxIdleTimeout() will kill the session whether or not the session actually timed out
  • TYRUS-225: Invalidation of (Servlet) HttpSession does not invalidate WebSocket Session
  • TYRUS-153: Static map in TyrusRemotEndpoint
  • TYRUS-201: Wrong ServletInputStream#isReady() usage in TyrusHttpUpgradeHandler
  • TYRUS-224: Refactor Connection#write and ConnectionImpl to use CompletionHandler only (no Future)
  • TYRUS-221: wss:// doesn’t appear to function correctly via a http proxy
  • TYRUS-146: Support request from client to secured services (“wss”)
  • TYRUS-223: Message can be writen multiple times when running on Servlet container

Besides trying the release out, you should feel equally free to file new JIRA entries on Tyrus and the rest of the GlassFish codebase for that matter.

Tuesday Nov 12, 2013

Java Developer Days India Trip Report

October 21st through October 25th I spoke at Java Developer Days India. This was three separate but identical one-day events in the cities of Pune (October 21st), Chennai (October 24th) and Bangalore (October 25th). For those with some familiarity with India, other than Hyderabad these cities are India's IT powerhouses.

The events were focused on Java EE. I delivered five sessions on Java EE 7, WebSocket, JAX-RS 2, JMS 2 and EclipeLink/NoSQL. The events went extremely well and was packed in all three cities. More details on the sessions and Java Developer Days India, including the slide decks, posted on my personal blog.

Tuesday Oct 15, 2013

Securing WebSocket Endpoints

As you know, WebSocket is a key capability standardized into Java EE 7. When I talk to developers, many wonder how WebSockets are to be secured. One very nice characteristic for WebSocket is that it in fact completely piggybacks on HTTP. This means that all the well-understood ways of securing web applications instantly applies to WebSocket including SSL/TLS, Basic Authentication, Digest Authentication, LDAP, role based authorization and all the robust security infrastructure built into modern application servers like GlassFish and WebLogic. In a brief blog post, Pavel Bucek demonstrates how to secure WebSocket endpoints in GlassFish using TLS/SSL. Besides the server-side, he also includes a secure client side code example using the wss: protocol.

For a more complete example, you could look at the code for my joint JavaOne 2013 session with Ryan Cuprak and Bala Muthuvarathan titled "Android and iOS Development with Java EE 7". Do let me know if you need more detailed coverage focused on the topic, I will be happy to put something together on my personal blog.

Thursday Aug 29, 2013

WebSocket Command Line Client for Testing

As many of you know, being able to do some simple integration/developer testing is invaluable in developing Web Services - WebSocket is no exception. You can use rich GUI based interfaces like soapUI to do this for SOAP and REST (there's also the compact but excellent rest-client UI dedicated to REST). Because it's so new, there aren't many good clients to test WebSocket endpoints with quite yet. Fortunately, Tyrus 1.1 comes with a pretty handy command line client that you can use for testing (it of course has other uses too such as monitoring). Pavel Bucek briefly describes the client here.

There's also a GUI driven simple WebSocket client extension for Chrome. It's similar to the popular Postman REST client extension for Chrome.

Do you know of any other/better options for WebSocket testing? Better yet, you could write a Java based WebSocket client UI yourself and share it with the community :-).

Friday Aug 23, 2013

Java EE@JavaDay Taipei 2013

JavaDay Taipei 2013 was held at the Taipei International Convention Center on August 2nd. Organized by Oracle University, it is one of the largest Java developer events in Taiwan. This was another successful year for JavaDay Taipei with a fully sold out venue. In addition to Oracle speakers like me, Steve Chin and Naveen Asrani, the event also featured a bevy of local speakers including Taipei Java community leaders. Topics included Java SE, Java EE, JavaFX and mobile.

I delivered a keynote on Java EE 7 (our flagship talk) as well as a talk on WebSocket/JSR 356. More details on the sessions and JavaDays Taipei, including the slide decks and code, posted on my personal blog.

Monday Jul 29, 2013

OSCON Trip Report

OSCON 2013 was held from July 22 to July 26 in Portland, Oregon. I presented the Java EE 7 hands-on lab there as well as a session on WebSocket/JSR 356. This was my first time to the revered conference.

OSCON was a unique and valuable experience. I would definitely look forward to doing it again some time. More details, including slide decks, lab materials and code examples, posted on my personal blog.