Monday Mar 24, 2014

Tyrus 1.5 released! Just in time for Java 8

1i=1njiλeλ2λ=1i=1ne(n1)λ2n1=1ne(n1)λ2n1


A new version Tyrus 1.5 (reference implementation of JSR 356 WebSockets API), was released. With it you get of course bug fixes and improvements, but most importantly a runtime fix on Java 8! And a few more things: 

 Going back to the JDK 8 issue, the good thing is that Tyrus 1.5 fixed the support of inherited annotated methods. If you are curious about this, go check Pavel Bucek's weblog post about the new Tyrus 1.5 release. Oh and if you want to know what's up with the math function above, since you are a WebSocket developer you may want to know what is the probability of two people will talk at the same time.

Cheers! 

Tuesday Jan 28, 2014

Using updated release of Jersey, Tyrus, Weld, ... in GlassFish 4

The Java EE specification is an umbrella specification that refers to different components specifications, aka components JSRs (e.g. Servlet, JMS, JAX-RS, ...). And as the Java EE 7 Reference Implementation, GlassFish 4 is made of those different components JSRs Reference Implementations. 

In addition to the specification, most of those implementations (eg. Jersey) also offers additional features (and fixes). And clearly, the different implementations that make GlassFish are evolving each at a different pace. Jersey (JAX-RS RI), Tyrus (WebSocket RI), Weld (CDI RI), Mojarra (JSF RI) are examples of implementations that evolves rapidly. GlassFish 4.0 embeds Tyrus 1.0, Jersey 2.0, Mojarra 2.2.0 and Weld 2.0.0.SP1 but since that time, those implementations have evolved quite a lot. As of today, the current release of Tyrus is 1.4, the current release of Jersey is 2.5.1, the current release of Weld is 2.0.5 and the current release of release of Mojarra is 2.2.5.

So what to do if you want to use one of the new features provided by one of those implementations in GlassFish 4? One way is to wait that the specific version of that implementation, say Jersey for example, is integrated in a nightly build of the GF 4.0.1 branch. Another solution is to upgrade the specific implementation (e.g. Jersey) in an existing GlassFish 4 setup. The following posts explains how to update Tyrus, how to update Jersey, how to update Weld and how to update Mojarra in a GF4 setup. 

It should be mentioned that no extra testing has been done, so clearly do not do this in any critical environments. And if the updated setup is not stable, it is always easy to come back to the initial configuration. Most of the time, it's just a matter of putting back the original implementation Jar and restarting GlassFish. For Jersey, the provided update script is able to restore the initial configuration if needed. 
Also, since Jersey has dependencies on HK2 and since HK2 has been updated between GF 4.0 and the 4.0.1 branch, it is only possible to update Jersey in a GlassFish 4.0.1 build.

In any cases, if you are using GF 4 with an updated version of Tyrus, Jersey, Mojarra or Weld, we would like to hear your feedback!

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).

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 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.

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.