One of the newer features introduced in JAX-RS 2.0 is the support for validating resource classes with Bean Validation
Bean Validation support comes in Jersey 2.x by adding jersey-bean-validation module to the class-path.
The following sample shows how to use Bean Validation with JAX-RS 2.0. I show how to define a custom constraint which will validate any Enum class.
Additionally I will show...
on Oct 30, 2013
Since Mojarra is available as a standalone JAR you can opt to update your Glassfish installation with a newer version. How would you do that? Well it is simple.
Make sure your Glassfish container is not running
Grab the latest JAR from http://repo1.maven.org/maven2/org/glassfish/javax.faces/
Replace the javax.faces.jar in the modules directory of your Glassfish directory with the downloaded JAR...
on Oct 29, 2013
Developing RESTful Services with JAX-RS 2.0, WebSockets, and JSON is the new book which Masoud Kalali and I have worked on and recently published.
As the technology landscape moves focus towards smaller devices, the need for building scalable, flexible, lightweight, and real-time communications-based applications grows.
HTML 5 and Java EE 7 provide a new synthesis of technologies that...
on Oct 18, 2013
javax.servlet.http.HttpSession provides a way to identify an user across multiple HTTP requests and to store user specified information. In other words, it provides a support of stateful communications with the stateless HTTP protocol.
For security and memory management, sessions need to be invalidated at a certain time. There are two related methods in HttpSession.
on Aug 29, 2013
Java API for WebSocket is a new JSR to Java EE 7. It provides a stardard Java API for creating WebSocket applications. This gives web applications the ability to push data.
In Java EE 6 samples, we added a chat room sample to illustrate how to use of Servlet 3.0 asynchronous operation. In that sample, the servlet code did the following:
keep track of AsyncContext in a Queue
create a thread to...
on Aug 13, 2013
JSR 356: Java API for WebSocket provides a standard Java API for creating WebSocket Applications. The specification provides an API for...
on Aug 7, 2013
Expression Language (EL) was first introduced as part of JSTL 1.0, was then moved JSP 2.0 and was unified with JSF 1.2 in JSP 2.1. In Java EE 7, EL is a new separate JSR, JSR 341. Many new features are introduced in EL 3.0.
This blog shows how to use new following new features of EL 3.0:
Lambda expression (section 1.20 of EL 3.0 spec)
The new operator ; to separate...
on Jul 1, 2013
Asynchronous operation was introduced in Servlet 3.0. ServletRequest#startAsync is used to put the request into asynchronous mode. A thread need to be created implicitly or explicitly (see here for an example).
Servlet 3.1, JSR 340 includes clarifications in asynchronous area. Besides Servlet 3,1, Concurreny Utilities for Java EE 1.0, JSR 236 is introduced in Java EE 7. JSR 236 provides a...
on Jun 6, 2013
Update: In Servlet 3.0, the behavior of using response is undefined after invoking #complete or #dispatch. In Servlet 3.1, it is clarified that AsyncContext#getResponse will throw IllegalStateException. The blog has been updated for this.
Asynchronous operation is supported in Servlet 3.0. I have discussed startAsync in my previous blog, startAsync in Servlet 3.0. In this blog, I will discuss...
on May 14, 2013
Update: Invoke WebConnection#close when there is an error.
Servlet 3.1 Specification (JSR 340) is almost ready for the release. One of the new features is the support for protocol upgrade.
HTTP protocol upgrade was introduced in HTTP 1.1 (RFC 2616):
The Upgrade general-header allows the client to specify what additional communication protocols it supports and would like to use if the server...
on May 7, 2013
Servlet 3.1 Specification (JSR 340) and Java Authorization Contract for Containers (JSR 115) MR3 are almost ready for release. Besides "*", the role-name "**" is introduced in the above two specifications.
In a nutshell, "*" means any role defined in web.xml and "**" means any authenticated user.
Prior to Servlet 3.1, web containers use proprietary mechanisms to add security-constraints for any...
on Apr 19, 2013
Servlet 3.1 Specification (JSR 340) is almost ready for the release. Several new security features have been added in this version of Servlet specification.
In this blog, I will explain one of the security features, namely deny-uncovered-http-methods.
Let us take a look at a simple security-constraint in web.xml as follows:
<web-app xmlns="http://www.w3.org/2001/XMLSchema" ...
on Apr 19, 2013
Update: One should not use response in AsyncListener#onComplete. Only print debug in this example.
Servlet 3.1 (JSR 340) is almost ready for the release. One of the new features is the support for non-blocking IO. ReadListener and WriteListener are introduced to allow non-blocking processing in Servlet.
Non-blocking IO can only be used in async (defined in Servlet 3.0) or the upgrade mode. We can...
on Apr 16, 2013
#How to run the dev test cases
All of the test cases can't be ran on the windows platform because the firefox can't support the ajax and JSF based on the windows platform very well. If you want to ran the tests, please check out all of the codes to the linux, ubuntu or mac platform.
1). Download the firefox and install it, On my platform, I...
on Oct 14, 2013
Last week, JFrog's online software binaries repository Bintray was made available to the public. What's Bintray? JFrog's announcement calls it "the first social platform for developers to publish, download, store, promote, and share software libraries (binaries) across a unified community." One way of looking at Bintray is that it's a "GitHub for binaries."
Bintray already has some major...
on Apr 1, 2013
My JavaOne 2013: Wrapup
This blog entry summarizes my session participation at JavaOne 2013. I plan to update this entry with links to the content on Parleys.com as it becomes available.
Sessions I Attended
In general, speaking more than listening is a very bad way to live. I find this holds true at conferences as well. Here are the sessions I attended. I attended eight and presented six, so I...
on Oct 1, 2013
Table of Contents
8:30am - Functional Reactive Programming with RxJava
10:00am - The JVM is dead! Long live the Polyglot VM!
1pm - invokedynamic in 45 minutes
3pm - Wholly Graal - Java on GPU
5:30pm - Experimenting with the Boundaries of Static Typing
7:30pm - Developing Small Languages with Scala Parser...
on Sep 24, 2013
At the JavaOne 2013 Java Technical Keynote, there was a series of demos of software that enables two people to play chess, using some of Java's latest features, including Java EE 7 Websockets, many variations of Java 8 (recent weekly builds), Lambda Expressions, Java ME, Embedded Java, ... It was an impressive demo of many of Java's recently-released and not-yet-finally-released capabilities,...
on Sep 23, 2013
Java User Groups
Looking Forward to JavaOne Sunday: JUG Forums, NetBeans Day, GlassFish, Technical Keynotes, Duke's Choice Awards
It used to be that Sunday was a fairly relaxing day for most. Not anymore! This year, Sunday is already overcrowded with many more events and sessions than one can possibly attend, as the JavaOne 2013 Content Catalog Sunday entries demonstrate.
Sunday's activity can be divided into...
on Sep 22, 2013
Java Web Services and XML
Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface. JAX-RS provides a standardized API for building RESTful web services in Java. This example will show how to...
on Sep 16, 2013