Wednesday Feb 29, 2012

GlassFish 3.1.2 is released!


GlassFish 3.1.2 is here and download it now!

This is the latest and the greatest release for GlassFish 3.x. The three main themes of this release are:
  • Higher Quality: 500+ bug fixes improving the overall quality of 3.1.x and still maintaining backwards compatibility. Several community-filed bugs are fixed in this release.
    • Updated components (see below) alone provide 300+ bug fixes
  • New Features
    • Administration Console Improvements
      • Better startup time and option to load in background after server startup
      • Feature parity with asadmin CLI
      • Enabling and disabling secure administration
      • Viewing and monitoring app-scoped resources
      • Setup SSH and Node installation
      • Configure JMS clusters
      • Consolidation of monitoring data in a single tab
      • Administering Loadbalancer plug-in configurations (only in Oracle GlassFish Server)
    • Improved clustering
      • New DCOM Support for Windows (as an alternative to SSH for remote management of GlassFish instances)
      • Non-Multicast clustering
      • mod_proxy_ajp support
    • Improved EclipseLink integration with EclipseLink MOXy support and TopLink Grid support (Coherence as 2nd level data cache and only in Oracle GlassFish Server)
    • WebSocket (RFC 6455) Support
    • Transaction recovery using database (in addition to the existing file system support)
    • Improved Security (secure admin requires password, Oracle GlassFish Server secure by default with new password required be set during installation or on first use), and SSL Encrypted traffic between the Domain Administration Server and remote instances
    • NetBeans 7.1.1 ships with GlassFish Server 3.1.2 (more samples in NetBeans Update Center)
  • Updated Platforms & Components (in addition to existing platforms, complete supported matrix here)
    • Supporting Mac OSX 10.7.1 and Ubuntu 11.0.4 as developer platform
    • JDKs
      • JRockit 28.2.2
      • JDK 7 U3 and JDK 6 U31
      • IBM/AIX JDK 6
    • Browsers: Chrome 15.x, Firefox 9+, Safari 5.x, IE 7.x+
    • Updated component bundles: JSF/Mojarra 2.1.6, Grizzly 1.9.46, Metro 2.2, Jersey 1.11, Shoal, EclipseLink 2.3.2, OpenMQ 4.5.2, OSGi Core 4.3.0, Update Center, Hibernate Validator, JavaDB 10.8.1.2, Weld 1.1.4

Check out this video by GlassFish 3.1.2 engineering manager providing highlights of the release:

Here are some other pointers for you to get started:

Tuesday Feb 21, 2012

Java EE 6 workshop delivered at Umeå JUG


What's common between Austin (Texas), Reykjavik (Iceland), Stockholm (Sweden), and Umeå (Sweden) ?
  • They all had a Java EE 6 workshop in the past 2.5 weeks
  • All of them had fairly higher attendance than normal/expected
  • Every where the attendees stayed much longer than originally planned
  • The simplicity and power of awesome threesome of Java EE 6, NetBeans, and GlassFish was very well appreciated by the attendees

The recently concluded workshop at Umeå JUG proved yet again how Java EE 6 can easily attract audience. And now that WebLogic and GlassFish are Java EE 6 compatible, there is a wide variety of containers available to deploy your applications.

This JUG, part of Javaforum Sweden, is the second most northern JUG (Reykjavik is the northern most by about 150 km) in a small university town of about 115,000. The constant sub-zero temperature and tons of snow during my stay made the cross-country an interesting first time experience. Running outside in the cold was harder than I originally thought as the cheeks were getting cold and making it difficult to talk. Thank you Jonas for teaching me the basic skills and sharing your spiked running shoes. Quite an enjoyable experience over all!

The interactive attendees learned all about:

  • Improvements in Java Persistence API 2
  • "web.xml"-free and annotation-driven Servlets
  • Simplified packaging of EJBs in a WAR file, no-interface and single file definition of EJB
  • Session preservation across redeploys
  • Facelets (XHTML/CSS) as templating language for JavaServer Faes to achieve true MVC
  • Integration of Bean Validation with JPA and JSF
  • Typesafe dependency injection and Producer/Observer of events using CDI
  • RESTful resources using JAX-RS

The hands-on lab document is available here and the complete application here.

Here is a picture with Jonas and Mattias - the JUG leaders. Their mission is to learn and spread knowledge about Java in Umeå by bringing in speakers from all around the world. A local tech publication (InfoTech Umeå) also talked about the workshop. Here is a picture from the article:


Jonas, Arun,
Mattias at Umeå JUG
(Image Credits: InfoTech Umeå)

And some more pictures from the visit ...





The complete photo album is available at (pictures are from trip to JUGICE and Jfokus)  ...



Next stop 33rd Degree and Codemotion ...

Wednesday Feb 15, 2012

Jfokus 2012 Trip Report


If I were to summarize Jfokus 2012 in two words then they would be - bigger and better!

Bigger because ...
  • 8 tutorials/hands-on lab in 2011 -> 10 in 2012
  • 1 fully booked in 2011 -> 5 in 2012
  • About 1450 attendees, 15% more from 2011
Better because ...
  • Coffee was served all day
  • The best speakers' dinner at a top-notch restaurant. Any body willing to beat that ? Make your speakers feel more special ? ;-)
  • REST interface to the program schedule
  • All-day Java Spotlight
  • Speakers from Brazil, attendees from Morocco,  more international participation (about 15-20% attendees were outside Sweden)
  • Flawless wireless connection, no complaints on #jfokus or elsewhere
  • #jfokus was trending

There were several talks by Oracle speakers. I gave a Java EE 6 hands-on lab and two talks - PaaSing a Java EE Application and The Java EE 7 Platform: Developing for the Cloud.

Again and again the awesome threesome of Java EE 6, NetBeans, and GlassFish continue to attract audience - this time at Jfokus 2012.  Lot more folks showed up for the hands-on lab than originally registered and the conference organizers had to arrange extra table and chairs.


One of the attendees forgot to bring his laptop and connected to a remote server running NetBeans using his Samsung Galaxy S1 smart phone. He built some part of the application that way and then got his laptop during one of the coffee breaks. That was pretty awesome!

The interactive attendees learned all about:
  • Improvements in Java Persistence API 2
  • "web.xml"-free and annotation-driven Servlets
  • Simplified packaging of EJBs in a WAR file, no-interface and single file definition of EJB
  • Session preservation across redeploys
  • Facelets (XHTML/CSS) as templating language for JavaServer Faes to achieve true MVC
  • Integration of Bean Validation with JPA and JSF
  • Typesafe dependency injection and Producer/Observer of events using CDI
  • RESTful resources using JAX-RS
Most of the attendees stayed for the 3.5 hrs long workshop. Several folks gave positive feedback afterwards and suggestions on some troubleshooting tips. The following bugs were filed/followed upon:
  • 190988 (Refactor fields of an existing entity class to an Embeddable class)
  • 203659 (Generate new lines between fields of a JPA entity)
  • 208355 (Injecting a POJO shows a warning message)
  • 205392 (Change the default RESTful URL to /webresources or /restful - will be fixed in 7.2.
The revised hands-on lab document is available here and the complete application here.

Many thanks to Markus Eisele for helping me with the lab!

The slides for "PaaSing your Java EE Application" are available below:

This session explained different components of GlassFish to provide a standards-based PaaS platform. There were about 25 attendees in this 9am session.

And the slides for "The Java EE 7 Platform: Developing for the Cloud" are available below:



This session gave an overview of the Java EE 7 platform. It also gave a quick preview of Early Drafts from JAX-RS 2.0, JavaServer Faces 2.2, Enterprise JavaBeans 3.2, and Contexs and Dependency Injection 1.1. There were about 200+ attendees in this session.

The Java Spotlight podcast #69 had six different Java Champions - Jonas Boner, Stephan Janssen, Chris Richardson, Mattias Karlsson, Fabiane Nardon, and Bert Ertman talked about "Is Java Dead ?", "How is Oracle doing with the Java community ?" and similar topics.



The opening keynote by Jurgen Holler reminded me of the famous quote by Gandhi:

First they ignore you
Then they laugh at you
Then they fight you
Then you win

I think we are at the last but one stage :-)

IMHO product pitches and negative campaigning (feels like Republican party primaries back home) should be strictly avoided from such conferences (not for the keynote at least) otherwise they leave a bad taste!

Check out some more pictures from the conference ...








Even though it snowed overnight yesterday and a little bit this morning as well but I managed to get a run in the city



The city certainly has tons of running/biking trails and they look beautiful covered with snow!

An evolving album is available at (the first few pictures are from the trip to JUGICE and then Jfokus)  ...




Also watch a lovely set of photos by Markus Eisele:



The returning speakers at Jfokus are only 7% in contrast with other big Java conferences such as JavaOne, Devoxx, and W-JAX. I've already attended two years in a row so guess getting into the smaller percentage already ;-)

Next stop Umeå and finally home ...

Sunday Feb 12, 2012

Java EE 6, NetBeans, and GlassFish workshop at Reykjavik, Iceland


The JUGICE normally has about 10-25 attendees, and once again, the awesome threesome of Java EE 6, NetBeans, and GlassFish attracted about 50+ attendees in Reykjavik, Iceland.



The interactive attendees learned all learned about:
  • Improvements in Java Persistence API 2
  • "web.xml"-free and annotation-driven Servlets
  • Simplified packaging of EJBs in a WAR file, no-interface and single file definition of EJB
  • Session preservation across redeploys
  • Facelets (XHTML/CSS) as templating language for JavaServer Faes to achieve true MVC
  • Integration of Bean Validation with JPA and JSF
  • Typesafe dependency injection and Producer/Observer of events using CDI
  • RESTful resources using JAX-RS
Most of the attendees stayed for almost 4 hrs long workshop. Several folks gave positive feedback afterwards and tweets like this are much more explicit about it:



Almost everybody could complete all the exercises, which was definitely satisfying. Most importantly I coached them on how to debug errors and got them little more comfortable in NetBeans and GlassFish. Some folks were even asking for the next level of workshop already. I'd love come back in Summer to enjoy the Icelandic hospitality!

I had an interesting discussion with a J2EE-to-Spring-converted architect on the benefits of Java EE 6 over Spring. Stay tuned on that and I'll post more details in a few days :-)

Check out some more pictures from the workshop ...






The attendees helped me clarify the document further and the revised document is available here and the complete application here.

I also had some good discussions with Reynir Hubner, the marvelous and extremely hospitable JUGICE leader. He is the CTO at Eplica and also the Vice President of Reykjavik Cycling Club. We had some interesting talks about cross training. He took me around Golden Circle and to Blue Lagoon.

And some more pictures from the stay ...










Some interesting facts about Iceland ...
  • The country has about 300k people with two-thirds living in Reykjavik metro.
  • Even though its close to Arctic circle, the temperature is still relatively warm because of the Gulf Stream.
  • Fishing, Aluminium smelting, Tourism, and Geothermal power are the primary industries.
  • One of the first countries to have a democratically elected female head of state.
  • The landscape is vast, diverse (lava, craters, snow, lakes, glacier, geysir to name a new), and beautiful (some pictures).
  • Team handball is the national sport and other sports are popular too. Icelanding wrestling (Glima) is a particularly interesting one!
  • The heat bill is received yearly because of the widespread usage of geothermal power.
  • Iceland is all green, Greenland is all icy (more here)
  • Very low crime rate in Iceland is proven by the fact that the country's name does not even exist in this list for 2010 and this shows 0 murder per 100k for the year 2008. The country has no Army, Navy, or Air Force and only has a Coast Guard. The only folks carrying guns is the Viking Squad which is about 50 cops in the entire country.
  • Everybody talks in terms of before and after the 2008 financial crisis.
  • The roof colors in Reykjavik are very bright and vibrant and is by design. I guess this might be to complement the gray sky which is prominent all through out the year ;-)
  • CrossFit Games overall runner up is Annie Thorisdottir, an Icelander.
  • 66 o North is a common brand that sell outer wear for all weather. No such thing as bad weather, just need to be properly dressed.
  • If you fly Iceland Air over Atlantic then you can take a 7-day stopover in Iceland without any additional cost.
  • Icelandic horses are short but neve call them pony. More about them at www.icelandichorsefestival.is.
  • Check the latest weather conditions from vedur.is instead of weather.com
And finally the complete set of pictures from Reykjavik and an evolving album of the trip of Nordics trip so far ...



Next stop JFokus ...

Saturday Feb 11, 2012

Pictures from Golden Circle, Iceland - Þingvellir, Gullfoss, Geysir, Strokkur, and Kerið


After a very interactive and successful Java EE 6 workshop (more on that later), Reynir, the esteemed Iceland JUG leader, took me out for a trip of Golden Circle in Iceland covering Þingvellir, waterfall Gullfoss, Haukadalur which contains the geysers Geysir and Strokkur, and a volcanic crater Kerið.

Þingvellir is home to the largest natural lake in Iceland. It is also one of the unique places in the world where tectonic plates between North America and Eurasia plates can be clearly seen in the faults, otherwise they are mostly deep under the water.

"Geysir" is the first known geyser and even the English word "geyser" is derived from it. It was quite a surreal experience to watch the now dormant geyser. However Strokkur which is about 50 m south still erupts any where between 2-8 minutes.

Check out some pictures below:

















Thank you Reynir for the wonderful trip!

Friday Feb 10, 2012

Running in Reykjavik, Iceland


How do runners explore a new country ?

Yep, by running!

That's exactly what I did after sleeping for about 2.5 hrs during San Francisco/Boston/Reykjavik night :-) Met an ex-Sun colleague who arranged a wonderful trail run by Ellioa River and Atlantic Sea. The river is the largest river to run through Reykjavik and is well known for fishing salmon during summer. There was still sopme residual snow, from last week's storm, on the trail and of course water was all over. We also experienced some hail towards the end of the run but a quick ride to the hotel and a warm shower was a great ending.

Here is the running route that we followed:


And some pictures from the trail:








Running seems to becoming more main stream in Reykjavik. Each swimming pool has a "hlaupakort" (running map) posted near the entrance with routes marked in different lengths. The 3 most frequented pools in the downtown area are Laugardalslaug, Sundhöllin, and Vesterbær. There is no way to reach out the running groups except the last one has a presence here. Generally the rule is just show up in running clothes and look for the spandex-clad group stretching. Learn more about running meetups in Reykjavik in this thread. There is even a 1/2 Ironman in July and a full marathon in August and . Read more about running in Reykjavik here.

Thank you Kristinn for arranging the run and Agust for showing me the trail!

Now to Java EE 6 workshop tomorrow morning ...

Tuesday Feb 07, 2012

JAX-RS 2.0 Early Draft Explained - Java EE 7 Making Progress


JAX-RS 2.0 Early Draft has been available for about 3 months now. JAX-RS 2.0, just like JPA 2.1, was one one of the first JSRs to be filed as part of Java EE 7. Several other specifications in Java EE 7 have released early drafts as well (JavaServer Faces 2.2CDI 1.1, EJB 3.2, and more coming as well) and I'll cover them in later blogs.

Here are the topics covered so far:
JAX-RS 2.0 is a brand new specification and here are the main highlights so far:
  • Client API: The HTTPUrlConnection is too low level and is not RESTful-oriented. Invoking a RESTful resource using this class would look like:

    URL url = new URL("http://.../atm/balance");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setRequestMethod("GET");
    conn.setDoInput(true);
    conn.setDoOutput(false);
               
    BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String line;
    while ((line = br.readLine()) != null) {
        out.println(line);
    }


    Notice, how much code has to be written and its brittle. Some JAX-RS 1.0/1.1 implementations already provide a higher-level client-side API to access the Web resources. For example, read TOTD #57 for more details about Jersey Client API. A slightly more advanced sample to access Twitter timeline using Jersey Client API is described in TOTD #143.

    JAX-RS 2.0 introduces a standard Client API to in javax.ws.rs.client package to access the Web resource. It also share features with JAX-RS server API (readers/writers).

    A simple usage looks like:

    Client client = ClientFactory.newClient();
    String balance = client.target("http://.../atm/balance")
                           .request("text/plain")
                           .get(String.class);


    Instead of Client client = ClientFactory.newClient(), would you like @Inject Client client then vote for JAX_RS_SPEC-170.

    Path and query parameters can be easily specified using the builder pattern as shown below:

    Client client = ClientFactory.newClient();
    String balance = client.target("http://.../atm/{card}/balance")
                           .pathParam("card", "1111222233334444")
                           .queryParam("pin", "1234")
                           .request("text/plain")
                           .get(String.class);


    See how the template in the target path is automatically substituted with the correct value. The request type is specified to be "text/plain" and GET method of this web resource is invoked. This will be translated to:

    http://.../atm/1111222233334444/balance?pin=1234

    A POST request will look like:

    Money balance = client.target("http://.../atm/{card}/withdraw")
                          .pathParam("card", "1111222233334444")
                          .queryParam("pin", "1234")
                          .request("application/json")
                          .post(text("50.0"), Money.class);

    There is also generic command pattern that enables separation of concern between the creator and submitteruseful for batch processing using Invocation. And the code would look like:

    Invocation inv1 = client.target("http://.../atm/{card}/balance")
                            .pathParam("card", "1111222233334444")
                            .queryParam("pin", "1234")
                            .request("text/plain")
                            .buildGet();


    Invocation inv2 = client.target("http://.../atm/{card}/withdraw")
                            .pathParam("card", "1111222233334444")
                            .queryParam("pin", "1234")
                            .request("application/json")
                            .buildPost(text("50.0"));

    And once the Invocations are ready then they can be invoked.

  • Filters and Handlers: The filters and handlers allow app developers to perform message request pre-processing and response post-processing via well-defined extension points on the client- and server-side. This is yet another feature that was supported by several JAX-RS 1.0/1.1 implementations with each using slightly different semantics and now getting standardized in JAX-RS 2.0.

    Filters are non-wrapping extension points, allow pre-processing without modifying the request itself. A filter implements interface RequestFilter or ResponseFilter or both and is annotated with @Provider. A logging filter that simply logs the message may look like:

    @Provider
    class LoggingFilter implements RequestFilter, ResponseFilter {

        @Override
        public FilterAction preFilter(FilterContext ctx) throws IOException {
            logRequest(ctx.getRequest());
            return FilterAction.NEXT;
        }

        @Override
        public FilterAction postFilter(FilterContext ctx) throws IOException {
            logResponse(ctx.getResponse());
            return FilterAction.NEXT;
        }
    }

    Multiple filters are grouped in filter chains. The response from preFilter and postFilter indicate whether the next filter in the chain need to be executed (FilterAction.NEXT) or stopped (FilterAction.STOP).

    Handlers provide wrapping extension points. A handler implements interface ReadFromHandler or WriteToHandler or both and is annotated with @Provider. A GZIP filter that provides deflate and inflate capabilities may look like:

    @Provider
    class GzipHandler implements ReadFromHandler, WriteToHandler {
        @Override
        public Object readFrom(ReadFromHandlerContext ctx) throws IOException {
            InputStream old = ctx.getInputStream();
            ctx.setInputStream(new GZIPInputStream(old));
            try {
                return ctx.proceed();
            } finally {
                ctx.setInputStream(old);
            }
        }

        @Override
        public Object writeTo(WriteToHandlerContext ctx) throws IOException {
            OutputStream old = ctx.getOutputStream();
            GZIPOutputStream gzipOutputStream =
    new GZIPOutputStream(old);
            ctx.setInputStream(gzipOutputStream);
            try {
                return ctx.proceed();
            } finally {
                gzipOutputStream.finish();
                ctx.setOutputStream(old);
            }
        }
    }

    Multiple handlers are grouped in handler chains. The proceed method must be explicitly called in order for the next handler in the chain to be invoked.

    In the direction of flow the filters always executed before handlers. The following diagram shows the exact execution order on client and server-side:



    The handlers and filters can be associated to each method of a resource specifically using @NameBinding. The specification defines @GlobalBinding to associate handlers and filters to all methods of a resource but the recent version of the specification removes it and makes it a default. Also look at JAX_RS_SPEC-146 that asks for a mechanism to override the global filters/handlers.

    The dynamic binding, enabled by implementing DynamicBinding, provide more control on the association with resources and methods.
  • Hypermedia: Linking resources together is one of the main RESTful principles. There are structural links that are used to avoid sending a complete representation of a resource and enable lazy loading. The clients can follow these type of links to retrieve the "pieces" they need. A transitional link is used to update the state of a resource and is typically identified by a "rel" attribute. Structural links are normally in the entity; transitional links could be in link headers or the entity.

    JAX-RS 2.0 will only support transitional links in headers using newly added Link and LinkBuilder classes. The proposed Client API can also create a target from a link. The code may look like:

    Response r = client.target("/product").request("application/json").get();
    ResponseHeaders rh = r.getHeaders();
    if (rh.hasLink("ship")) {
        client.invocation(rh.getLink("ship")).invoke();
    }


    On the server side, ResponseBuilder has support for adding one or more link headers. The code may look like:

    @Path("/products")
    public class MyResponse {

        @GET
        @Path("{id}")
        @Produces({"application/json", "application/xml"})
        public Response getProduct(@PathParam("id")int id) {
            Product product = new Product(id);
            return Response
                    .ok(product)
                    .link("http://.../orders/" + id + "/ship", "ship")
                    .build();
        }
    }


  • Validation: Web resources must validate data received in query or header parameters or entity bodies. Currently this validation has to be performed in the application code. The Bean Validation specification already defines a extensible mechanism to specify validation constraints on a bean. So the JAX-RS specification leverages that and introduces support for declarative validation. The constraint annotations can be specified in public constructor parameters, method parameters, fields and bean properties. In addition, they can also decorate resource classes, entity parameters and resource methods. Here is a sample class augmented with constraint annotations:

    @Path("/")
    class ProductResource {

        @POST
        @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
        public void addProduct(@NotNull @FormParam("productName") String name,
                               @NotNull @Category @FormParam("category") String category) {
            . . .
        }
    }


    The @NotNull is a pre-defined constraint in the Bean Validation API and ensures that the target parameters are not null. The @Category is a user-defined constraint using the extensible mechanism provided by the Bean Validation API. If the constraints are violated then the resource method is not invoked and instead a response with status code 400 (Bad Request) and an entity that describe the violations is returned to the client.

    Here is a sample code of how to validate request entity bodies when they are mapped to resource method parameters:

    @CheckProduct
    class Product { . . . }

    @Path("/")
    class ProductResource {

        @POST
        @Consumes(MediaType.APPLICATION_JSON)
        public void addProduct(@Valid Product product) {
            . . .
        }
    }


    The presence of @Valid (a pre-defined annotation in Bean Validation API) next to the method parameter ensures that the @CheckProduct constraint is called to verify the mapped entity.

    The JAX-RS specification also defines the sequence to validate root resource class instances. The recommendation is to return as many violations as possible instead of aborting after the first violation is encountered.
  • Asynchronous Processing: JAX-RS 2.0 introduces asynchronous processing on server- and client-side APIs for the usual reasons. The server-side code will look like:

    @Path("/async")
    class ProductResource {
        @Context ExecutionContext ctx;

        @GET
        @Suspend
        public Product longOp() {
            Executors.newSingleThreadExecutor().submit(
                new Runnable() {
                    public void run() {
                        Proruct product = longQueryFromDatabase();
                        ctx.resume(product);
                    }
                }
            );
        }
    }

    The longOp method is invoked when this resource is accessed using GET, forks a new thread, and returns immediately without producing the result. Once longQueryFromDatabase returns the product then the connection is resumed and the response is returned by calling ctx.resume and setting the value.

    ExecutionContext also provide suspend() that allows to override the values, such as timeout, specified in the annotation based upon the runtime state.

    On the client-side, the code will look like:

    Client client = ClientFactory.newClient();
    Future<String> future = client.target("http://.../atm/{card}/balance")
                                  .pathParam("card", "1111222233334444")
                                  .queryParam("pin", "1234")
           
                           .request("text/plain")
                  
                    .async()
                         
             .get();

    The async() is called during building the client request. The return Future<String> can be used to query/cancel the status of execution on the server-side using isDone and cancel. Once the response is ready then Future<T>.get() is invoked to receive an instance of T if the response was successful or null if the invocation failed.

    Optionally an InvocationCallback<T> may be registered during the request invocation. The completed method is called when the invocation completes successfully and a response is available and failed method is called when the invocation fails. The code looks like:

    Future<String> future = client.target("http://.../atm/{card}/balance")
                                  .pathParam("card", "1111222233334444")
                                  .queryParam("pin", "1234")
           
                           .request("text/plain")
                  
                    .async()
                         
             .get(
                                      new InvocationCallback<String>() {
                                          @Override
                                          public void completed(String result) {
                                              // got the correct result
                                              System.out.println(result);
                                          }

                                          @Override
                                          public void failed(InvocationException error) {
                                              // ouch, got an error!
                                              System.err.println(error.getCause());
                                          }
                                      }
                                   );


    Notice, the type of the result is specified as type parameter to InvocationCallback.

    Client and server developers optimize their resources (threads) depending upon their needs and are independent of each other. A client really can't tell if a resource is implemented asynchronously or not and shouldn't even need to know.

  • Improved connection negotiation: This would allow a server to specify a preferred MIME type if the client does not care about it. This can be easily specified using the "qs" qualifier as shown below:

    @Path("/")
    class ProductResource {

        @GET
        @Produces({ "text/xml
    ;qs=0.75", "application/json"})
        public Product[] getProducts() {
            . . .
        }
    }


    The default server-side qs-value and the final order of server-side served types preferences follow the same rules as those specified for HTTP Accept Header. Per those rules an unspecified value takes the default value of 1. So the above @Produces rule says "application/json" will be served as the preferred type if there is no Accept header from the client. The section 3.5 talks more about qs parameter and the section 3.8 in the specification provide complete details about how media type of the response is chosen by a JAX-RS runtime.

The Appendix D in the specification provide a comprehensive list of changes from the previous version of the specification.

Here are some final set of references for you:

And of course, it'll all be delivered as part of GlassFish 4.0!

Learn the latest and greatest about JAX-RS 2.0 from Marek Potociar's talk on JAX-RS at Devoxx 2011:

Monday Feb 06, 2012

Java EE 6 and 7 at JUGICE, Iceland, JFokus 2012, and Umeå JUG, Sweden


After an easy January month, the conference circuit is starting with a tour of the Nordics.

What ? Java EE 6 hands-on workshop
Date ? Saturday, Feb 11, 2012
Time ? 9am - 1pm
Where ? Reykjavik University, Fönix (m-105)
Register ? jugice-ag2012-eorg.eventbrite.com
Prep work: Download and Install NetBeans 7.0.1 or later ("All" version) from netbeans.org, JDK 6 latest update from oracle.com/javase.
Twitter: @JUGICE




What ? Java EE 6 hands-on workshop (Feb 13, 9am), PaaSing a Java EE Application (Feb 15, 9am), Java EE 7: Developing for the Cloud (Feb 15, 1pm)
Date ? Monday - Wednesday, Feb 13 - 15, 2012
Time ? All Day
Where ? Stockholm Waterfront Congress Center, Sweden
Register ? jfokus.com (almost sold out, register quick)
Prep work: (For hands-on workshop only) Download and Install NetBeans 7.0.1 or later ("All" version) from netbeans.org, JDK 6 latest update from oracle.com/javase.
Website: jfokus.com
Twitter: @jfokus

Check out my reports from JFokus 2011.



What ? Java EE 6 hands-on workshop
Date ? Thursday, Feb 16, 2012
Time ? 6pm
Where ? Umeå University (Triple-Helix), Umeå, Sweden
Register ? Just show up
Prep work: Download and Install NetBeans 7.0.1 or later ("All" version) from netbeans.org, JDK 6 latest update from oracle.com/javase.
Website: umejug.blogspot.com

Where will I meet or run with you ? :)

Wednesday Feb 01, 2012

Java EE 6 pulled crowd at Austin JUG




I delivered a NetBeans-driven Java EE 6 session to about 80+ attendees at the Austin JUG yesterday. The session built a typical three-tier Web application using the new/updated technologies in the Java EE 6 platform. I was told this is one of the largest attendance seen at the JUG in recent months. Java EE 6 is indeed a crowd puller ;-)

Rob Ratcliff, the JUG leader, started with a great overview of "Whats new in Java" covering recent JDK update releases, Java FX 2.1 Developer Preview for Mac and Linux, Java EE 6 and WebLogic 12c, NetBeans 7.1 and other stuff. His complete slides are available here. I was fortunate to speak at the JUG because an informal survey of the attendees showed that nobody attends (or plan to attend) a conference in the coming months.

During my session, the highly interactive attendees learned about NetBeans wizard-driven Java EE 6 application development. Here are some of the features that were demonstrated in the talk:
  • Improvements in Java Persistence API
  • "web.xml"-free and annotation-driven Servlets
  • Simplified packaging of EJBs in a WAR file, no-interface and single file definition of EJB
  • Session preservation across redeploys
  • Facelets (XHTML/CSS) as templating language for JavaServer Faes to achieve true MVC
  • Integration of Bean Validation with JPA and JSF
  • Typesafe dependency injection and Producer/Observer of events using CDI
  • RESTful resources using JAX-RS

The application was built using NetBeans and deployed on GlassFish. This same application can be easily deployed on WebLogic 12c as well since it is full Java EE 6-compliant as well now. The complete instructions for NetBeans/GlassFish are available here and same instructions for NetBeans/WebLogic will be made available shortly as well.

The session ran almost 45 minutes beyond the scheduled time with most of the attendees staying late and asking questions. The feedback from the attendees was very positive. One of them was even starting a new project using NetBeans + Java EE 6 + GlassFish next week so this talk was directly relevant. Also found another attendee using GlassFish for development and WebLogic for deployment for their Java EE 6 application. Rob used GlassFish for an internal US Military project and has been deployed for more than 2 years with nearly zero maintenance.

Check out some pictures from the JUG visit ...






A tweet like the one below definitely make the quick trip worth it ...



The formal JUG session was followed by a beer-a-thon (lemonade-a-thon for me ;-) at BJs.

Some interesting facts about Austin ...
  • Michael Dell (chairman and CEO of Dell) lives in Austin, Dell worldwide headquarters are in Austin.
  • Lance Armstrong is from Austin.
  • Sandra Bullock, Matthew McConaughey, and Brad Pitt has homes in Austin.
  • Whole Foods chain started and headquartered in Austin. I was lucky enough to squeeze time out for a lunch with a colleague at one of their stores in this less-than-24-hour visit to Austin.
  • Keep Austin Weird
Download the NetBeans/GlassFish instructions and let us know how you are using Java EE 6.

Next stop is Reykjavik (Iceland), Stockholm (Sweden) and Umeå (Sweden), more on that later ...

About

profile image
Arun Gupta is a technology enthusiast, a passionate runner, author, and a community guy who works for Oracle Corp.


Java EE 7 Samples

Stay Connected

Search

Archives
« February 2012 »
SunMonTueWedThuFriSat
   
2
3
4
5
8
9
13
14
16
17
18
19
20
22
23
24
25
26
27
28
   
       
Today