Thursday Jan 09, 2014

Some Tyrus updates


Project Tyrus is the JSR 356 (Java API for WebSocket) Reference Implementation. As JSR 356 is part of Java EE 7 (Web Profile and the Full Java EE Platform), Tyrus is embedded in GlassFish 4. In addition, Tyrus *should* also run on any Servlet 3.1 compatible container.

Tyrus 1.0 was released mid 2013 when the JSR 356 specification went final. Since then, the work on Tyrus hasn't stopped and this is also true for other implementations such as Jersey for JAX-RS, Mojarra for JavaServer Faces, etc. For example, no less than 2 updates of Mojarra were released this week (2.2.5 & 2.1.27) but more on JSF later and back to Tyrus...

Here are some of features and improvments that were recently added to Tyrus :

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!

Friday Jan 03, 2014

Getting Started with EL 3

EL 3 is one the APIs that has gone through a major overhaul in Java EE 7. In fact, EL is now finally a specification on its own right after long being an important API for JSTL, JSP, JSF and CDI. Most folks in the ecosystem are just beginning to realize the full significance of this. EL 3 opens up the possibility of using the power of a standard expression language in new and innovative ways in frameworks and applications much like the way Bean Validation 1.1 now utilizes EL. Just some of the changes in EL 3 includes a stand-alone API, powerful new operators, static field and method references, lambda support (essentially ahead of Java SE 8) and much, much more. Servlet 3.1 specification lead Shing Wai Chan handily demonstrates how some of the EL 3 features fit together in an excellent blog post. The code example calculates a standard deviation three different ways using various EL 3 features inside a Servlet. The blog post is really a great place to get started with learning EL 3. You can also check out Ed Burns and Kin-man Chung's JavaOne 2013 session on EL 3 via Parleys:

The slide deck for the session is available on the JavaOne content builder. It may be particularly interesting to relate the content of the slide deck back to Shing Wai Chan's blog entry.

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 :-)?

Friday Dec 27, 2013

A Realistic JSF 2.2 Faces Flows Example

While very basic introductory examples are invaluable in explaining a new API, they can fail to do a rich API justice - especially from the perspective of more experienced developers. For some of us, looking at a slightly more involved, realistic example can shed far better light on the practical value proposition for a technology.

Faces Flows are one of the best hidden gems in Java EE 7. Standardized in JSF 2.2 they enable web application flow state management in an elegant, declarative fashion. In an excellent blog post, Liferay Faces project lead and JSF 2.2 expert group member Neil Griffin takes an in-depth look at Faces Flows. He explains the motivation for the feature, contrasts it with the Java EE 6/CDI 1.0 conversation scope and demonstrates the feature using a very realistic use case and non-trivial example code. There's also the video of Ed Burns and Roger Kitain's JavaOne 2013 JSF 2.2 talk on Parleys.com:

The source slide deck for the talk - titled JSF 2.2 New Features in Context is posted on the JavaOne Content Catalog. Make sure to check out the other great JavaOne 2013 sessions on Parleys.com too!

Monday Dec 23, 2013

Java EE@Oredev 2013

Oredev 2013 was held on 4-8 November in Malmo Sweden. This was my second time at the largest IT conference in the Scania region - I had been there in 2010 as an independent. This year it attracted a decent section of the Java crowd including my fellow Oracle colleagues Brian Goetz, Geertjan Wielenga, Attila Szegedi, Aleksey Shipilev, Cecilia Borg, Marcus Hirt and Tomas Nilsson as well as independent Adam Bien. Topics covered included Java EE, mobile, DDD, agile, HTML5, cloud, Java SE, OpenJDK, JavaScript and NoSQL.

I delivered a full day workshop on Java EE 7 and a technical talk on JAX-RS 2, both of which went well. More details on the sessions and Oredev, including the slide deck and code, posted on my personal blog.

Thursday Dec 19, 2013

JSF 2.2 New Features in Context

"If the smaller characters are well-written, the whole world of the film becomes enriched. 
It's not the size of the thing, but the detail." 
(Brendan Gleeson)

A lot of airtime is spent on the APIs that were added to Java EE 7 (e.g. WebSocket) and APIs that went through a major revision (e.g. JMS 2.0 or JAX-RS 2.0). But let's not forget that a lot of others APIs have been revised in Java EE 7 and this sometime implies new features, new capabilities.

In this JavaOne session, Roger Kitain and Edward Burns who are both Specification Leads for JavaServer Faces, explains in details some of the important features that were added to JSF 2.2 (e.g. Faces Flow, HTML5-friendly markup, Resource library contracts). Those new features are explained in detail and demonstrated in the context of a self-contained sample application. Ed and Roger also shows that JSF is still relevant in today's enterprise software stack, they finally compares the benefits of upgrading to JSF 2.2 against opting for a totally new architecture.

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!

Wednesday Dec 11, 2013

'Come and Play! with Java EE 7' in London!

"The French and the British are such good enemies that they can't resist being friends."
(Peter Ustinov)

Our friends of the London GlassFish User Group are planning their next event on the 9th of January 2014. For that occasion, Antonio Goncalves (Paris JUG, Devoxx France, Java EE EG Member, author...) will dare to cross the Channel to talk on Java EE 7.


'Come and Play! with Java EE 7'

As you know, Java EE is old-fashioned, heavyweight, cumbersome, and made mostly of boilerplate code. Who would develop a modern Web application with such a technological stack? Who would start a heavy application server, deploy some EJBs, and wait ages for integration tests to run - only to end up with an ugly Web page?

If you like HTML5 front ends with responsive design, sexy graphical components, manageable REST interfaces, easy asynchronous processing, reliable messaging, and transactional databases, come to this session to see two developers writing and testing a real Java EE 7 Web application within 1 hour.

More info can be found here.

Monday Dec 02, 2013

Asynchronous session beans and 'Concurrency Utilities for Java EE API'

"It's true hard work never killed anybody, but I figure, why take the chance?" (Ronald Reagan)

There are different approaches to obtain an asynchronous behaviour within a Java EE application, this post cover 2 of them.

Asynchronous Session Beans, added in EJB 3.1 (Java EE 6), is one possible solution. The @Asynchronous annotation is used to decorate session bean methods that should be invoked asynchronously. When such a bean method is invoked, the control returns to the invoking client before the container dispatches the invocation to an instance of the bean. This allows the client to continue processing in parallel while that particular session bean method performs its operations. In EJB 3.2 (Java EE 7), Asynchronous Session Beans are now part of EJB Lite and as such are even more widely available.

Another approach is the use the new Concurrency Utilities for Java EE API (JSR 236) which was added to Java EE 7. The goal of this JSR is simple, i.e. it allows to safely use some of Java SE's java.util.concurrent.* features within a Java EE context. So if you are familiar with some the JSR166 features (e.g. ExecutorServices), you can now re-use the same features in a managed Java EE environment.

Mohamed Sanaulla recently wrote different posts explaining how to use the different JSR 236 Managed Objects : ManagedExecutorService, ManagedScheduledExecutorService and ManagedThreadFactory.

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.


Monday Nov 18, 2013

JMS2@London GlassFish User Group

Some of you may be aware that the London GlassFish User Group got launched a few months ago. The group is organized and sponsored by C2B2 Consulting. C2B2 continues to offer GlassFish support and C2B2 Technical Director Steve Millidge recently offered his pretty level-headed reaction to the discontinuation of Oracle commercial support for GlassFish - it's worth reading for perspective.

The Manchester, UK based JMS 2 specification lead Nigel Deakin recently led a session in the group on the new JMS 2/Java EE 7 features in GlassFish 4. The video for the talk is posted below. There's also my own slide deck on JMS 2 posted on SlideShare (with source PDF and abstract).

Do consider inviting Nigel to give a JMS 2 talk if you are relatively local to him. Also, consider supporting the group if you are local to it. More recently, Nigel presented a JavaOne 2013 technical session titled Easier Messaging with JMS 2.0 as well as a Birds-of-a-Feather session titled What’s Next for JMS?. Stay tuned to Parleys.com for video of the sessions to be posted (the slide decks are already posted on the linked JavaOne Content Catalog).

Friday Nov 15, 2013

MOXy is the New Default JSON-Binding Provider in GlassFish 4

When I talk about JAX-RS 2, JSON-P and Java EE 7 a surprising number of people seem to assume that GlassFish and Jersey does not support JSON binding and just supports lower level JSON processing. It is in fact correct that Java EE 7 has standardized JSON processing (via JSON-P) but not a JSON binding API yet (although such a standardized API is a very strong consideration for Java EE 8 and would build upon the JSON-P work). However Jersey, the popular JAX-RS reference implementation, has long had strong support for JSON binding via MOXy, Jackson and Jettison (now it also has support for JSON-P of course). In fact, in GlassFish/Jersey the default JSON binding provider is MOXy. If you are not familiar with MOXy, it is a very interesting project part of EclipseLink (the JPA reference implementation) that translates JAXB annotations to JSON. In a code driven post, Blaise Doughan of the Oracle EclipseLink team explains the details of using MOXy with JAX-RS in GlassFish.

For more details on Jersey's support for JSON, you should check out the very well-written documentation.