<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">
        <title type="html">Arun Gupta, Miles to go ...</title>
    <subtitle type="html">Arun Gupta's Weblog</subtitle>
    <id>https://blogs.oracle.com/arungupta/feed/entries/atom</id>
            
        <link rel="alternate" type="text/html" href="https://blogs.oracle.com/arungupta/" />
        <updated>2013-05-21T21:56:08+00:00</updated>
        <generator uri="http://roller.apache.org" version="BLOGS401ORA4 (20120329084749)">Apache Roller</generator>
        <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/MilesToGo" /><feedburner:info uri="milestogo" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
        <id>https://blogs.oracle.com/arungupta/entry/java_ee_7_launch_webcast</id>
        <title type="html">Java EE 7 Launch Webcast: Jun 12th, Register Now</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/6XMVTCp8RjE/java_ee_7_launch_webcast" />
        <published>2013-05-19T15:10:12+00:00</published>
        <updated>2013-05-20T01:02:36+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="launch" scheme="http://roller.apache.org/ns/tags/" />
        <category term="webcast" scheme="http://roller.apache.org/ns/tags/" />
        <category term="webinar" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
The &lt;a
href="https://blogs.oracle.com/theaquarium/entry/java_ee_7_platform_completes"&gt;Java
EE 7 Platform JSR was approved&lt;/a&gt; a few days ago and is ready to
be released ...ta da!&lt;br&gt;
&lt;br&gt;
Want to learn the latest and the greatest improvements in the
platform from the best ?&lt;br&gt;
&lt;br&gt;
Mark the date for webinars in two different time zones:&lt;br&gt;
&lt;br&gt;
Jun 12, 2013, 9am PT&lt;br&gt;
Jun 12, 2013, 9pm PT&lt;br&gt;
&lt;br&gt;
&lt;a
href="https://event.on24.com/eventRegistration/EventLobbyServlet?target=registration.jsp&amp;amp;eventid=615713&amp;amp;sessionid=1&amp;amp;key=453EBA948F6408FE613E61903CBAEBFA&amp;amp;partnerref=Java_EE7_Launch_glassfishblogs_06122013&amp;amp;sourcepage=register"&gt;Register
now!&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
What will you see in this online event ?&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Business Keynote (Hasan Rizvi and Cameron Purdy)&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Technical Keynote (Linda DeMichiel)&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Breakout Sessions on different JSRs by specification leads&lt;/li&gt;
&lt;li&gt;Live Chat&lt;/li&gt;
&lt;li&gt;Lots of Demos&lt;/li&gt;
&lt;li&gt;Community, Partner, and Customer video testimonials&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
Feel free to use any of the following images to promote the launch
webcast on your blog, website, social media, or elsewhere. You can
also copy/paste the code fragment shown next to them:&lt;br&gt;
&lt;br&gt;
&lt;table border="0" cellpadding="5" cellspacing="5" width="100%"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a
href="https://event.on24.com/eventRegistration/EventLobbyServlet?target=registration.jsp&amp;amp;eventid=615713&amp;amp;sessionid=1&amp;amp;key=453EBA948F6408FE613E61903CBAEBFA&amp;amp;partnerref=Java_EE7_Launch_glassfishblogs_06122013&amp;amp;sourcepage=register"&gt;&lt;img
alt=""
src="https://blogs.oracle.com/arungupta/resource/javaee7-launch-jun12-185x225.png"
border="0" height="225" width="185"&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt; &amp;lt;a&lt;br&gt;
href="https://event.on24.com/eventRegistration/EventLobbyServlet?target=registration.jsp&amp;amp;eventid=615713&amp;amp;sessionid=1&amp;amp;key=453EBA948F6408FE613E61903CBAEBFA&amp;amp;partnerref=Java_EE7_Launch_glassfishblogs_06122013&amp;amp;sourcepage=register"&amp;gt;&amp;lt;img&lt;br&gt;
alt=""&lt;br&gt;
src="https://blogs.oracle.com/arungupta/resource/javaee7-launch-jun12-185x225.png"&lt;br&gt;
border="0" height="225" width="185"&amp;gt;&amp;lt;/a&amp;gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;table border="0" cellpadding="5" cellspacing="5" width="100%"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a
href="https://event.on24.com/eventRegistration/EventLobbyServlet?target=registration.jsp&amp;amp;eventid=615713&amp;amp;sessionid=1&amp;amp;key=453EBA948F6408FE613E61903CBAEBFA&amp;amp;partnerref=Java_EE7_Launch_glassfishblogs_06122013&amp;amp;sourcepage=register"&gt;&lt;img
alt=""
src="https://blogs.oracle.com/arungupta/resource/javaee7-launch-jun12-403x403.png"
border="0" height="403" width="403"&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&amp;lt;a&lt;br&gt;
href="https://event.on24.com/eventRegistration/EventLobbyServlet?target=registration.jsp&amp;amp;eventid=615713&amp;amp;sessionid=1&amp;amp;key=453EBA948F6408FE613E61903CBAEBFA&amp;amp;partnerref=Java_EE7_Launch_glassfishblogs_06122013&amp;amp;sourcepage=register"&amp;gt;&amp;lt;img&lt;br&gt;
alt=""&lt;br&gt;
src="https://blogs.oracle.com/arungupta/resource/javaee7-launch-jun12-403x403.png"&lt;br&gt;
border="0" height="403" width="403"&amp;gt;&amp;lt;/a&amp;gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
Don't forget to &lt;a
href="https://event.on24.com/eventRegistration/EventLobbyServlet?target=registration.jsp&amp;amp;amp;eventid=615713&amp;amp;amp;sessionid=1&amp;amp;amp;key=453EBA948F6408FE613E61903CBAEBFA&amp;amp;amp;partnerref=Java_EE7_Launch_glassfishblogs_06122013&amp;amp;amp;sourcepage=register"&gt;register&lt;/a&gt;!&lt;br&gt;
&lt;br&gt;
Get ready to drink from the fire hose, no throttle!&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/6XMVTCp8RjE" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/java_ee_7_launch_webcast</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/suggestions_for_java_ee_and</id>
        <title type="html"> Suggestions for Java EE and Cloud Track at JavaOne 2013: CFP ends Apr 23</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/9gV-DKj7sSQ/suggestions_for_java_ee_and" />
        <published>2013-04-17T22:54:56+00:00</published>
        <updated>2013-04-17T22:54:56+00:00</updated> 
        <category term="/General" label="General" />
        <category term="2013" scheme="http://roller.apache.org/ns/tags/" />
        <category term="conf" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaone" scheme="http://roller.apache.org/ns/tags/" />
        <category term="sanfrancisco" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
&lt;img alt=""
src="https://blogs.oracle.com/arungupta/resource/javaone-logo.png"
height="189" width="532"&gt;&lt;br&gt;
&lt;br&gt;
&lt;a href="http://www.oracle.com/javaone/index.html"&gt;JavaOne&lt;/a&gt; &lt;a
href="http://www.oracle.com/javaone/call-for-papers/information/index.html"&gt;Call

for Papers&lt;/a&gt; has been &lt;a
href="https://blogs.oracle.com/javaone/entry/one_week_left_to_submit"&gt;extended&lt;/a&gt;
and now will close on April 23. There are eight tracks to submit
your talks:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Client and Embedded Development with JavaFX&lt;/li&gt;
&lt;li&gt;Core Java Platform&lt;/li&gt;
&lt;li&gt;Edge Computing with Java in Embedded, Smart Card, and IoT
applications&lt;/li&gt;
&lt;li&gt;Emerging Languages and the Java Virtual Machine&lt;/li&gt;
&lt;li&gt;Securing Java&lt;/li&gt;
&lt;li&gt;Java Development Tools and Techniques&lt;/li&gt;
&lt;li&gt;Java EE Web Profile and Platform Technologies&lt;/li&gt;
&lt;li&gt;Java Web Services and the Cloud&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A complete description of each track is &lt;a
href="http://www.oracle.com/javaone/tracks/index.html"&gt;provided
here&lt;/a&gt;. Five different kind of sessions can be submitted for
each track:&lt;br&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Conference Session&lt;/b&gt;: A 60-minute session presented by
Oracle, customers, partners, developers, and/or user group
members&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Panel&lt;/b&gt;: A 60-minute session presented in a panel format
by multiple speakers consisting of Oracle, customers, partners,
developers, and/or user group members&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Tutorials&lt;/b&gt;: A 2 hour speaker led session where the
presenter literally show attendees a live "How to" tutorial, and
attendees can ask questions to the presenter during this. It
doesn't require the attendee to have any equipment whatsoever.
Ideally, the attendee should be listening and taking notes.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Birds of a Feather (BOFs)&lt;/b&gt;: A&amp;nbsp; 60-minute session
that allows a closer interaction with the speakers and attendees
focusing on a particular aspect of technology.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Hands-on Lab (HOL)&lt;/b&gt;: A two-hour hands-on, interactive
lab session&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
We've seen a good response to paper submission so far and really
thankful for that! &lt;br&gt;
&lt;br&gt;
You've a few more days to submit your talks. As a track co-lead for
Java EE and Cloud tracks, here are some talks that I'd like to see
there:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Anything related to WebSocket, JSON, Concurrency, Batch,
HTML5, Persistence, Dependency Injection, Transactions ?&lt;/li&gt;
&lt;li&gt;Do you have a creative use of Java EE technologies in your
applications ?&lt;/li&gt;
&lt;li&gt;Are you an extreme believer in Java EE and use most of the
components for creating world-class applications ?&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Are you using multiple application servers in your deployment
environment ? &lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Do you have any experience of migrating from earlier versions
of J2EE to Java EE ? Tutorials here would be nice.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Do you want to show value of standards-based application
development over proprietary frameworks ?&lt;/li&gt;
&lt;li&gt;Are you building support for Java EE 7 in your applications
already ?&lt;/li&gt;
&lt;li&gt;Performance, monitoring, testing, development, deployment
strategies ?&lt;/li&gt;
&lt;li&gt;Any other enterprise Java technologies from the ecosystem ?&lt;/li&gt;
&lt;li&gt;Real case studies on how Java EE helped you deliver on time,
within budget, and stay competitive&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
And now some suggestions for the Cloud track:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;How are your Java services powering web and cloud ?&lt;/li&gt;
&lt;li&gt;Anything related to REST/SOAP Web services and design patterns
?&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;How is Service Oriented Architecture (SOA) helping you realize
the benefits ?&lt;br&gt;
&lt;/li&gt;
&lt;li&gt; Do you have an interesting deployment topology across your
private and public cloud ?&lt;/li&gt;
&lt;li&gt;Do you have a case study showing why a particular deployment
scenario works ? &lt;/li&gt;
&lt;li&gt;Are you exposing services at IaaS, PaaS, and SaaS layers and
share guidelines on them ?&lt;/li&gt;
&lt;li&gt;How are you simplifying DevOps ?&lt;/li&gt;
&lt;li&gt;How are you using BigData in development and deployment ?&lt;/li&gt;
&lt;li&gt;Anything related to NoSQL ? Using a mix of NoSQL and RDBMS ?&lt;/li&gt;
&lt;/ul&gt;
Keep the job of &lt;a
href="http://www.oracle.com/javaone/quick-links/program-committee/index.html"&gt;Content
Review Committe&lt;/a&gt; interesting, demanding, and challenging.
Submit as many sessions as you can before April 23rd 11:50pm PT.&lt;br&gt;
&lt;br&gt;
Read the &lt;a
href="https://blogs.oracle.com/arungupta/entry/javaone_2011_content_review_process"&gt;content
review process and tips for submission&lt;/a&gt; from 2 years ago to
improve your chances of getting a paper selected.&lt;br&gt;
&lt;br&gt;
&lt;a
href="http://www.oracle.com/javaone/call-for-papers/information/index.html"&gt;Submit

now&lt;/a&gt;!&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/9gV-DKj7sSQ" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/suggestions_for_java_ee_and</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/websocket_client_and_server_endpoint</id>
        <title type="html"> WebSocket Client and Server Endpoint: Annotated and Programmatic (TOTD #212)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/rSpORD8_TDM/websocket_client_and_server_endpoint" />
        <published>2013-04-04T19:35:00+00:00</published>
        <updated>2013-04-04T19:35:00+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr356" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <category term="websocket" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html"> &lt;br&gt;
&lt;a href="http://jcp.org/en/jsr/detail?id=356"&gt;JSR 356&lt;/a&gt; defines
Java API for WebSocket 1.0. It defines a standard-based programming
model for creating WebSocket client and server endpoint. Both kind
of endpoints can be created programmatically or using annotations.
This &lt;b&gt;T&lt;/b&gt;ip &lt;b&gt;O&lt;/b&gt;f &lt;b&gt;T&lt;/b&gt;he &lt;b&gt;D&lt;/b&gt;ay (TOTD) provide
short snippets of how to write a WebSocket client and server
endpoint programmatically or using annotations.&lt;br&gt;
&lt;br&gt;
The complete source code in this sample can be downloaded &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd212-websocket-endpoint.zip"&gt;from
here&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
Lets start with &lt;b&gt;annotation-based server endpoint&lt;/b&gt;.&lt;br&gt;
&lt;br&gt;
&lt;code&gt;@ServerEndpoint("/websocket")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;public class MyEndpoint {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; @OnMessage&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; public String echoText(String name) {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return name;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;}&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
&lt;code&gt;@ServerEndpoint&lt;/code&gt; marks the POJO as a WebSocket server
endpoint. URI of the deployed endpoint is as &lt;code&gt;value&lt;/code&gt;
attribute of the annotation.&amp;nbsp; &lt;code&gt;echoText&lt;/code&gt; method is
invoked whenever a message with text payload is received by this
endpoint. Payload of the message is mapped to the parameter &lt;code&gt;name&lt;/code&gt;.
A synchronous response is returned to the client using the return
value.&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Programmatic server endpoint&lt;/b&gt; can be defined as:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;public class MyEndpoint extends Endpoint {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; @Override&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; public void onOpen(final Session session,
EndpointConfig ec) {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; session.addMessageHandler(new
MessageHandler.Whole&amp;lt;String&amp;gt;() {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void
onMessage(String text) {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
session.getBasicRemote().sendText(text);&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch
(IOException ex) {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Logger.getLogger(MyEndpoint.class.getName()).log(Level.SEVERE,
null, ex);&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; });&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;}&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
A programmatic server endpoint is defined by extending &lt;code&gt;Endpoint&lt;/code&gt;
abstract class. &lt;code&gt;onOpen&lt;/code&gt; method is overridden to be
notified of when a new conversation has started. &lt;code&gt;Session&lt;/code&gt;
captures the other end of the conversation. &lt;code&gt;EndpointConfig&lt;/code&gt;
identifies the configuration object used to configure this endpoint.
Multiple &lt;code&gt;MessageHandler&lt;/code&gt;s are registered to handle
text, binary, and pong messages. The first parameter of &lt;code&gt;onOpen&lt;/code&gt;
captures the other end of the conversation. A synchronous response
to the client is sent by calling &lt;code&gt;getBasicRemote().sendText(...)&lt;/code&gt;
method.&lt;br&gt;
&lt;br&gt;
Programmatic server endpoint needs to be configured using &lt;code&gt;ServerApplicationConfig&lt;/code&gt;.&lt;br&gt;
&lt;br&gt;
&lt;code&gt;public class MyApplicationConfig implements
ServerApplicationConfig {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; @Override&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; public Set&amp;lt;ServerEndpointConfig&amp;gt;
getEndpointConfigs(Set&amp;lt;Class&amp;lt;? extends Endpoint&amp;gt;&amp;gt; set)
{&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new
HashSet&amp;lt;ServerEndpointConfig&amp;gt;() {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
add(ServerEndpointConfig.Builder&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
.create(MyEndpoint.class, "/websocket")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
.build());&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; @Override&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; public Set&amp;lt;Class&amp;lt;?&amp;gt;&amp;gt;
getAnnotatedEndpointClasses(Set&amp;lt;Class&amp;lt;?&amp;gt;&amp;gt; set) {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Collections.emptySet();&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;}&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
WebSocket runtime scans the WAR file with all implementations of &lt;code&gt;ServerApplicationConfig&lt;/code&gt;
and registers the endpoint returned from &lt;code&gt;getEndpointConfigs&lt;/code&gt;
and &lt;code&gt;getAnnotatedEndpointClasses&lt;/code&gt;. The URI of the server
endpoint is published using &lt;code&gt;ServerEndpointConfig.Builder&lt;/code&gt;.&lt;br&gt;
&lt;br&gt;
Now lets take a look at &lt;b&gt;annotated client endpoint&lt;/b&gt;.&lt;br&gt;
&lt;br&gt;
&lt;code&gt;@ClientEndpoint&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;public class MyClient {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; @OnOpen&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; public void onOpen(Session session) {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String name = "Duke";&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
System.out.println("Sending message to endpoint: " + name);&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
session.getBasicRemote().sendText(name);&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (IOException ex) {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Logger.getLogger(MyClient.class.getName()).log(Level.SEVERE, null,
ex);&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;}&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
&lt;code&gt;@ClientEndpoint&lt;/code&gt; marks the POJO as a WebSocket client
endpoint. &lt;code&gt;onOpen&lt;/code&gt; method is invoked whenever a new
WebSocket connection is opened and is identified by &lt;code&gt;@OnOpen&lt;/code&gt;
annotation. &lt;code&gt;Session&lt;/code&gt; captures the other end of the
conversation. A synchronous message is sent to the server using &lt;code&gt;session.getBasicRemote.sendText()&lt;/code&gt;
method.&lt;br&gt;
&lt;br&gt;
This client can connect to the endpoint as:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;WebSocketContainer container =
ContainerProvider.getWebSocketContainer();&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;String uri = "ws://localhost:8080" +
request.getContextPath() + "/websocket";&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;container.connectToServer(MyClient.class,
URI.create(uri));&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
And finally &lt;b&gt;programmatic &lt;/b&gt;&lt;b&gt;client endpoint&lt;/b&gt;.&lt;br&gt;
&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;public class MyClient extends Endpoint {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; @Override&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; public void onOpen(final Session session,
EndpointConfig ec) {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; session.addMessageHandler(new
MessageHandler.Whole&amp;lt;String&amp;gt;() {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void
onMessage(String text) {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
System.out.println("Received response in client from endpoint: " +
text);&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; });&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; try {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; String name = "Duke";&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
System.out.println("Sending message from client -&amp;gt; endpoint: "
+ name);&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
session.getBasicRemote().sendText(name);&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (IOException ex) {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Logger.getLogger(MyClient.class.getName()).log(Level.SEVERE, null,
ex);&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;}&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
The first parameter of &lt;code&gt;onOpen&lt;/code&gt; captures the other end
of the conversation.&amp;nbsp; &lt;code&gt;EndpointConfig&lt;/code&gt; identifies
the configuration object used to configure this endpoint. Multiple &lt;code&gt;MessageHandler&lt;/code&gt;s
are registered to handle text, binary, and pong messages. &lt;code&gt;onMessage&lt;/code&gt;
method is called whenever a message is received from the endpoint. A
synchronous request to the server is sent by calling &lt;code&gt;getBasicRemote().sendText(...)&lt;/code&gt;
method.&lt;br&gt;
&lt;br&gt;
This client can connect to the endpoint as:&lt;br&gt;
&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;WebSocketContainer container =
ContainerProvider.getWebSocketContainer();&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;String uri = "ws://localhost:8080" +
request.getContextPath() + "/websocket";&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;container.connectToServer(MyClient.class, &lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
null,&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
URI.create(uri));&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
Now go download your &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b82.zip"&gt;GlassFish
b82&lt;/a&gt;, &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd212-websocket-endpoint.zip"&gt;samples
source code&lt;/a&gt;, and run them.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/rSpORD8_TDM" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/websocket_client_and_server_endpoint</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/introducing_kids_to_java_programming</id>
        <title type="html">Introducing Kids to Java Programming Using Minecraft</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/H5h-DKTVDdg/introducing_kids_to_java_programming" />
        <published>2013-03-22T17:29:04+00:00</published>
        <updated>2013-03-22T17:29:04+00:00</updated> 
        <category term="/General" label="General" />
        <category term="bukkit" scheme="http://roller.apache.org/ns/tags/" />
        <category term="craftbukkit" scheme="http://roller.apache.org/ns/tags/" />
        <category term="education" scheme="http://roller.apache.org/ns/tags/" />
        <category term="kids" scheme="http://roller.apache.org/ns/tags/" />
        <category term="minecraft" scheme="http://roller.apache.org/ns/tags/" />
        <category term="netbeans" scheme="http://roller.apache.org/ns/tags/" />
        <category term="programming" scheme="http://roller.apache.org/ns/tags/" />
        <category term="school" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
&lt;table border="0" cellpadding="5" cellspacing="5" width="100%"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://blogs.oracle.com/arungupta/resource/minecraft-logo.png"
height="54" width="257"&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;a href="http://minecraft.net"&gt;Minecraft&lt;/a&gt;
is a wildly popular game among elementary and middle
schoolers. The game allows players to build constructions of
textured cubes in a 3D world. &lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
My son has been playing the game for about a year, lets say addicted
to it. Last Fall he told me that the game is corrupted because the
JAR file snapshot has messed up the configuration. And that right
away rang a bell in me as a Java Evangelist at Oracle. &lt;br&gt;
&lt;br&gt;
I learned from him that the game is written in Java, has a trial
version that runs as an applet in the browser, and downloaded as a
JAR file for desktop. The game is modular where the players travel
through a world and chunks are loaded and unloaded to keep the
memory footprint small. Something unique about the game is the
ability to modify the game from what it was originally designed for.
In Minecraft language, this is called as a "&lt;a
href="http://www.minecraftwiki.net/wiki/Mods"&gt;mod&lt;/a&gt;" - short for
modifications. For example, a mod can add new characters to the
game, change look-and-feel of the play field, or make it easy to
build new structures.&lt;br&gt;
&lt;br&gt;
The game has a server and a client component. This allows the game
to be played in a single player mode where a player connects to a
server using a client and plays the game. Alternatively multiple
players, using different clients across platforms, can connect to a
server and play with each other collaboratively. Its very common to
have a server run with multiple mods. There are almost an infinite
number of mods someone could do to make Minecraft a more amusing
game to play. There is no official API to create these mods but
there are several third-party vendors that provide that capability;
&lt;a href="http://bukkit.org/"&gt;Bukkit&lt;/a&gt; is one such API. The ability
to write mods and alter the game play gives players more control
over the game and gets them more excited.&lt;br&gt;
&lt;br&gt;
My son expressed his desire to write a mod and so we started
exploring further. Then onwards, he started teaching me Minecraft
vocabulary and I taught him the Java programming concepts. Our
discussions in the car, on the dinner table, during the breakfast
preparation, and elsewhere changed to reflect that as well. He
already played with &lt;a href="http://scratch.mit.edu/"&gt;Scratch&lt;/a&gt;
and &lt;a href="http://www.greenfoot.org/door"&gt;Greenfoot&lt;/a&gt; last
Summer and that was extremely helpful during this learning curve. We
set up a goal to build a mod during Christmas break. After
understanding the basic concepts and building a few mods, we decided
to share the knowledge with a broader set of Minecrafters. And
that's where the concept of doing a Minecraft Workshop was born.&lt;br&gt;
&lt;br&gt;
My son came up with a list of his minecraft buddies and we announced
a date for the workshop. Everybody invited for the workshop
confirmed their presence right away. I found out that both the
invited kids and their parents were equally excited. One friend
could not attend because of a prior commitment and was extremely
disappointed. On the day of the workshop, some kids were eager to
come even before the formal start of the workshop.&lt;br&gt;
&lt;br&gt;
The workshop was attended by 10 kids with age ranging from 10-14
years. Most of the kids had no programming experience, let alone
Java. However there was high Minecraft experience in the group with
some kids playing for about 2 years and up to 2 hours every day.
When given the topic of Minecraft, the small group would talk
excitedly about different aspects of the game, constantly using
hundreds of game-specific terms and phrases as if speaking a
different language. My goal was to leverage their passion and
introduce them to Java programming. &lt;br&gt;
&lt;br&gt;
&lt;table border="0" cellpadding="5" cellspacing="5"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="http://java.net/projects/java4kids/sources/source/content/website/minecraft-workshop/mar2013/images/workshop-003.jpg?rev=e00c90375f54b54d53eea5f2a940b345ea110943"
height="199" width="300"&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="http://java.net/projects/java4kids/sources/source/content/website/minecraft-workshop/mar2013/images/workshop-068.jpg?rev=e00c90375f54b54d53eea5f2a940b345ea110943"
height="200" width="300"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
The challenge for me was to introduce programming to these kids
using analogies from the daily life. Using a car, features,
capabilities, types, and car dealers and correlating with class,
properties, methods, instances, and packages seem to work. Fruits
and different methods of peeling, eating, and planting was used to
introduce the concept of Interface in Java. I asked, “What can you
do with a watermelon?” the first answer was obvious, “you can eat
it.” The second one was a little less so, “You can chuck in a trash
can.” The response was greeted with scattered laughter. I used that
to explain the concept of Exceptions in Java. &lt;br&gt;
&lt;br&gt;
&lt;table border="0" cellpadding="5" cellspacing="5" width="100%"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="http://java.net/projects/java4kids/sources/source/content/website/minecraft-workshop/mar2013/images/workshop-114.jpg?rev=e00c90375f54b54d53eea5f2a940b345ea110943"
height="300" width="199"&gt;&lt;/td&gt;
&lt;td valign="top"&gt;Short anecdotes and side-conversations kept
the livelihood of the group going throughout the five hour
programming session. There are almost an infinite number of
mods someone could do to make Minecraft a more amusing game
to play. But all these mods hold the same basic framework
that we set up for any future work on making game-specific
mods. By the end of the session, we had worked out an entire
framework for making a mod. A &lt;a
href="https://maven.java.net/content/groups/public/name/arungupta/bukkit/bukkit-plugin-archetype/"&gt;Maven
archetype&lt;/a&gt; to create a template &lt;a
href="http://plugins.bukkit.org/"&gt;Bukkit plugin&lt;/a&gt;
allowed the attendees to avoid writing boilerplate code. A
lower bar to get started and simplicity was the key for this
audience. The mod built in the workshop added a new
server-side command and printed a trivial message.&lt;br&gt;
&lt;br&gt;
Although the goal of the workshop was to get an introduction
on programming and make a Minecraft mod, I believe the
attendees learned much more than that. I think the informal
set up helped them discover that programming can be fun and
useful to add to gaming experience. Programming is a vast
field and we barely scratched the surface. But most
importantly, the attendees had a good time and learned their
first lesson of Java programming to start off an interest in
it. &lt;br&gt;
&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
"Fun", "Easy", "Quick", "Awesome", "Short", and "Intuitive"
described attendees' one word summary of building and running their
first Hello World application using NetBeans.&lt;br&gt;
&lt;br&gt;
All the instructions followed in the workshop, including a lot more
pictures, are available at &lt;a
href="http://java4kids.java.net/minecraft-workshop/mar2013/index.html"&gt;java4kids.java.net/minecraft-workshop&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
For me, it was quite a humbling and learning experience. I've
delivered multiple workshops all around the world but mostly to
professional developers. I realized how the instructions need to be
completely spelled out in order for the attendees of this age to
make progress. Something as simple as "Hit Enter after entering the
command", yes, that is required. Anyway I plan this to be the first
of many more workshops aimed to introduce the world of Java
programming to school students.&lt;br&gt;
&lt;br&gt;
One of the lessons learned during the workshop was to simplify the
installation experience. All the kids had JDK and NetBeans set up
already, pretty straight forward. However I wonder why Maven insists
on JAVA_HOME variable instead of figuring it out. I need to
investigate how to seamlessly install JDK, NetBeans, and Maven in a
platform independent way. This will allow to focus more on building
the actual mod rather than the multi-step installations.&lt;br&gt;
&lt;br&gt;
&lt;img alt=""
src="http://java.net/projects/java4kids/sources/source/content/website/minecraft-workshop/mar2013/images/workshop-117.jpg?rev=e00c90375f54b54d53eea5f2a940b345ea110943"
height="333" width="500"&gt;&lt;br&gt;
&lt;br&gt;
This workshop was not possible without mentoring support from Allen
Dutra and other parents. A huge shout out to my family who helped
validate and calibrate my strategy for the audience. My nephews
feedback from the lab is incorporated into this blog. Thanks to
Oracle for sponsoring the snacks!&lt;br&gt;
&lt;br&gt;
Thank you &lt;a href="https://twitter.com/notch"&gt;@notch&lt;/a&gt; for using
Java to build the game! You've provided a great platform for young
kids to learn Java and truly enabled Make The Future Java ...&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/H5h-DKTVDdg" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/introducing_kids_to_java_programming</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/chunked_step_using_batch_applications</id>
        <title type="html">Chunked Step using Batch Applications in Java EE 7: Getting Started with GlassFish 4 (TOTD #211)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/B4F4SVRgqlI/chunked_step_using_batch_applications" />
        <published>2013-03-06T09:00:00+00:00</published>
        <updated>2013-03-06T09:00:00+00:00</updated> 
        <category term="/General" label="General" />
        <category term="batch" scheme="http://roller.apache.org/ns/tags/" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr352" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
&lt;a
href="https://blogs.oracle.com/arungupta/entry/batch_applications_in_java_ee"&gt;TOTD
#192&lt;/a&gt; explained the key concepts of &lt;a
href="http://jcp.org/en/jsr/detail?id=352"&gt;JSR 352&lt;/a&gt;. This &lt;b&gt;T&lt;/b&gt;ip
&lt;b&gt;O&lt;/b&gt;f &lt;b&gt;T&lt;/b&gt;he &lt;b&gt;D&lt;/b&gt;ay provides a working example of a
how to write a simple chunk step using &lt;a
href="http://java.net/projects/jbatch/"&gt;JSR 352 Reference
Implementation&lt;/a&gt; integrated in &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/"&gt;GlassFish
4&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
The source code for this sample application can be &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd211-chunk-simple.zip"&gt;downloaded
from here&lt;/a&gt; and works on &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b78.zip"&gt;GlassFish
4 b78&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
As explained in &lt;a
href="https://blogs.oracle.com/arungupta/entry/batch_applications_in_java_ee"&gt;TOTD
#192&lt;/a&gt;, JSR 352 defines item-oriented processing using &lt;i&gt;chunk&lt;/i&gt;
step and task-oriented processing using &lt;i&gt;batchlet&lt;/i&gt; step. A
chunk consists of a &lt;i&gt;reader&lt;/i&gt; that reads one item at a time, a
&lt;i&gt;processor&lt;/i&gt; that processes one item at a time, and a &lt;i&gt;writer&lt;/i&gt;
that aggregates 'chunk' number of items and then writes them out.&lt;br&gt;
&lt;br&gt;
Here is an implementation of reader:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;@Named&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;public class MyItemReader extends
AbstractItemReader&amp;lt;MyInputRecord&amp;gt; {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private final StringTokenizer
tokens;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public MyItemReader() {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tokens = new
StringTokenizer("1,2,3,4,5,6,7,8,9,10", ",");&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public MyInputRecord readItem() {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if
(tokens.hasMoreTokens()) {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
return new MyInputRecord(Integer.valueOf(tokens.nextToken()));&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return null;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;}&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
Reader uses type information to specify the type of record that it
is working on, &lt;code&gt;MyInputRecord&lt;/code&gt; in this case. The &lt;code&gt;readItem&lt;/code&gt;
method returns &lt;code&gt;null&lt;/code&gt; to indicate the end of items that
can be read. In this case, a &lt;code&gt;StringTokenizer&lt;/code&gt; is used
to read the items but you can use an &lt;code&gt;InputStream&lt;/code&gt; here
if you like.&lt;br&gt;
&lt;br&gt;
Here is an implementation of processor:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;@Named&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;public class MyItemProcessor implements
ItemProcessor&amp;lt;MyInputRecord,MyOutputRecord&amp;gt; {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public MyOutputRecord
processItem(MyInputRecord t) {&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
System.out.println("processItem: " + t);&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return
(t.getId() % 2 == 0) ? null : new MyOutputRecord(t.getId() * 2);&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;}&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
Processor uses type information to specify the type of input and
output records its working on, &lt;code&gt;MyInputRecord&lt;/code&gt; is the
input record and &lt;code&gt;MyOutputRecord&lt;/code&gt; is the output record
in this case. The &lt;code&gt;processItem&lt;/code&gt; method reads the input
record and accepts only odd-numbered records. This is where your
business logic would be implemented.&lt;br&gt;
&lt;br&gt;
And here is an implementation of writer:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;@Named&lt;br&gt;
public class MyItemWriter extends
AbstractItemWriter&amp;lt;MyOutputRecord&amp;gt; {&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public void
writeItems(List&amp;lt;MyOutputRecord&amp;gt; list) {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
System.out.println("writeItems: " + list);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Writer uses type information as well to specify the type of output
record, &lt;code&gt;MyOutputRecord&lt;/code&gt; in this case. All these
elements are tied together using "Job XML" as shown:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;&amp;lt;job id="myJob" xmlns="http://batch.jsr352/jsl"&amp;gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;step id="myStep" &amp;gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;chunk
item-count="3"&amp;gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;reader ref="myItemReader"&amp;gt;&amp;lt;/reader&amp;gt; &lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;processor ref="myItemProcessor"&amp;gt;&amp;lt;/processor&amp;gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;writer ref="myItemWriter"&amp;gt;&amp;lt;/writer&amp;gt; &lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/chunk&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/step&amp;gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;lt;/job&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Eventually, the references &lt;code&gt;myItemReader&lt;/code&gt;, &lt;code&gt;myItemProcessor&lt;/code&gt;,
and &lt;code&gt;myItemWriter&lt;/code&gt; will be resolved using CDI. But for
now, the references can be explicitly resolved using "batch.xml" as
shown:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;&amp;lt;batch-artifacts xmlns="http://jcp.org.batch/jsl"&amp;gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ref id="myItemReader"
class="org.glassfish.chunk.simple.MyItemReader"/&amp;gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ref id="myItemProcessor"
class="org.glassfish.chunk.simple.MyItemProcessor"/&amp;gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ref id="myItemWriter"
class="org.glassfish.chunk.simple.MyItemWriter"/&amp;gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;lt;/batch-artifacts&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Once again, downloaded the source code &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd211-chunk-simple.zip"&gt;from
here&lt;/a&gt; and get it running on &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b78.zip"&gt;GlassFish
4 b78&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
Post feedback on &lt;a href="mailto:public@jbatch.java.net"&gt;public@jbatch.java.net&lt;/a&gt;
or &lt;a href="mailto:users@glassfish.java.net"&gt;users@glassfish.java.net&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/B4F4SVRgqlI" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/chunked_step_using_batch_applications</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/consuming_and_producing_json_using</id>
        <title type="html">Consuming and Producing JSON using JAX-RS Entity Providers and JSR 353 Streaming API (TOTD# 210)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/94asBTTukNk/consuming_and_producing_json_using" />
        <published>2013-03-04T08:15:00+00:00</published>
        <updated>2013-03-04T08:15:00+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jaxrs" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jersey" scheme="http://roller.apache.org/ns/tags/" />
        <category term="json" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr339" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
&lt;a
href="https://blogs.oracle.com/arungupta/entry/jax_rs_custom_entity_providers"&gt;TOTD





#193&lt;/a&gt; explained how JAX-RS Entity Providers can be used to
provide mapping between on-the-wire representations and their
associated Java types. This blog shows how you can use Java API for
JSON Processing (JSR 353), already integrated in &lt;a
href="http://download.java.net/glassfish/4.0/promoted"&gt;GlassFish 4
promoted builds&lt;/a&gt;, to produce and consume JSON payload using
Entity Providers.&lt;br&gt;
&lt;br&gt;
The source code in this blog can be &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd210-readerwriter-json.zip"&gt;downloaded





here&lt;/a&gt; and runs on &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b76.zip"&gt;GlassFish





b76&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
Lets say your domain object is defined as:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;public class MyObject {&lt;br&gt;
&lt;br&gt;
&amp;nbsp; private String name;&lt;br&gt;
&amp;nbsp; private int age;&lt;br&gt;
&lt;br&gt;
&amp;nbsp; //. . .&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
And your resource endpoint is defined as:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;@Path("endpoint")&lt;br&gt;
public class MyResource {&lt;br&gt;
&amp;nbsp; @POST&lt;br&gt;
&amp;nbsp; @Consumes(MediaType.APPLICATION_JSON)&lt;br&gt;
&amp;nbsp; public MyObject echoObject(MyObject mo) {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return mo;&lt;br&gt;
&amp;nbsp; }&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;/code&gt; This is just echoing the domain object but I suspect your
domain logic would be more complex than that ;-)&lt;br&gt;
&lt;br&gt;
Using JAX-RS Client API, this endpoint can be invoked as:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;WebTarget target = client.target(".../endpoint");&lt;br&gt;
MyObject mo = target&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
.request()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
.post(&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Entity.entity(new MyObject("Duke", 18),
MediaType.APPLICATION_JSON),&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
MyObject.class);&lt;br&gt;
System.out.println("Received response: " + mo.getName() + ", " +
mo.getAge() + "&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;");&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
The &lt;code&gt;MessageBodyWriter.writeTo&lt;/code&gt; method, that writes &lt;code&gt;MyObject&lt;/code&gt;
to the underlying &lt;code&gt;OutputStream&lt;/code&gt;, uses Streaming API
from JSR 353 and looks like:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;@Override&lt;br&gt;
public void writeTo(MyObject t, &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;



Class&amp;lt;?&amp;gt; type, &lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;



&lt;/code&gt; Type type1, &lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;



&lt;/code&gt; Annotation[] antns, &lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;



&lt;/code&gt; MediaType mt, &lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;



&lt;/code&gt; MultivaluedMap&amp;lt;String, Object&amp;gt; mm, &lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;



&lt;/code&gt; OutputStream out)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
throws IOException, WebApplicationException {&lt;br&gt;
&amp;nbsp; JsonGeneratorFactory factory =
Json.createGeneratorFactory();&lt;br&gt;
&amp;nbsp; JsonGenerator gen = factory.createGenerator(out);&lt;br&gt;
&amp;nbsp; gen.writeStartObject()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .write("name", t.getName())&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .write("age", t.getAge())&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .writeEnd();&lt;br&gt;
&amp;nbsp; gen.flush();&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt; &lt;br&gt;
Similarly &lt;code&gt;MessageBodyReader.readFrom&lt;/code&gt; method, that
reads &lt;code&gt;MyObject&lt;/code&gt; from the underlying &lt;code&gt;InputStream&lt;/code&gt;,
uses Streaming API from JSR 353 and looks like:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;@Override&lt;br&gt;
public MyObject readFrom(Class&amp;lt;MyObject&amp;gt; type,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;




Type type1,&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;




&lt;/code&gt; Annotation[] antns,&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;




&lt;/code&gt; MediaType mt,&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;




&lt;/code&gt;MultivaluedMap&amp;lt;String, String&amp;gt; mm,&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;




&lt;/code&gt; InputStream in)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;




throws IOException, WebApplicationException {&lt;br&gt;
&amp;nbsp; MyObject mo = new MyObject();&lt;br&gt;
&amp;nbsp; JsonParser parser = Json.createParser(in);&lt;br&gt;
&amp;nbsp; while (parser.hasNext()) {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; switch (parser.next()) {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case KEY_NAME:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String key =
parser.getString();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; parser.next();&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; switch (key) {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; case "name":&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
mo.setName(parser.getString());&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; break;&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case "age":&lt;br&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;
mo.setAge(parser.getIntValue());&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; default:&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; break;&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; break;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; default:&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; break;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp; }&lt;br&gt;
&amp;nbsp; return mo;&lt;br&gt;
}&lt;br&gt;
&lt;/code&gt; &lt;br&gt;
The code is pretty straight forward and refer to &lt;a
href="http://json-processing-spec.java.net/nonav/releases/1.0/pfd-draft/javadocs/index.html"&gt;Java





API for JSON Processing javadocs&lt;/a&gt; if you need help in
understanding the code.&lt;br&gt;
&lt;br&gt;
Download the &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd210-readerwriter-json.zip"&gt;source





code&lt;/a&gt; and enjoy!&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/94asBTTukNk" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/consuming_and_producing_json_using</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/updating_to_latest_websocket_api</id>
        <title type="html"> Updating to latest WebSocket API - Starting with GlassFish b78 (TOTD #209)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/cV3_bSJBV-E/updating_to_latest_websocket_api" />
        <published>2013-02-28T15:50:44+00:00</published>
        <updated>2013-02-28T15:50:44+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr356" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <category term="websocket" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
Java API for WebSocket (&lt;a
href="http://jcp.org/en/jsr/detail?id=356"&gt;JSR 356)&lt;/a&gt; has
recently gone through a &lt;a
href="http://java.net/projects/websocket-spec/lists/jsr356-experts/archive/2013-02/message/58"&gt;major

refactoring&lt;/a&gt;. The changes are &lt;a
href="https://blogs.oracle.com/PavelBucek/entry/tyrus_1_0_b12_released"&gt;integrated

in Tyrus b12&lt;/a&gt; and now available in &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b78.zip"&gt;GlassFish

b78&lt;/a&gt;. This &lt;b&gt;T&lt;/b&gt;ip &lt;b&gt;O&lt;/b&gt;f &lt;b&gt;T&lt;/b&gt;he &lt;b&gt;D&lt;/b&gt;ay
(TOTD) shows the change log for WebSocket endpoint in &lt;a
href="http://java.net/projects/websocket-spec/lists/jsr356-experts/archive/2013-02/message/58"&gt;Collaborative

Whiteboard Sample&lt;/a&gt; (explained in &lt;a
href="https://blogs.oracle.com/arungupta/entry/collaborative_whiteboard_using_websocket_in"&gt;TOTD

#189&lt;/a&gt;) between GlassFish b76 and b78.&lt;br&gt;
&lt;br&gt;
First of all, everything stays in &lt;code&gt;javax.websocket.*&lt;/code&gt;
and &lt;code&gt;javax.websocket.server.*&lt;/code&gt; package.&lt;br&gt;
&lt;br&gt;
There are name changes in annotations, APIs, class renames, and some
behavior change as well. &lt;a
href="https://blogs.oracle.com/PavelBucek/entry/tyrus_1_0_b12_released"&gt;Pavel's
blog&lt;/a&gt; provides a comprehensive list of changes and the
annotation changes are listed here as well:&lt;br&gt;
&lt;br&gt;
&lt;table border="0" cellpadding="5" cellspacing="5" width="50%"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th valign="top"&gt;Name before b78&lt;br&gt;
&lt;/th&gt;
&lt;th valign="top"&gt;Name after b78&lt;br&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;@WebSocketEndpoint&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;@ServerEndpoint&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;@WebSocketClient&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;@ClientEndpoint&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;@WebSocketMessage&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;@OnMessage&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;@WebSocketPathParam&lt;/code&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;@PathParam&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;@WebSocketOpen&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;@OnOpen&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;@WebSocketClose&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;@OnClose&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;@WebSocketError&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;@OnError&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
&lt;br&gt;
Here is the change log for updating Whiteboard.java:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;--- &amp;lt;html&amp;gt;Whiteboard.java (&amp;lt;b&amp;gt;849f919&amp;lt;/b&amp;gt;)&amp;lt;/html&amp;gt;&lt;br&gt;+++ &amp;lt;html&amp;gt;&amp;lt;b&amp;gt;Current File&amp;lt;/b&amp;gt;&amp;lt;/html&amp;gt;&lt;br&gt;@@ -45,50 +45,48 @@&lt;br&gt; import java.util.HashSet;&lt;br&gt; import java.util.Set;&lt;br&gt; import javax.websocket.EncodeException;&lt;br&gt;&lt;b&gt;&lt;font color="#006600"&gt;+import javax.websocket.OnClose;&lt;br&gt;+import javax.websocket.OnMessage;&lt;br&gt;+import javax.websocket.OnOpen;&lt;br&gt;&lt;/font&gt;&lt;/b&gt; import javax.websocket.Session;&lt;br&gt;&lt;b&gt;&lt;font color="#ff0000"&gt;-import javax.websocket.WebSocketClose;&lt;br&gt;-import javax.websocket.WebSocketMessage;&lt;br&gt;-import javax.websocket.WebSocketOpen;&lt;br&gt;-import javax.websocket.server.WebSocketEndpoint;&lt;br&gt;&lt;/font&gt;&lt;/b&gt;&lt;b&gt;&lt;font color="#006600"&gt;+import javax.websocket.server.ServerEndpoint;&lt;/font&gt;&lt;/b&gt;&lt;br&gt; &lt;br&gt; /**&lt;br&gt; * @author Arun Gupta&lt;br&gt; */&lt;br&gt;&lt;b&gt;&lt;font color="#ff0000"&gt;-@WebSocketEndpoint(value = "/websocket",&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;font color="#006600"&gt;+@ServerEndpoint(value = "/websocket",&lt;/font&gt;&lt;/b&gt;&lt;br&gt; encoders = {FigureEncoder.class},&lt;br&gt; decoders = {FigureDecoder.class}&lt;b&gt;)&lt;/b&gt;&lt;br&gt; public class Whiteboard {&lt;br&gt; &lt;br&gt; private static Set&amp;lt;Session&amp;gt; peers = Collections.synchronizedSet(new HashSet&amp;lt;Session&amp;gt;());&lt;br&gt; &lt;br&gt;&lt;b&gt;&lt;font color="#ff0000"&gt;- @WebSocketOpen&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;font color="#006600"&gt;+ @OnOpen&lt;/font&gt;&lt;/b&gt;&lt;br&gt; public void onOpen(Session peer) {&lt;br&gt; peers.add(peer);&lt;br&gt; }&lt;br&gt; &lt;br&gt;&lt;b&gt;&lt;font color="#ff0000"&gt;- @WebSocketClose&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;font color="#006600"&gt;+ @OnClose&lt;/font&gt;&lt;/b&gt;&lt;br&gt; public void onClose(Session peer) {&lt;br&gt; peers.remove(peer);&lt;br&gt; }&lt;br&gt; &lt;br&gt;&lt;b&gt;&lt;font color="#ff0000"&gt;- @WebSocketMessage&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;font color="#006600"&gt;+ @OnMessage&lt;/font&gt;&lt;/b&gt;&lt;br&gt; public void boradcastFigure(Figure figure, Session session) throws IOException, EncodeException {&lt;br&gt; System.out.println("boradcastFigure: " + figure);&lt;br&gt; for (Session peer : peers) {&lt;br&gt; if (!peer.equals(session)) {&lt;br&gt;&lt;b&gt;&lt;font color="#ff0000"&gt;- peer.getRemote().sendObject(figure);&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;font color="#006600"&gt;+ peer.getBasicRemote().sendObject(figure);&lt;/font&gt;&lt;/b&gt;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt; &lt;br&gt;&lt;b&gt;&lt;font color="#ff0000"&gt;- @WebSocketMessage&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;font color="#006600"&gt;&lt;b&gt;+ @OnMessage&lt;/b&gt;&lt;/font&gt;&lt;br&gt; public void broadcastSnapshot(ByteBuffer data, Session session) throws IOException {&lt;br&gt; System.out.println("broadcastBinary: " + data);&lt;br&gt; for (Session peer : peers) {&lt;br&gt; if (!peer.equals(session)) {&lt;br&gt;&lt;b&gt;&lt;font color="#ff0000"&gt;- peer.getRemote().sendBytes(data);&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;b&gt;&lt;font color="#006600"&gt;+ peer.getBasicRemote().sendBinary(data);&lt;/font&gt;&lt;/b&gt;&lt;br&gt; }&lt;br&gt; }&lt;br&gt; }&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
The updated source code for the sample is &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd189-whiteboard-glassfish78.zip"&gt;available
here&lt;/a&gt; and runs on &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b78.zip"&gt;GlassFish
b78&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
Hopefully this gives you a good idea on how to migrate your
WebSocket applications from the older to the newer API. The changes
are still evolving and the &lt;a
href="http://java.net/projects/websocket-spec/downloads/download/Spec%20javadoc%20Drafts/v013/JavaWebSocket_JSR356_013.pdf"&gt;specification&lt;/a&gt;
(PDF) and &lt;a
href="http://java.net/projects/websocket-spec/downloads/download/Spec%20javadoc%20Drafts/v013/JavaWebSocket_JSR356_013_apidoc.zip"&gt;javadocs&lt;/a&gt;
(ZIP) are the definitive source for the latest information. The
complete set of latest spec downloads are &lt;a
href="http://java.net/projects/websocket-spec/downloads/directory/Spec%20javadoc%20Drafts/v013"&gt;available
here&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
As always, send the spec feedback to &lt;a
href="mailto:users@websocket-spec.java.net"&gt;users@websocket-spec.java.net&lt;/a&gt;
and implementation feedback to &lt;a
href="mailto:users@tyrus.java.net"&gt;users@tyrus.java.net&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/cV3_bSJBV-E" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/updating_to_latest_websocket_api</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/transparency_and_community_participation_in</id>
        <title type="html">Transparency and Community Participation in Java EE 7</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/v7Zri5tUuvE/transparency_and_community_participation_in" />
        <published>2013-02-27T10:00:00+00:00</published>
        <updated>2013-02-27T11:20:34+00:00</updated> 
        <category term="/General" label="General" />
        <category term="community" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jcp" scheme="http://roller.apache.org/ns/tags/" />
        <category term="transparency" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
Ever since the launch of Java EE 7 and its component JSRs, Oracle
has been very committed to a high level of transparency for all of
the JSRs under the Java EE 7 umbrella. We're so excited that
increased transparency has resulted in more useful feedback that has
improved the Java EE platform. Let me tell you what we've done, how
it's helped, and how &lt;b class="moz-txt-star"&gt;you&lt;span
class="moz-txt-tag"&gt;&lt;/span&gt;&lt;/b&gt; can get involved too.&lt;br&gt;
&lt;br&gt;
One of the requirements for &lt;a
href="http://jcp.org/en/procedures/jcp2_8"&gt;JCP 2.8&lt;/a&gt; is:&lt;br&gt;
&lt;br&gt;
&lt;i&gt;When voting to approve a JSR's transition to the next stage, EC
members are expected to take into consideration the extent to
which the Spec Lead is meeting the transparency requirements.&lt;/i&gt;&lt;br&gt;
&lt;br&gt;
Now that many of these JSRs have gone through the Public Review
Ballot and others are in progress, it is useful to review how they
have contributed to the transparency process. &lt;br&gt;
&lt;br&gt;
First of all, all Java EE 7 Expert Groups are operating using the
transparency rules defined &lt;a
href="http://jcp.org/en/resources/2.8"&gt;JCP 2.8&lt;/a&gt;. The
transparency rule requires:&lt;br&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;ol type="A"&gt;
&lt;li&gt;Public can read the names on the Expert Group&lt;/li&gt;
&lt;li&gt;Expert Group business is regularly reported on a publicly
readable alias&lt;/li&gt;
&lt;li&gt;Mechanism for allow public to provide feedback&lt;/li&gt;
&lt;li&gt;Spec lead respond to the posts on the alias&lt;/li&gt;
&lt;li&gt;Schedule of JSR is publicly available, current, and updated
regularly&lt;/li&gt;
&lt;li&gt;Open source process for the development of RI and/or TCK&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Publicly readable and/or writable issue-tracker&lt;/li&gt;
&lt;li&gt;Publicly accessible document archive&lt;br&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;/ul&gt;
Happy to report that &lt;b&gt;all&lt;/b&gt; the JSRs in Java EE 7 have followed
the guidelines mentioned above. Providing a specific example using
JSR 342:&lt;br&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;ol type="A"&gt;
&lt;li&gt;&lt;a href="http://jcp.org/en/jsr/detail?id=342"&gt;JSR 342&lt;/a&gt; has
all the Expert Group member names publicly listed&lt;/li&gt;
&lt;li&gt;All technical discussions on the Expert Group are reported on
jsr342-experts@javaee-spec.java.net alias and &lt;a
href="http://java.net/projects/javaee-spec/lists/jsr342-experts/archive"&gt;archived&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Anybody outside the Expert Group can subscribe to the alias at
&lt;a
href="http://java.net/projects/javaee-spec/lists/users/archive"&gt;users@javaee-spec.java.net&lt;/a&gt;
and provide feedback&lt;/li&gt;
&lt;li&gt;Spec leads regularly read and respond on the alias&lt;/li&gt;
&lt;li&gt;Schedule of JSR is publicly reported at &lt;a
href="http://java.net/projects/javaee-spec/pages/Home#Java_EE_7_Schedule"&gt;javaee-spec.java.net&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://glassfish.org"&gt;GlassFish&lt;/a&gt; is the Reference
Implementation and is completely built in open source. The &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/"&gt;promoted









builds&lt;/a&gt; have been available for several months, the
schedule is &lt;a
href="https://wikis.oracle.com/display/GlassFish/4.0BuildSchedule"&gt;completely









transparent&lt;/a&gt;, &lt;a
href="https://wikis.oracle.com/display/GlassFish/Java+EE+7+Maven+Coordinates"&gt;maven









coordinates&lt;/a&gt; are published, and &lt;a
href="http://wiki.netbeans.org/JavaEE7Preview"&gt;NetBeans
tooling&lt;/a&gt; is available for some time. All this allows
developers to play with the bleeding edge Java EE 7 technologies
as they are integrated in GlassFish. &lt;a
href="http://www.java.net/forums/glassfish/glassfish"&gt;Public
forum&lt;/a&gt; allows the users to communicate specifically about
the RI.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Publicly readable/writable &lt;a
href="http://java.net/jira/browse/JAVAEE_SPEC"&gt;issue tracker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Publicly accessible &lt;a
href="http://java.net/projects/javaee-spec/downloads"&gt;document
archive&lt;/a&gt;&lt;br&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;/ul&gt;
The transparency checklist by each JSR is explained in the table
below.&lt;br&gt;
&lt;br&gt;
&lt;meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1"&gt;
Many of our spec leads have gone beyond this in their outreach to
the community with blogs, talks, chats, and more. The Java EE 7
Expert Group recently concluded a &lt;a
href="https://blogs.oracle.com/theaquarium/entry/java_ee_7_survey_results"&gt;public











survey&lt;/a&gt; seeking community input to define key areas in the
platform such as which specifications should be included in the Web
Profile, should CDI be enabled by default, expanded use of &lt;code&gt;@Stereotype&lt;/code&gt;,
and expansions of Interceptors to all Java EE components. Over 1100
respondents voted, make their voices heard, and help decide the
direction of the platform.&lt;br&gt;
&lt;br&gt;
The table below provides:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Public website for each specification in Java EE 7. All of our
JSRs that are part of the Java EE 7 Platform are being run in
the open, using java.net projects.&amp;nbsp; These JSRs, and links
to their respective projects are listed on the &lt;a
href="http://java.net/projects/javaee-spec/pages/Home"&gt;home
page of the Java EE 7 Platform JSR&lt;/a&gt; and in the table below.
Each page has publicly viewable Expert Group mailing lists as
Users observer lists. The Users lists receive copies of all
expert group emails, as well as providing users the ability to
post feedback and engage in discussions with each other and with
expert group members. All lists have publicly viewable archives
on the java.net project sites. &lt;br&gt;
&lt;br&gt;
Similarly, all projects have publicly accessible download areas,
and JIRA issue trackers where bugs and suggestions for new
features can be posted, and which also serve as another means of
discussion with EG members. The schedules and interim drafts of
the specification were posted on the main project page and
publicly visible Downloads area.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Transparency Checklist columns shows the status of different
JSRs meeting the transparency requirements of JCP 2.8.&lt;/li&gt;
&lt;li&gt;Community Participation represents the increase in community
participation above and beyond the core Expert Group for each
Specification. As you can see the participation from the
community outside the Expert Group is pretty significant and has
worked really well.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;To encourage further community participation, different Java
EE 7 Expert Groups defined specific areas to &lt;a
href="http://glassfish.java.net/adoptajsr/"&gt;provide feedback&lt;/a&gt;
using &lt;a href="http://adoptajsr.org"&gt;Adopt-a-JSR&lt;/a&gt;. We saw
tremendous success with the effort with several JUGs joining the
effort. The last column lists different JUGs that have adopted a
particular JSR. In several cases, JUGs have adopted multiple
JSRs.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
&lt;table border="0" cellpadding="5" cellspacing="5"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th colspan="1" rowspan="2" valign="top"&gt;Specification / JSR &lt;/th&gt;
&lt;th colspan="8" rowspan="1" valign="top"&gt;Transparency
Checklist&lt;br&gt;
&lt;/th&gt;
&lt;th colspan="1" rowspan="2" valign="top"&gt;Community&lt;br&gt;
Participation&lt;br&gt;
&lt;/th&gt;
&lt;th colspan="1" rowspan="2" valign="top"&gt;Adopt-a-JSR &lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;th valign="top"&gt;A&lt;/th&gt;
&lt;th valign="top"&gt;B&lt;/th&gt;
&lt;th valign="top"&gt;C&lt;/th&gt;
&lt;th valign="top"&gt;D&lt;/th&gt;
&lt;th valign="top"&gt;E&lt;/th&gt;
&lt;th valign="top"&gt;F&lt;/th&gt;
&lt;th valign="top"&gt;G&lt;/th&gt;
&lt;th valign="top"&gt;H&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a
href="http://java.net/projects/concurrency-ee-spec/"&gt;Concurrency&lt;/a&gt;
(JSR 236)&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt; ✓&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;~250%&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a href="http://java.net/projects/jpa-spec/"&gt;JPA&lt;/a&gt;
(JSR 338)&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;~250%&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;Chennai JUG&lt;br&gt;
Hyderabad JUG&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a
href="http://java.net/projects/jax-rs-spec/"&gt;JAX-RS&lt;/a&gt;
(JSR 339)&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;~350%&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;CE JUG&lt;br&gt;
Indonesia JUG&lt;br&gt;
LJC&lt;br&gt;
Madrid JUG&lt;br&gt;
Morocco JUG&lt;br&gt;
Peru JUG&lt;br&gt;
SouJava&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a
href="http://java.net/projects/servlet-spec/"&gt;Servlet&lt;/a&gt;
(JSR 340)&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;~350%&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a href="http://java.net/projects/el-spec/"&gt;EL&lt;/a&gt;
(JSR 341)&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;~125%&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a
href="http://java.net/projects/javaee-spec/"&gt;Java EE 7&lt;/a&gt;
(JSR 342)&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;~600%&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;LJC&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a href="http://java.net/projects/jms-spec/"&gt;JMS&lt;/a&gt;
(JSR 343)&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;~500%&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;FASO JUG&lt;br&gt;
Indonesia JUG&lt;br&gt;
LJC&lt;br&gt;
Peru JUG&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a
href="http://java.net/projects/javaserverfaces-spec-public/"&gt;JSF












2.2&lt;/a&gt; (JSR 344)&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;~200%&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;CE JUG&lt;br&gt;
Chennai JUG&lt;br&gt;
Cologne JUG&lt;br&gt;
Hyderabad JUG&lt;br&gt;
SouJava &lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a href="http://java.net/projects/ejb-spec/"&gt;EJB&lt;/a&gt;
(JSR 345)&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;~300%&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;SouJava Campinas JUG&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a href="https://github.com/jboss/cdi/wiki"&gt;CDI&lt;/a&gt;
(JSR 346)&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td colspan="1" rowspan="1" valign="top"&gt;Only public forum&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;Chennai JUG&lt;br&gt;
Hyderabad JUG&lt;br&gt;
Indonesia JUG&lt;br&gt;
LJC &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a href="http://beanvalidation.org/"&gt;Bean
Validation&lt;/a&gt; (JSR 349)&lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td colspan="1" rowspan="1" valign="top"&gt;Only public forum&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;SouJava&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a href="http://java.net/projects/jbatch/"&gt;Batch&lt;/a&gt;
(JSR 352)&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;~750%&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;Chennai JUG&lt;br&gt;
LJC, SouJava&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a
href="http://java.net/projects/json-processing-spec/"&gt;JSON&lt;/a&gt;
(JSR 353)&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;~650%&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;CE JUG&lt;br&gt;
Congo JUG&lt;br&gt;
LJC&lt;br&gt;
Mbale JUG&lt;br&gt;
Morocco JUG&lt;br&gt;
Peru JUG&lt;br&gt;
SouJava&lt;br&gt;
Toronto JUG&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;a
href="http://java.net/projects/websocket-spec/"&gt;WebSocket&lt;/a&gt;
(JSR 356)&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;✓ &lt;/td&gt;
&lt;td valign="top"&gt;~400%&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;BeJUG&lt;br&gt;
LJC&lt;br&gt;
Chennai JUG&lt;br&gt;
Morocco JUG&lt;br&gt;
CEJUG&lt;br&gt;
NY SIG &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
The map below shows geographical coordinates for different JUGs
participating in the Adopt-a-JSR effort for Java EE 7:&lt;br&gt;
&lt;br&gt;
&lt;iframe marginheight="0" marginwidth="0"
src="https://maps.google.com/maps/ms?msa=0&amp;amp;msid=215435580086277558608.0004d6548767be68efe5f&amp;amp;ie=UTF8&amp;amp;t=h&amp;amp;z=2&amp;amp;output=embed"
frameborder="0" height="350" scrolling="no" width="425"&gt;&lt;/iframe&gt;&lt;br&gt;
&lt;small&gt;View &lt;a
href="https://maps.google.com/maps/ms?msa=0&amp;amp;msid=215435580086277558608.0004d6548767be68efe5f&amp;amp;ie=UTF8&amp;amp;t=h&amp;amp;z=2&amp;amp;source=embed"
style="color:#0000FF;text-align:left"&gt;Java EE 7 Adopt-a-JSR Maps&lt;/a&gt;
in a larger map&lt;/small&gt; &lt;br&gt;
&lt;br&gt;
Specific contributions from Adopt-a-JSR effort:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;London Java Community (LJC) organized a &lt;a
href="http://www.meetup.com/Londonjavacommunity/events/101954512/"&gt;WebSocket











and JSON Hack Day&lt;/a&gt;. The event was sold out within 2 hours
and had 17 people on the waiting list. The event started with a
presentation on explaining the APIs in Java API for WebSocket
(JSR 353) and Java API for JSON Processing (JSR 353). The
attendees designed a Market Ticker application. All the &lt;a
href="http://java.net/projects/adoptajsr/downloads/download/wesocket-jsonhackday-130208072652-phpapp01.ppt"&gt;presentation











material&lt;/a&gt; and &lt;a
href="https://github.com/Adopt-a-JSR/JSR-353-JSON"&gt;source code&lt;/a&gt;
was shared publicly. LJC also created projects (&lt;a
href="https://github.com/Adopt-a-JSR/cdiex-palindrome-jsf"&gt;cdiex-palindrom-jsf&lt;/a&gt;
and &lt;a href="https://github.com/Adopt-a-JSR/cdiex-datastore"&gt;cdiex-datastore&lt;/a&gt;)
to test CDI 1.1 specification.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Chennai JUG is building a multi-player game that can be played
across the Internet. The application uses Java API for WebSocket
1.0 (JSR 356), Java API for JSON Processing 1.0 (JSR 353), Java
Persistence API 2.1 (JSR 338), JavaServer Faces 2.2 (JSR 344)
and Batch Applications for Java Platform (JSR 352) and/or
Enterprise JavaBeans 3.2 (JSR 345) and so provide a holistic
experience of building a Java EE 7 application. The energetic
JUG meets regularly using G+ hangouts and in the neighborhood
coffee shops to coordinate. And then they go hacking the
application on &lt;a
href="https://github.com/jugchennaiadoptjava/UrbanTravellers/tree/develop"&gt;github&lt;/a&gt;.&amp;nbsp;











There are 5 developers that are regularly contributing to the
application and the JUG plans to incorporate several other
technologies as part of an ongoing effort.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://moroccojug.org/adopt_a_jsr"&gt;Morocco JUG&lt;/a&gt;
will be presenting on Java EE 7, WebSocket, and JSON at &lt;a
href="http://jdc2013.egjug.org/session/introduction_json_websocket_apis_hackday"&gt;Java











Developer Conference, Cairo, Egypt&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Cologne JUG had a meetup on about &lt;a
href="http://java.net/projects/jugc/pages/JSR-344"&gt;JSF 2.2&lt;/a&gt;
and another one on &lt;a
href="http://jugcologne.github.com/Adopt-A-JSR-346/"&gt;CDI 1.1&lt;/a&gt;
(&lt;a
href="http://www.youtube.com/watch?v=YOeyKGwVafE&amp;amp;feature=youtu.be"&gt;video&lt;/a&gt;).&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;BeJUG has adopted JSR 356 have planned a &lt;a
href="http://www.bejug.org/confluenceBeJUG/display/BeJUG/Java+WebSockets+Hackathon"&gt;hackathon&lt;/a&gt;
on Mar 6th. They plan to build a cross-browser Tic-Tac-Toe
application using JSR 356. One of the JUG members is on its way
to become a committer in &lt;a href="http://tyrus.java.net/"&gt;Tyrus&lt;/a&gt;
- the Reference Implementation for JSR 356.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Ceara JUG has planned a set of &lt;a
href="http://www.cejug.org/2013/02/22/cafe-com-tapioca-de-marco/"&gt;presentations&lt;/a&gt;
on Mar 9 by on JAX-RS 2.0 (JSR 339), Java API for JSON
Processing (JSR 353), JavaServer Faces 2.2 (JSR 344), and Java
API for WebSocket (JSR 356).&lt;/li&gt;
&lt;li&gt;San Francisco JUG organized a &lt;a
href="http://www.sfjava.org/events/93511462/"&gt;Java EE 7 and
WebSocket&lt;/a&gt; session and planning a session on &lt;a
href="http://www.sfjava.org/events/105395862/"&gt;JAX-RS 2.0&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;SouJava is contributing by adding new features from JSF 2.2 to
&lt;a href="http://netbeans.org/kb/samples/scrum-toys.html"&gt;Scrum
Toys&lt;/a&gt;.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
Several other JUGs are doing an outstanding work and contributing
towards making Java EE 7 as the best release ever. All these efforts
truly indicate that Java EE 7 is getting grass roots participation
from the global community. This truly allows early feedback on the
specification and implementation from the end user and developers
who will eventually use these APIs. Overall this leads to a higher
quality deliverables and will hopefully eventually lead to a faster
adoption as well.&lt;br&gt;
&lt;br&gt;
Even though many of the JSRs have gone through Public Review Ballot
and others are in progress, its never too late to contribute. So how
do you contribute ? Just follow this three step process:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Join a JUG&lt;/b&gt;: If you do not participate in your local
Java User Group, then &lt;a
href="http://www.java.net/jugs/java-user-groups"&gt;find your
local JUG&lt;/a&gt; and participate. There are several already
active JUGs around the world. If one does not exist in your
neighborhood, now is your time to shine as a leader and start
one.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Participate in Adopt-a-JSR&lt;/b&gt;: Encourage JUG members to
participate in the global &lt;a
href="http://java.net/projects/adoptajsr/pages/Home"&gt;Adopt-a-JSR


effort&lt;/a&gt;. Several JUGs are already participating and
contributing very effectively.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Share the joy&lt;/b&gt;: Pick &lt;a
href="http://glassfish.java.net/adoptajsr/"&gt;any of the Java EE
7 JSRs&lt;/a&gt; that are particularly interesting, download &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/"&gt;GlassFish


4 promoted builds&lt;/a&gt;, read javadocs, build a sample
application, provide feedback to the Expert Group, and share the
joy!&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;a
href="https://blogs.oracle.com/arungupta/entry/adopt_a_jsr_for_java"&gt;
Adopt-a-JSR for Java EE 7: Getting Started&lt;/a&gt; provide more
details on how your JUGs can contribute effectively.&lt;br&gt;
&lt;br&gt;
Java EE 7 JSRs are truly operating in a fully transparent manner and
took community participation to a new level. We are always ready for
&lt;a href="http://java.net/projects/javaee-spec/lists/users/archive"&gt;feedback&lt;/a&gt;!&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/v7Zri5tUuvE" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/transparency_and_community_participation_in</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/websocket_java_client_api_in</id>
        <title type="html">WebSocket Java Client API in GlassFish 4 (TOTD #208)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/gH5asYOTSvY/websocket_java_client_api_in" />
        <published>2013-02-26T14:46:16+00:00</published>
        <updated>2013-02-26T14:46:16+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr356" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <category term="websocket" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
&lt;a href="http://www.w3.org/TR/websockets/"&gt;The WebSocket API&lt;/a&gt; by
W3C defines an API that enables Web pages to use the WebSocket
protocol for two-way communication with a remote host. Java API for
WebSocket (&lt;a href="http://jcp.org/en/jsr/detail?id=356"&gt;JSR 356&lt;/a&gt;)
has added an ability to invoke a WebSocket endpoint from a Java
application. This &lt;b&gt;T&lt;/b&gt;ip &lt;b&gt;O&lt;/b&gt;f &lt;b&gt;T&lt;/b&gt;he &lt;b&gt;D&lt;/b&gt;ay
(TOTD) will explain how you can use that API for invoking a
WebSocket endpoint.&lt;br&gt;
&lt;br&gt;
JSR 356 introduces a class-level annotation &lt;code&gt;@WebSocketClient&lt;/code&gt;
that converts a POJO into a WebSocket client. The usual lifecycle
annotations such as &lt;code&gt;@WebSocketOpen&lt;/code&gt;, &lt;code&gt;@WebSocketClose&lt;/code&gt;,
&lt;code&gt;@WebSocketError&lt;/code&gt;, and &lt;code&gt;@WebSocketMessage&lt;/code&gt;
can be specified on methods.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@WebSocketClient&lt;br&gt;public class MyClientEndpoint {&lt;br&gt; @WebSocketOpen&lt;br&gt; public void onOpen(Session session) {&lt;br&gt; System.out.println("Connected to endpoint: " + session.getRemote());&lt;br&gt; try {&lt;br&gt; String name = "Duke";&lt;br&gt; System.out.println("Sending message to endpoint: " + name);&lt;br&gt; session.getRemote().sendString(name);&lt;br&gt; } catch (IOException ex) {&lt;br&gt; Logger.getLogger(MyClientEndpoint.class.getName()).log(Level.SEVERE, null, ex);&lt;br&gt; }&lt;br&gt; }&lt;br&gt; &lt;br&gt; @WebSocketMessage&lt;br&gt; public void processMessage(String message) {&lt;br&gt; System.out.println("Received message in client: " + message);&lt;br&gt; Client.messageLatch.countDown();&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
This code sends a message to the connected WebSocket endpoint from
the &lt;code&gt;onOpen&lt;/code&gt; method and prints the message when it comes
back. This endpoint is bootstrapped using a separate class:&lt;br&gt;
&lt;pre&gt;&lt;br&gt;public class Client {&lt;br&gt;&lt;br&gt; final static CountDownLatch messageLatch = new CountDownLatch(1);&lt;br&gt; &lt;br&gt; public static void main(String[] args) {&lt;br&gt; try {&lt;br&gt; WebSocketContainer container = ContainerProvider.getWebSocketContainer();&lt;br&gt; String uri = "ws://echo.websocket.org:80/";&lt;br&gt; System.out.println("Connecting to " + uri);&lt;br&gt; container.connectToServer(MyClientEndpoint.class, URI.create(uri));&lt;br&gt; messageLatch.await(100, TimeUnit.SECONDS); &lt;br&gt; } catch (DeploymentException | InterruptedException ex) {&lt;br&gt; Logger.getLogger(Client.class.getName()).log(Level.SEVERE, null, ex);&lt;br&gt; }&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
Note that a &lt;code&gt;CountDownLatch&lt;/code&gt; is used to ensure that
there is enough time for the client to connect to the endpoint. The
latch counts down in &lt;code&gt;MyClientEndpoint.processMessage&lt;/code&gt;
once the echo message is received from the endpoint.&lt;br&gt;
&lt;br&gt;
The source code can be &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd208-javase-client.zip"&gt;downloaded
here&lt;/a&gt;, connects to a remote WebSocket endpoint, and displays
the output on the console.&lt;br&gt;
&lt;br&gt;
The Maven dependency for now are specified as:&lt;br&gt;
&lt;pre&gt;&amp;lt;dependencies&amp;gt;&lt;br&gt; &amp;lt;dependency&amp;gt;&lt;br&gt; &amp;lt;groupId&amp;gt;org.glassfish.tyrus&amp;lt;/groupId&amp;gt;&lt;br&gt; &amp;lt;artifactId&amp;gt;tyrus-client&amp;lt;/artifactId&amp;gt;&lt;br&gt; &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;&lt;br&gt; &amp;lt;/dependency&amp;gt;&lt;br&gt; &amp;lt;dependency&amp;gt;&lt;br&gt; &amp;lt;groupId&amp;gt;org.glassfish.tyrus&amp;lt;/groupId&amp;gt;&lt;br&gt; &amp;lt;artifactId&amp;gt;tyrus-container-grizzly&amp;lt;/artifactId&amp;gt;&lt;br&gt; &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;&lt;br&gt; &amp;lt;/dependency&amp;gt; &lt;br&gt;&amp;lt;/dependencies&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
Hopefully these could be specified as &lt;code&gt;javax&lt;/code&gt;
dependencies only!&lt;br&gt;
&lt;br&gt;
The latest specification draft and javadocs can be &lt;a
href="http://java.net/projects/websocket-spec/downloads/directory/Spec%20javadoc%20Drafts/v013"&gt;downloaded
here&lt;/a&gt;. Share your feedback at &lt;a
href="http://java.net/projects/websocket-spec/lists/users/archive"&gt;users@websocket-spec.java.net&lt;/a&gt;
(for the specification) or &lt;a
href="http://java.net/projects/tyrus/lists/users/archive"&gt;users@tyrus.java.net&lt;/a&gt;
(for the implenentation).&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/gH5asYOTSvY" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/websocket_java_client_api_in</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/chat_sever_using_websocket_totd</id>
        <title type="html">Chat Sever using WebSocket in GlassFish 4 (TOTD #207)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/JbI6G1Yk6W0/chat_sever_using_websocket_totd" />
        <published>2013-02-25T19:44:12+00:00</published>
        <updated>2013-02-25T19:44:12+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr356" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <category term="websocket" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
A canonical example of using WebSocket is a chat server. This &lt;b&gt;T&lt;/b&gt;ip
&lt;b&gt;O&lt;/b&gt;f &lt;b&gt;T&lt;/b&gt;he &lt;b&gt;D&lt;/b&gt;ay (TOTD) will share the code for
building exactly that!&lt;br&gt;
&lt;br&gt;
The complete code in this TOTD can be &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd207-chat.zip"&gt;downloaded
here&lt;/a&gt; and runs on &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b77.zip"&gt;GlassFish
4 b77&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
Here is the code for the Chat Server built as a WebSocket endpoint:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@WebSocketEndpoint("/websocket")&lt;br&gt;public class ChatEndpoint {&lt;br&gt; private static final Set&amp;lt;Session&amp;gt; peers = Collections.synchronizedSet(new HashSet&amp;lt;Session&amp;gt;());&lt;br&gt; &lt;br&gt; @WebSocketOpen&lt;br&gt; public void onOpen(Session peer) {&lt;br&gt; peers.add(peer);&lt;br&gt; }&lt;br&gt; &lt;br&gt; @WebSocketClose&lt;br&gt; public void onClose(Session peer) {&lt;br&gt; peers.remove(peer);&lt;br&gt; }&lt;br&gt; &lt;br&gt; @WebSocketMessage&lt;br&gt; public void message(String message, Session client) throws IOException, EncodeException {&lt;br&gt; for (Session peer : peers) {&lt;br&gt; peer.getRemote().sendObject(message);&lt;br&gt; }&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
In this code:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Lifecycle callbacks manage the coordinates of the connecting
clients&lt;/li&gt;
&lt;li&gt;&lt;code&gt;message&lt;/code&gt; method receives all the messages sent by
the client and then transmits to all the connected clients.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
Simple, isn't it ?&lt;br&gt;
&lt;br&gt;
You can use a trivial JavaScript to exchange messages between two
browsers. A chat session between two Chrome and Firefox is shown
below:&lt;br&gt;
&lt;br&gt;
&lt;img alt=""
src="https://blogs.oracle.com/arungupta/resource/totd207-chat-output.png"&gt;&lt;br&gt;
&lt;br&gt;
Download the &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd207-chat.zip"&gt;source
code&lt;/a&gt; and run it in &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b77.zip"&gt;GlassFish
4 b77&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/JbI6G1Yk6W0" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/chat_sever_using_websocket_totd</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/jsonparser_and_jsonreader_streaming_and</id>
        <title type="html">JsonParser and JsonReader - Streaming and Object Readers in Java API for JSON Processing (TOTD #206)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/3Hkots1ZUi4/jsonparser_and_jsonreader_streaming_and" />
        <published>2013-02-20T07:00:00+00:00</published>
        <updated>2013-02-20T07:00:00+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="json" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr353" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
&lt;code&gt;JsonReader&lt;/code&gt; reads a JSON object or array from an input
source. This provides DOM access to the JSON structure. &lt;br&gt;
&lt;br&gt;
&lt;code&gt;JsonParser&lt;/code&gt; provides forward, ready-only access to JSON
data in a streaming way. The parser can be created from &lt;code&gt;InputStream&lt;/code&gt;
and &lt;code&gt;Reader&lt;/code&gt;. A sample code looks like:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;JsonParser jsonParser = Json.createParser(new
StringReader(YOUR_STRING_HERE));&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
Here is a table with code fragments for parsing some common JSON
using Object Model and events generated from Streaming API:&lt;br&gt;
&lt;br&gt;
&lt;table border="1" cellpadding="2" cellspacing="2" width="100%"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th valign="top"&gt;JSON &lt;/th&gt;
&lt;th valign="top"&gt;Object Model API &lt;/th&gt;
&lt;th valign="top"&gt;Events from Streaming API &lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;{ }&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;JsonReader jsonReader = &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; new JsonReader(new StringReader("{}"));&lt;br&gt;
JsonObject json = jsonReader.readObject();&lt;br&gt;
&lt;/code&gt; &lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;{&lt;b&gt;START_OBJECT&lt;/b&gt; }&lt;b&gt;END_OBJECT&lt;/b&gt;&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;{&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "apple":"red",&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "banana":"yellow"&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;}&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;jsonReader = &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; new JsonReader(new StringReader(...));&lt;br&gt;
json = jsonReader.readObject();&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;{&lt;b&gt;START_OBJECT&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "apple"&lt;b&gt;KEY_NAME&lt;/b&gt;:"red"&lt;b&gt;VALUE_STRING&lt;/b&gt;,&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "banana"&lt;b&gt;KEY_NAME&lt;/b&gt;:"yellow"&lt;b&gt;VALUE_STRING&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;}&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;[&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; { "apple":"red" },&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; { "banana":"yellow" }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;]&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;jsonReader = &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; new JsonReader(new StringReader(...));&lt;br&gt;
JsonArray jsonArr = jsonReader.readArray();&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;[&lt;b&gt;START_ARRAY&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; {&lt;b&gt;START_OBJECT&lt;/b&gt; "apple"&lt;b&gt;KEY_NAME&lt;/b&gt;:"red"&lt;b&gt;VALUE_STRING&lt;/b&gt;
}&lt;b&gt;END_OBJECT&lt;/b&gt;,&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; {&lt;b&gt;START_OBJECT&lt;/b&gt; "banana"&lt;b&gt;KEY_NAME&lt;/b&gt;:"yellow"&lt;b&gt;VALUE_STRING&lt;/b&gt;
}&lt;b&gt;END_OBJECT&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;]&lt;b&gt;END_ARRAY&lt;/b&gt;&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;{&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "title":"The Matrix",&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "year":1999,&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "cast":[&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Keanu Reaves",&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Laurence Fishburne",&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Carrie-Anne Moss"&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; ]&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;}&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;jsonReader = &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; new JsonReader(new StringReader(...));&lt;br&gt;
json = jsonReader.readObject();&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;{&lt;b&gt;START_OBJECT&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "title"&lt;b&gt;KEY_NAME&lt;/b&gt;:"The Matrix"&lt;b&gt;VALUE_STRING&lt;/b&gt;,&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "year"&lt;b&gt;KEY_NAME&lt;/b&gt;:1999&lt;b&gt;VALUE_NUMBER&lt;/b&gt;,&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "cast"&lt;b&gt;KEY_NAME&lt;/b&gt;:[&lt;b&gt;START_ARRAY&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Keanu Reaves"&lt;b&gt;VALUE_STRING&lt;/b&gt;,&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Laurence Fishburne"&lt;b&gt;VALUE_STRING&lt;/b&gt;,&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Carrie-Anne Moss"&lt;b&gt;VALUE_STRING&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; ]&lt;b&gt;END_ARRAY&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;}&lt;b&gt;END_OBJECT&lt;/b&gt;&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt; &lt;/td&gt;
&lt;code&gt; &lt;/code&gt;&lt;/tr&gt;
&lt;code&gt; &lt;/code&gt;
&lt;/tbody&gt;&lt;code&gt; &lt;/code&gt;
&lt;/table&gt;
&lt;code&gt; &lt;/code&gt;&lt;br&gt;
The source code for this sample can be &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd206-samples.zip"&gt;downloaded
here&lt;/a&gt;, try it with &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b76.zip"&gt;GlassFish
4 b76&lt;/a&gt; or &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/"&gt;later&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
Note, GlassFish b76 has &lt;a
href="http://json-processing-spec.java.net/nonav/releases/1.0/pr-draft/javadocs/index.html"&gt;Public
Review version of the APIs&lt;/a&gt;. But the &lt;a
href="http://json-processing-spec.java.net/nonav/releases/1.0/pfd-draft2/javadocs/index.html"&gt;APIs
have evolved&lt;/a&gt; since then and an integration is planned in the
next few days. So if you are using an older build, the sample code
may not work. I'll update the sample code once the bits are
integrated.&lt;br&gt;
&lt;br&gt;
Here are some more links for you to read further:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a
href="http://json-processing-spec.java.net/nonav/releases/1.0/pr-draft/javadocs/index.html"&gt;Public
Review javadoc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a
href="http://json-processing-spec.java.net/nonav/releases/1.0/pfd-draft2/javadocs/index.html"&gt;Latest
javadoc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Reference Implemenation: &lt;a href="http://jsonp.java.net/"&gt;jsonp.java.net&lt;/a&gt;&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/3Hkots1ZUi4" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/jsonparser_and_jsonreader_streaming_and</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/jsongenerator_and_jsonobjectbuilder_streaming_and</id>
        <title type="html"> JsonGenerator and JsonObjectBuilder - Streaming and Object API in Java API for JSON Processing (TOTD #205)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/0RjqONMsMyo/jsongenerator_and_jsonobjectbuilder_streaming_and" />
        <published>2013-02-18T19:15:53+00:00</published>
        <updated>2013-02-21T00:53:31+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="json" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr353" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
Java API for JSON Processing (&lt;a
href="http://jcp.org/en/jsr/detail?id=353"&gt;JSR 353&lt;/a&gt;) &lt;a
href="http://jcp.org/en/jsr/results?id=5413"&gt;cleared Public Review
unanimously&lt;/a&gt; and is on its way to to standardization. There is
still Proposed Final Draft and the final vote to come. As per the &lt;a
href="http://java.net/projects/javaee-spec/pages/Home#Java_EE_7_Schedule"&gt;Java
EE
7 schedule&lt;/a&gt;, the specification will be final on 4/15/2013.
The implementation is already integrated in &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/"&gt;GlassFish
4
builds&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
The API provides an Object Model (like DOM for XML) and Streaming
API (like StAX for XML) to parse and generate JSON structure. Here
is a table that provide code fragments for generating some common
JSON:&lt;br&gt;
&lt;br&gt;
&lt;table border="1" cellpadding="2" cellspacing="2" width="100%"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th valign="top"&gt;JSON &lt;/th&gt;
&lt;th valign="top"&gt;Object Model API &lt;/th&gt;
&lt;th valign="top"&gt;Streaming API &lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;{ }&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;JsonObject jsonObject = &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new JsonObjectBuilder().build();&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;new JsonWriter(System.out)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .writeObject(jsonObject);&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;JsonGeneratorFactory factory = &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Json.createGeneratorFactory();&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;JsonGenerator gen = &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
factory.createGenerator(System.out);&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;gen.writeStartObject().writeEnd();&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;{&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "apple":"red",&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "banana":"yellow"&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;}&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;new JsonObjectBuilder()&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; .add("apple", "red")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; .add("banana", "yellow")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;.build();&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;gen.writeStartObject()&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .write("apple", "red")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .write("banana",
"yellow")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp; .writeEnd();&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;[&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; { "apple":"red" },&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; { "banana":"yellow" }&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;]&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;JsonArray jsonArray = new
JsonArrayBuilder()&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; .add(new JsonObjectBuilder()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
.add("apple","red"))&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; .add(new JsonObjectBuilder()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
.add("banana","yellow"))&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; .build();&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;gen.writeStartArray()&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .writeStartObject()&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
.write("apple", "red")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .writeEnd()&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .writeStartObject()&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
.write("banana", "yellow")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .writeEnd()&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;.writeEnd();&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;code&gt;{&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "title":"The Matrix",&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "year":1999,&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; "cast":[&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Keanu Reaves",&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Laurence Fishburne",&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Carrie-Anne Moss"&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; ]&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;}&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;new &lt;/code&gt;&lt;code&gt;new
JsonObjectBuilder()&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; .add("title", "The Matrix")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; .add("year", 1999)&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; .add("cast", new JsonArrayBuilder()&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; .add("Keanu Reaves")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; .add("Laurence Fishburne")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp; .add("Carrie-Anne Moss"))&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;.build();&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;code&gt;gen.writeStartObject()&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .write("title", "The
Matrix")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .write("year", 1999)&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
.writeStartArray("cast")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
.write("Keanu Reaves")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
.write("Laurence Fishburne")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
.write("Carrie-Anne Moss")&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .writeEnd()&lt;/code&gt;&lt;code&gt;&lt;br&gt;
&lt;/code&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp; .writeEnd();&lt;/code&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
The source code for this sample can be &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd205-json-samples.zip"&gt;downloaded
here&lt;/a&gt;, try it with &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b76.zip"&gt;GlassFish
4
b76&lt;/a&gt; or &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/"&gt;later&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
Here are some more links for you to read further:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a
href="http://json-processing-spec.java.net/nonav/releases/1.0/pr-draft/javadocs/index.html"&gt;Public
Review
javadoc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a
href="http://json-processing-spec.java.net/nonav/releases/1.0/pfd-draft2/javadocs/index.html"&gt;Latest
javadoc&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Reference Implemenation: &lt;a href="http://jsonp.java.net/"&gt;jsonp.java.net&lt;/a&gt;&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/0RjqONMsMyo" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/jsongenerator_and_jsonobjectbuilder_streaming_and</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/websocketclient_in_glassfish_4_totd</id>
        <title type="html">@WebSocketClient in GlassFish 4  (TOTD #204)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/LqILl-sMlD8/websocketclient_in_glassfish_4_totd" />
        <published>2013-02-13T23:12:29+00:00</published>
        <updated>2013-02-13T23:22:13+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr356" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <category term="websocket" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
&lt;a href="http://tyrus.java.net/"&gt;Tyrus&lt;/a&gt; is the Reference
Implementation for Java API for WebSocket (JSR 356) and is already
integrated in &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/latest-glassfish.zip"&gt;GlassFish

4&lt;/a&gt;. The implementation is rapidly evolving and and adding
support for different features already defined in the &lt;a
href="http://java.net/projects/websocket-spec/downloads/download/Spec%20javadoc%20Drafts/v012/JavaWebSocket_JSR356_012.pdf"&gt;latest

version of the specification&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
The latest integration in GlassFish added support for creating
Java-based WebSocket clients.&lt;br&gt;
&lt;br&gt;
Any POJO can be made a WebSocket client by adding &lt;code&gt;@WebSocketClient&lt;/code&gt;.
A inbound message is received in a method annotated with &lt;code&gt;@WebSocketMessage&lt;/code&gt;.
Any method can be designated as lifecycle method by specifying &lt;code&gt;@WebSocketOpen&lt;/code&gt;,
&lt;code&gt;@WebSocketClose&lt;/code&gt;, &lt;code&gt;@WebSocketError&lt;/code&gt;. Here is
a simple sample:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@WebSocketClient&lt;br&gt;public class MyClient {&lt;br&gt; @WebSocketOpen&lt;br&gt; public void onOpen(Session session) {&lt;br&gt; System.out.println("Connected to endpoint: " + session.getRemote());&lt;br&gt; try {&lt;br&gt; session.getRemote().sendString("Duke");&lt;br&gt; } catch (IOException ex) {&lt;br&gt; Logger.getLogger(MyClient.class.getName()).log(Level.SEVERE, null, ex);&lt;br&gt; }&lt;br&gt; }&lt;br&gt; &lt;br&gt; @WebSocketMessage&lt;br&gt; public void processMessage(String message, Session session) {&lt;br&gt; System.out.println(getClass().getName() + ": " + message);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
In this code, a message is sent to the connected WebSocket endpoint
whenever the connection is initiated. An inbound message (coming
from the server) is processed using &lt;code&gt;processMessage&lt;/code&gt;
method.&lt;br&gt;
&lt;br&gt;
The endpoint code is pretty trivial:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@WebSocketEndpoint(value="/websocket", configuration=DefaultServerConfiguration.class)&lt;br&gt;public class MyEndpoint {&lt;br&gt; &lt;br&gt; @WebSocketMessage&lt;br&gt; public String sayHello(String name) {&lt;br&gt; System.out.println(getClass().getName() + ": " + name);&lt;br&gt; return "Hello " + name;&lt;br&gt; }&lt;br&gt; &lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
The endpoint has a single method that receives the payload, appends
a string and returns back as the response. Even though server is
returning the response right away, the client views this as two
separate messages, one outbound and the other one inbound. So any
message-exchange-pattern such as request/response need to be
specifically built using the application code. The &lt;code&gt;configuration&lt;/code&gt;
attribute, in this case, is optional and will be fixed in a
subsequent release of Tyrus.&lt;br&gt;
&lt;br&gt;
The client can bootstrap using Java SE or Java EE components as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;WebSocketContainer container = ContainerProvider.getWebSocketContainer();&lt;br&gt;String uri = "ws://localhost:8080" + request.getContextPath() + "/websocket";&lt;br&gt;container.connectToServer(MyClient.class, URI.create(uri));&lt;br&gt;
&lt;/pre&gt;
The complete source code used in this &lt;b&gt;T&lt;/b&gt;ip &lt;b&gt;O&lt;/b&gt;f &lt;b&gt;T&lt;/b&gt;he

&lt;b&gt;D&lt;/b&gt;ay (TOTD) is &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd204-client.zip"&gt;available

here&lt;/a&gt;. It will run on the latest &lt;a
href="https://blogs.oracle.com/arungupta/entry/how_to_checkout_and_build"&gt;checked

out version of GlassFish workspace&lt;/a&gt;, not a promoted build yet
(bleeding edge eh ;-)&lt;br&gt;
&lt;br&gt;
Please provide feedback on &lt;a
href="http://java.net/projects/tyrus/lists/users/archive"&gt;users@tyrus.java.net&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
How are you going to use Java-based WebSocket client in your
applications ?&lt;br&gt;
&lt;br&gt;
Here are other Java EE 7 entries published on this blog so far:&lt;br&gt;
&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Create ManagedExecutorService,
ManagedScheduledExecutorService, ManagedThreadFactory,
ContextService in GlassFish 4 build 74 (&lt;a
href="https://blogs.oracle.com/arungupta/entry/create_managedexecutorservice_managedscheduledexecutorservice_managedthreadfactory_contextservice"&gt;TOTD

#203&lt;/a&gt;)&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Resource Library Contracts in JSF 2.2 (&lt;a
href="https://blogs.oracle.com/arungupta/entry/resource_library_contracts_in_jsf2"&gt;TOTD

#202&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Java EE 7 Maven Archetype - Available in NetBeans (&lt;a
href="https://blogs.oracle.com/arungupta/entry/java_ee_7_maven_archetype"&gt;TOTD

#201&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Java EE 7 and NetBeans IDE - Early Support Available (&lt;a
href="https://blogs.oracle.com/arungupta/entry/java_ee_7_and_netbeans"&gt;TOTD

#199&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;JSF 2.2 FacesFlow - @FlowScoped, #{flowScope}, @FlowDefinition
(&lt;a
href="https://blogs.oracle.com/arungupta/entry/jsf_2_2_faces_flow"&gt;TOTD

#198&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Java EE 7 Maven Application (&lt;a
href="https://blogs.oracle.com/arungupta/entry/java_ee_7_maven_application"&gt;TOTD

#197&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Default Data Source in Java EE 7: Lesser XML and More Defaults
(&lt;a
href="https://blogs.oracle.com/arungupta/entry/default_datasource_in_java_ee"&gt;TOTD

#196&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;JPA 2.1 Implementation - EclipseLink M6 integrated in
GlassFish 4 (&lt;a
href="https://blogs.oracle.com/arungupta/entry/jpa_2_1_implementation_eclipselink"&gt;TOTD

#195&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;JAX-RS Client API and GlassFish 4 - Logging HTTP Messages (&lt;a
href="https://blogs.oracle.com/arungupta/entry/jax_rs_client_api_and"&gt;TOTD

#194&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;JAX-RS Custom Entity Providers (&lt;a
href="https://blogs.oracle.com/arungupta/entry/jax_rs_custom_entity_providers"&gt;TOTD

#193&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Batch Applications in Java EE 7 (&lt;a
href="https://blogs.oracle.com/arungupta/entry/batch_applications_in_java_ee"&gt;TOTD

#192&lt;/a&gt;)&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Simple
JMS 2.0 Sample (&lt;a
href="https://blogs.oracle.com/arungupta/entry/simple_jms_2_0_sample"&gt;TOTD
#191&lt;/a&gt;)
&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/what_s_new_in_servlet"&gt;What's

New
in Servlet 3.1 ?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/concurrency_utilities_for_java_ee"&gt;Concurrency

Utilities
for Java EE&lt;/a&gt; (JSR 236)&lt;/li&gt;
&lt;li&gt;Collaborative
Whiteboard using WebSocket in GlassFish 4 (&lt;a
href="https://blogs.oracle.com/arungupta/entry/collaborative_whiteboard_using_websocket_in"&gt;TOTD
#189&lt;/a&gt;)
&lt;/li&gt;
&lt;li&gt;Non-blocking
I/O using Servlet 3.1 (&lt;a
href="https://blogs.oracle.com/arungupta/entry/non_blocking_i_o_using"&gt;TOTD
#188&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/what_s_new_in_ejb"&gt;What's

New
in EJB 3.2 ?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;JPA
2.1 Schema Generation (&lt;a
href="https://blogs.oracle.com/arungupta/entry/jpa_2_1_schema_generation"&gt;TOTD
#187&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/websocket_applications_using_java_jsr"&gt;WebSocket

Applications
using Java&lt;/a&gt; (JSR 356)&lt;/li&gt;
&lt;li&gt;Jersey
2 in GlassFish 4 (&lt;a
href="https://blogs.oracle.com/arungupta/entry/jersey_2_in_glassfish_4"&gt;TOTD
#182&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;WebSocket
and Java EE 7 (&lt;a
href="https://blogs.oracle.com/arungupta/entry/websockets_and_java_ee_7"&gt;TOTD
#181&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/json_p_java_api_for"&gt;Java

API
for JSON Processing&lt;/a&gt; (JSR 353)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/jms_2_0_early_draft"&gt;JMS

2.0
Early Draft&lt;/a&gt; (JSR 343)&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/LqILl-sMlD8" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/websocketclient_in_glassfish_4_totd</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/create_managedexecutorservice_managedscheduledexecutorservice_managedthreadfactory_contextservice</id>
        <title type="html">Create ManagedExecutorService, ManagedScheduledExecutorService, ManagedThreadFactory, ContextService in GlassFish 4 build 74  (TOTD #203)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/Vca9Ygg841Q/create_managedexecutorservice_managedscheduledexecutorservice_managedthreadfactory_contextservice" />
        <published>2013-02-11T14:37:32+00:00</published>
        <updated>2013-02-11T14:37:32+00:00</updated> 
        <category term="/General" label="General" />
        <category term="concurrency" scheme="http://roller.apache.org/ns/tags/" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr236" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
Latest &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/latest-glassfish.zip"&gt;GlassFish
4 promoted build&lt;/a&gt; (&lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b74.zip"&gt;74&lt;/a&gt;
at this time) has the first cut of &lt;a
href="http://java.net/projects/concurrency-ee-spec"&gt;Concurrency
Utilities for Java EE&lt;/a&gt; (&lt;a
href="http://jcp.org/en/jsr/detail?id=236"&gt;JSR 236&lt;/a&gt;)
implementation integrated. An &lt;a
href="https://blogs.oracle.com/arungupta/entry/concurrency_utilities_for_java_ee"&gt;earlier
blog&lt;/a&gt; provided an overview of the specification, lets see what
can be actually done with this build.&lt;br&gt;
&lt;br&gt;
This build introduce new commands to create &lt;code&gt;ManagedExecutorService&lt;/code&gt;,
&lt;code&gt;ManagedScheduledExecutorService&lt;/code&gt;, &lt;code&gt;ManagedThreadFactory&lt;/code&gt;,
and &lt;code&gt;ContextService&lt;/code&gt;.&lt;br&gt;
&lt;br&gt;
A simple command execution as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;b&gt;asadmin create-managed-executor-service concurrent/myExecutor&lt;/b&gt;&lt;br&gt;Managed executor service concurrent/myExecutor created successfully.&lt;br&gt;Command create-managed-executor-service executed successfully.&lt;/pre&gt;
&lt;br&gt;
creates the configuration for a default &lt;code&gt;ManagedExecutorService&lt;/code&gt;.
Adding &lt;code&gt;--help&lt;/code&gt; shows more details about the command:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;b&gt;create-managed-executor-service&lt;/b&gt;&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [--enabled=true]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [--contextinfo=contextinfo]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [--threadpriority=5]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [--longrunningtasks=false]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [--hungafterseconds=hungafterseconds]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [--corepoolsize=0]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [--maximumpoolsize=2147483647]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [--keepaliveseconds=60]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [--threadlifetimeseconds=0]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [--taskqueuecapacity=2147483647]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [--description=description]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [--property=property]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [--target=target]&lt;br&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; jndi_name&lt;/pre&gt;
&lt;br&gt;
The created executor can then be injected into a Java EE component
(say Servlet) as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@Resource(name = "concurrent/myExecutor")&lt;br&gt;ManagedExecutorService executor;&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
or looked up using JNDI as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;InitialContext ctx = new InitialContext();&lt;br&gt;ManagedExecutorService executor = (ManagedExecutorService) ctx.lookup("concurrent/myExecutor");&lt;/pre&gt;
&lt;br&gt;
A task can be defined as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;public class MyRunnableTask implements Runnable {&lt;br&gt;&lt;br&gt; private int id;&lt;br&gt;&lt;br&gt; public MyRunnableTask(int id) {&lt;br&gt; this.id = id;&lt;br&gt; }&lt;br&gt;&lt;br&gt; @Override&lt;br&gt; public void run() {&lt;br&gt; try {&lt;br&gt; System.out.format("%d (runnable): starting", id);&lt;br&gt; System.out.format("%d (runnable): sleeping 2 seconds", id);&lt;br&gt; Thread.sleep(2000);&lt;br&gt; System.out.format("%d (runnable): complete", id);&lt;br&gt; } catch (InterruptedException ex) {&lt;br&gt; Logger.getLogger(TestResourceServlet.class.getName()).log(Level.SEVERE, null, ex);&lt;br&gt; }&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
Task can be submitted as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;Future&amp;lt;?&amp;gt; f = executor.submit(new MyRunnableTask(1));&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
OR&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;executor.execute(new MyRunnableTask(2));&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
A task may also be defined as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;public class MyCallableTask implements Callable&amp;lt;Product&amp;gt; {&lt;br&gt;&lt;br&gt; private int id;&lt;br&gt; &lt;br&gt; public MyCallableTask(int id) {&lt;br&gt; this.id = id;&lt;br&gt; }&lt;br&gt; &lt;br&gt; @Override&lt;br&gt; public Product call() {&lt;br&gt; try {&lt;br&gt; System.out.format("%d (callable): starting", id);&lt;br&gt; System.out.format("%d (callable): sleeping 2 seconds", id);&lt;br&gt; Thread.sleep(2000);&lt;br&gt; System.out.format("%d (callable): complete", id);&lt;br&gt; } catch (InterruptedException ex) {&lt;br&gt; Logger.getLogger(TestResourceServlet.class.getName()).log(Level.SEVERE, null, ex);&lt;br&gt; }&lt;br&gt; return new Product(id);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
where &lt;code&gt;Product&lt;/code&gt; is a domain-specific class. In this
case, the task is submited for execution as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;Future&amp;lt;Product&amp;gt; f2 = executor.submit(new MyCallableTask(3));&lt;br&gt;&lt;/pre&gt;
A &lt;code&gt;ManagedScheduledExecutorService&lt;/code&gt; can be created as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;b&gt;asadmin create-managed-scheduled-executor-service concurrent/myScheduledExecutor&lt;/b&gt;&lt;br&gt;Managed scheduled executor service concurrent/myScheduledExecutor created successfully.&lt;br&gt;Command create-managed-scheduled-executor-service executed successfully.&lt;/pre&gt;
&lt;br&gt;
A &lt;code&gt;ManagedThreadFactory&lt;/code&gt; can be created as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;b&gt;asadmin create-managed-thread-factory concurrent/myThreadFactory&lt;/b&gt;&lt;br&gt;Managed thread factory concurrent/myThreadFactory created successfully.&lt;br&gt;Command create-managed-thread-factory executed successfully.&lt;/pre&gt;
&lt;br&gt;
A &lt;code&gt;ContextService&lt;/code&gt; can be created as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;b&gt;asadmin create-context-service concurrent/myContextService&lt;/b&gt;&lt;br&gt;Context service concurrent/myContextService created successfully.&lt;br&gt;Command create-context-service executed successfully.&lt;/pre&gt;
&lt;br&gt;
Note, this is the first integration and some of the options may not
work. But you can definitely start playing around with basic stuff
now.&lt;br&gt;
&lt;br&gt;
The complete source code used in this &lt;b&gt;T&lt;/b&gt;ip &lt;b&gt;O&lt;/b&gt;f &lt;b&gt;T&lt;/b&gt;he
&lt;b&gt;D&lt;/b&gt;ay (TOTD) is &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd203-executor.zip"&gt;available
here&lt;/a&gt; and will run on &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b74.zip"&gt;GlassFish
4 b74&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/Vca9Ygg841Q" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/create_managedexecutorservice_managedscheduledexecutorservice_managedthreadfactory_contextservice</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/resource_library_contracts_in_jsf2</id>
        <title type="html"> Resource Library Contracts in JSF2.2 (TOTD #202)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/VPZAuWTN_nY/resource_library_contracts_in_jsf2" />
        <published>2013-02-08T09:33:45+00:00</published>
        <updated>2013-02-08T17:54:12+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaserverfaces" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr344" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
JavaServer Faces 2 introduced Facelets as the default View
Declaration Language. Facelets allows to create templates using
XHTML and CSS that can be then used to provide a consistent
look-and-feel across different pages of an application. JSF 2.2
defines Resource Library Contracts that allow facelet templates to
be applied to an entire application in a reusable and
interchangeable manner. &lt;br&gt;
&lt;br&gt;
This &lt;b&gt;T&lt;/b&gt;ip &lt;b&gt;O&lt;/b&gt;f The &lt;b&gt;D&lt;/b&gt;ay (TOTD) will explain how
you can leverage them in your web application.&lt;br&gt;
&lt;br&gt;
The complete source code for this sample can be &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd202-contracts-source.zip"&gt;downloaded
here&lt;/a&gt;. This will run on GlassFish build 72 + &lt;a
href="https://maven.java.net/content/groups/public/org/glassfish/javax.faces/2.2.0-SNAPSHOT/"&gt;latest
JSF
2.2.0 SNAPSHOT&lt;/a&gt; copied over
"glassfish3/glassfish/modules/javax.faces.jar" file.&lt;br&gt;
&lt;br&gt;
Consider the following WAR file:&lt;br&gt;
&lt;pre&gt;index.xhtml
user/index.xhtml
contracts/blue/layout.css
contracts/blue/template.xhtml
contracts/red
contracts/red/layout.css
contracts/red/template.xhtml
WEB-INF/faces-config.xml&lt;/pre&gt;
&lt;br&gt;
The application also has two pages - "index.xhtml" and
"user/index.xhtml". All contracts reside in the "contracts"
directory of the WAR. All templates and resources for a contract are
in their own directory. For example, the structure above has two
defined contracts "blue" and "red". Each contract has a
"template.xhtml" and a CSS. Each template is called as "declared
template". The "template.xhtml" has &amp;lt;ui:insert&amp;gt; tags called as
"declared insertion points". CSS and other resources bundled in the
directory are "declared resources". The "declared template",
"declared insertion points", and "declared resources" together make
the definition of the resource library contract. A template client
needs to know the value of all three in order to use the contract.&lt;br&gt;
&lt;br&gt;
In our case, templates have similar "ui:insert" sections and
template clients will accordingly have "ui:define" sections. The
difference will primarily be in the CSS. "index.xhtml" will refer to
the template as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&amp;lt;ui:composition template="/template.xhtml"&amp;gt;&lt;br&gt; &amp;lt;ui:define name="content"&amp;gt;&lt;br&gt; . . .&lt;br&gt; &amp;lt;/ui:define&amp;gt;&lt;br&gt;&amp;lt;/ui:composition&amp;gt;&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
The usage of the contracts is defined in "faces-config.xml" as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&amp;lt;application&amp;gt;&lt;br&gt; &amp;lt;resource-library-contracts&amp;gt;&lt;br&gt; &amp;lt;contract-mapping&amp;gt;&lt;br&gt; &amp;lt;url-pattern&amp;gt;/user/*&amp;lt;/url-pattern&amp;gt;&lt;br&gt; &amp;lt;contracts&amp;gt;blue&amp;lt;/contracts&amp;gt;&lt;br&gt; &amp;lt;/contract-mapping&amp;gt;&lt;br&gt; &amp;lt;contract-mapping&amp;gt;&lt;br&gt; &amp;lt;url-pattern&amp;gt;*&amp;lt;/url-pattern&amp;gt;&lt;br&gt; &amp;lt;contracts&amp;gt;red&amp;lt;/contracts&amp;gt;&lt;br&gt; &amp;lt;/contract-mapping&amp;gt;&lt;br&gt; &amp;lt;/resource-library-contracts&amp;gt;&lt;br&gt;&amp;lt;/application&amp;gt;&lt;br&gt;&lt;/pre&gt;
A contract is applied based upon the URL pattern invoked. Based upon
the configuration specified here, "red" contract will be applied to
"faces/index.xhtml" and "red" contract will be applied to
"faces/user/index.xhtml". &lt;br&gt;
&lt;br&gt;
The template of the page can be changed dynamically as well. For
example consider "index.xhtml" is updated as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&amp;lt;f:view contracts="#{contractsBean.contract}"&amp;gt;&lt;br&gt; &amp;lt;ui:composition template="/template.xhtml"&amp;gt;&lt;br&gt;&lt;br&gt; &amp;lt;ui:define name="content"&amp;gt;&lt;br&gt; &amp;lt;a href="#{facesContext.externalContext.requestContextPath}/faces/user/index.xhtml"&amp;gt;Go to&amp;lt;/a&amp;gt; other contract&lt;br&gt; &amp;lt;p/&amp;gt;&lt;br&gt; Look at WEB-INF/faces-config.xml for contract configuration.&lt;br&gt; &amp;lt;p/&amp;gt;&amp;lt;p/&amp;gt;&lt;br&gt; Choose a template:&amp;lt;br/&amp;gt;&lt;br&gt; &amp;lt;h:form&amp;gt;&lt;br&gt; &amp;lt;h:selectOneRadio value="#{contractsBean.contract}" layout="pageDirection" required="true"&amp;gt;&lt;br&gt; &amp;lt;f:selectItem itemValue="red" itemLabel="red"/&amp;gt;&lt;br&gt; &amp;lt;f:selectItem itemValue="blue" itemLabel="blue"/&amp;gt;&lt;br&gt; &amp;lt;/h:selectOneRadio&amp;gt;&lt;br&gt; &amp;lt;h:commandButton value="Apply" action="index" /&amp;gt;&lt;br&gt; &amp;lt;/h:form&amp;gt;&lt;br&gt; &amp;lt;/ui:define&amp;gt;&lt;br&gt;&lt;br&gt; &amp;lt;/ui:composition&amp;gt;&lt;br&gt;&amp;lt;/f:view&amp;gt;&lt;br&gt;&lt;/pre&gt;
The "ui:composition" is included in "f:view". An additional
"contracts" attribute can bind to an EL. The value of this EL is
populated from the radio button in the newly added form. Now you can
choose a radio button, click on the "Apply" button and the new
template will be applied to the page. The bean is very trivial:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@Named&lt;br&gt;@SessionScoped&lt;br&gt;public class ContractsBean implements Serializable {&lt;br&gt; &lt;br&gt; String contract = "red";&lt;br&gt;&lt;br&gt; public String getContract() {&lt;br&gt; return contract;&lt;br&gt; }&lt;br&gt;&lt;br&gt; public void setContract(String contract) {&lt;br&gt; this.contract = contract;&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
This is a very powerful feature. Imagine providing different
look-and-feel for your website and letting the user choose them, fun
eh ?&lt;br&gt;
&lt;br&gt;
Contracts may be packaged as a JAR file. Such a JAR file maybe
bundled in "WEB-INF/lib" directory. Read section 2.7 for more
details about the packaging requirement and a marker file that
identifies the JAR to contain a contract.&lt;br&gt;
&lt;br&gt;
In the specification ...&lt;br&gt;
&lt;ul&gt;
&lt;li&gt; Section 10.1.3 provide background on the feature.&lt;/li&gt;
&lt;li&gt;Section 2.7 provide formal definition of the feature.&lt;/li&gt;
&lt;li&gt;Section 11.4.2.1 defines how the contracts are identified
during application startup.&lt;/li&gt;
&lt;/ul&gt;
Create templates as JAR files and reuse them across different
applications, enjoy!&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/VPZAuWTN_nY" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/resource_library_contracts_in_jsf2</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/jfokus_2013_trip_report_a</id>
        <title type="html">Jfokus 2013 Trip Report - A Magnificent Spectacle</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/Gnv0fwCH4OI/jfokus_2013_trip_report_a" />
        <published>2013-02-07T09:44:18+00:00</published>
        <updated>2013-02-07T10:15:47+00:00</updated> 
        <category term="/General" label="General" />
        <category term="conf" scheme="http://roller.apache.org/ns/tags/" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jfokus" scheme="http://roller.apache.org/ns/tags/" />
        <category term="netbeans" scheme="http://roller.apache.org/ns/tags/" />
        <category term="stockholm" scheme="http://roller.apache.org/ns/tags/" />
        <category term="sweden" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
This was my third consecutive year (&lt;a
href="https://blogs.oracle.com/arungupta/entry/jfokus_2012_trip_report"&gt;2012&lt;/a&gt;,
&lt;a
href="https://blogs.oracle.com/arungupta/entry/jfokus_2011_day_3_trip"&gt;2011&lt;/a&gt;)
at Jfokus and the organizing committee, and Mattias Karlsson in
particular, continue to amaze me every year! As one of my colleague
mentioned, it truly has become a "magnificent spectacle".&lt;br&gt;
&lt;br&gt;
With the conference sold out 2 weeks before the official start, 1550
attendees from 20+ countries were delighted by a barrage of
international speakers. This was the biggest Jfokus ever and the bar
has always gone higher from the previous years.&lt;br&gt;
&lt;br&gt;
The conference kickstarted with a guided tour of &lt;a
href="http://www.old-town-stockholm.com/"&gt;Old Town Stockholm&lt;/a&gt;
and was a good way to get familiar with history of the city. &lt;br&gt;
&lt;br&gt;
&lt;table border="0" cellpadding="5" cellspacing="5"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh4.googleusercontent.com/-E8wmHgZv5F4/URM6nmfWf3I/AAAAAAAAm1g/BYuxHQqTtoE/s288/DSCN4239.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh4.googleusercontent.com/-47vyIL-6SP8/URM6qYofgSI/AAAAAAAAm2U/mF0ekya_jXA/s288/DSCN4250.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="center" valign="top"&gt;&lt;img alt=""
src="https://lh4.googleusercontent.com/-H-nuqP-KfFA/URM6qkgmO8I/AAAAAAAAm2Y/HAzNmi5gGJQ/s288/DSCN4252.JPG"
height="288" width="216"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td align="center" valign="top"&gt;&lt;img alt=""
src="https://lh6.googleusercontent.com/-qcCy7EqQQzo/URM6rE8GEnI/AAAAAAAAm2k/9ot-u3ehkGI/s288/DSCN4253.JPG"
height="288" width="216"&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh6.googleusercontent.com/-TwNubLflqa8/URM6rnok2GI/AAAAAAAAm2s/jxXTJb83dPA/s288/DSCN4254.JPG"
height="216" width="288"&gt; &lt;/td&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh4.googleusercontent.com/-XLJm73f_0Ks/URM6r8ah_zI/AAAAAAAAm20/h02eR2Pl2pw/s288/DSCN4256.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
The conference had hands-on lab on the first day and technical
sessions, BoFs, &lt;a href="http://hackergarten.net/"&gt;HackerGarten&lt;/a&gt;,
&lt;a href="http://steveonjava.com/nighthacking/"&gt;NightHacking&lt;/a&gt;, &lt;a
href="http://www.mejsla.se/"&gt;Swedish massage by Mejsla&lt;/a&gt; and
other activities on day 2 and 3. Even though the conference had
several tracks but the best track is always the "hallway track"
which gives you the unique opportunity to engage with other
attendees of the conference.&lt;br&gt;
&lt;br&gt;
Markus and I delivered a lab on "&lt;a
href="http://www.jfokus.se/jfokus/talks.jsp#Hands-on%20Lab%3A%20Developing%20JAX-RS%20Web%20Applications%20Utilizing%20Server-Sent%20Events%20and%20WebSocket"&gt;Developing




JAX-RS Web Applications Utilizing Server-sent Events and
WebSockets&lt;/a&gt;". Geertjan also showed up at the lab and helped out
with general NetBeans questions. The lab guide is &lt;a
href="https://github.com/jersey/hol-sse-websocket/blob/master/lab-guide.pdf?raw=true"&gt;available&lt;/a&gt;
and the complete source code can be &lt;a
href="https://github.com/jersey/hol-sse-websocket"&gt;downloaded here&lt;/a&gt;.
Note, the lab works on &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b57.zip"&gt;GlassFish




4.0 build 57&lt;/a&gt; for now because of the pending &lt;a
href="http://java.net/jira/browse/JERSEY-1633"&gt;bugs in SSE
implementation in Jersey&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
The last 45 minutes of the lab had a different section covering some
other Java EE 7 technologies. The lab guide is available at &lt;a
href="http://bit.ly/javaee7-hol"&gt;bit.ly/javaee7-hol&lt;/a&gt; (PDF) and
the starting code is available at &lt;a
href="http://bit.ly/javaee7-hol-code"&gt;bit.ly/javaee7-hol-code&lt;/a&gt;
(ZIP). For now, this particular lab covers:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/java_ee_7_maven_application"&gt;Java



EE 7 Maven Coordinates&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/default_datasource_in_java_ee"&gt;Default



DataSource&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/jpa_2_1_schema_generation"&gt;JPA



2.1 Schema Generation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/collaborative_whiteboard_using_websocket_in"&gt;WebSocket



- Endpoint and JavaScript client&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/jsf_2_2_faces_flow"&gt;JSF



2.2 Faces Flow&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This lab is a work in progress and a more comprehensive feature
set will be integrated and shared at future conferences (yes,
several are already planned!). Let me know if you'll be interested
in reviewing the contents and providing feedback. &lt;br&gt;
&lt;br&gt;
Here are some pics from the lab session:&lt;br&gt;
&lt;/p&gt;
&lt;table border="0" cellpadding="5" cellspacing="5"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh4.googleusercontent.com/-mLuKwv7aNwc/URM6sZ-ryXI/AAAAAAAAm28/17SuafZfeQE/s288/DSCN4257.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh3.googleusercontent.com/-5VK0HZiWlq8/URM6tBEjVOI/AAAAAAAAm3I/xLkdEH08Z80/s288/DSCN4259.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh6.googleusercontent.com/-mBKozWSy8pc/URM662r7utI/AAAAAAAAm7s/_Ll4OSjMXeI/s288/IMG_2191.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh6.googleusercontent.com/-c3ygPmhIBoY/URM66SBVrVI/AAAAAAAAm7c/6JA0oohm7yw/s288/IMG_2189.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
The conference also had its first #GeekRun. 7 of us ran in sub-zero
temperature in the dark around the island and it was a great
experience!&lt;br&gt;
&lt;br&gt;
&lt;img alt=""
src="https://lh6.googleusercontent.com/-9w6YAbLbDNc/URM67-4PDkI/AAAAAAAAm8I/h6JosDB7Dfo/s800/IMG_2194.JPG"
height="300" width="400"&gt;&lt;br&gt;
&lt;br&gt;
Here is the running route:&lt;br&gt;
&lt;br&gt;
&lt;a href="http://runkeeper.com/user/ArunGupta/activity/146814789"&gt;&lt;img
alt=""
src="https://blogs.oracle.com/arungupta/resource/jfokus2013-geekrun.png"
border="2" height="306" width="592"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
The evening concluded with an outstanding speakers' dinner at &lt;a
href="http://f12.se/en/"&gt;F12&lt;/a&gt;. The hospitality of the
restaurant, warmth of the Jfokus events team, and company of some of
the finest geeks in the world made the evening memorable. Some pics
from the dinner ...&lt;br&gt;
&lt;br&gt;
&lt;table border="0" cellpadding="5" cellspacing="5"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh5.googleusercontent.com/-dTL81VSCa4c/URM6tbec1EI/AAAAAAAAm3U/Kxni0VsDtBw/s288/DSCN4261.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh4.googleusercontent.com/-oo3r9iNw6lc/URM6uf1_M2I/AAAAAAAAm3g/26QgZgAtSw0/s288/DSCN4263.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh4.googleusercontent.com/-CShffP1U034/URM6wVkHu_I/AAAAAAAAm4M/Ms1P0w0_qfE/s288/DSCN4271.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh5.googleusercontent.com/-grzxpFjBjqU/URM6whkfSOI/AAAAAAAAm4Q/I8qZQ07IlLY/s288/DSCN4277.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
I delivered a session on &lt;a
href="http://www.jfokus.se/jfokus/talks.jsp#The%20Java%20EE%207%20Platform%3A%20Productivity%20%26%20HTML5"&gt;The
Java EE 7 Platform: Productivity++ and Embracing HTML5&lt;/a&gt;. There
were about 100+ attendees for the 9am session. It gave a quick
overview of the features coming in Java EE 7:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Java API for WebSocket&lt;/li&gt;
&lt;li&gt;Java API for JSON Processing&lt;/li&gt;
&lt;li&gt;Concurrency Utilities for Java EE&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Batch Applications for Java Platform&lt;/li&gt;
&lt;li&gt;JAX-RS 2.0&lt;/li&gt;
&lt;li&gt;JMS 2&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And several other technologies which are getting an update. The
complete slides are available:&lt;br&gt;
&lt;/p&gt;
&amp;nbsp;&lt;br&gt;
&lt;iframe src="http://www.slideshare.net/arungupta1/slideshelf"
marginwidth="0" marginheight="0" style="border:none;"
allowfullscreen="" webkitallowfullscreen="" mozallowfullscreen=""
frameborder="0" height="470px" scrolling="no" width="615px"&gt;&lt;/iframe&gt;
&lt;br&gt;
The session also showed a quick demo of the latest &lt;a
href="http://bertram2.netbeans.org:8080/job/web-main-javaee7/"&gt;NetBeans



build&lt;/a&gt; supporting &lt;a href="http://wiki.netbeans.org/JavaEE7"&gt;Java



EE 7&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
In &lt;a
href="http://www.jfokus.se/jfokus/talks.jsp?lang=en#How%20to%20participate%20in%20the%20future%20of%20Java"&gt;How



to participate in the future of Java&lt;/a&gt;, I talkd about how
several JUGs are contributing to &lt;a
href="http://glassfish.java.net/adoptajsr/"&gt;Adopt-a-JSR efforts
around Java EE 7&lt;/a&gt;. There are 19 JUGs from around the world that
are participating in this effort. What is your JUG waiting for ?
Join the momentum now!&lt;br&gt;
&lt;br&gt;
Here are some more pictures from the conference:&lt;br&gt;
&lt;br&gt;
&lt;table border="0" cellpadding="5" cellspacing="5"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh4.googleusercontent.com/-gllqo9q7oJ4/URM6yWAHfEI/AAAAAAAAm4w/MtTPsZ3yovA/s288/DSCN4283.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh3.googleusercontent.com/-X7x6CGNGKsM/URM68kU5MrI/AAAAAAAAm8c/CpBTK09pYus/s288/IMG_2199.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt; &lt;img alt=""
src="https://lh3.googleusercontent.com/-IW7VnST2SOE/URM6zfOueaI/AAAAAAAAm5Q/Re4L30doUEY/s288/DSCN4287.JPG"
height="216" width="288"&gt;&lt;/td&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh4.googleusercontent.com/-MP4mlCXcdaM/URM6z3JlfPI/AAAAAAAAm5Y/JYqbzPAx3u0/s288/DSCN4289.JPG"
height="216" width="288"&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh4.googleusercontent.com/-HoHGPtTSgxY/URM60kfmGWI/AAAAAAAAm5k/78VjOD6wk2k/s288/DSCN4292.JPG"
height="216" width="288"&gt; &lt;/td&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh3.googleusercontent.com/-eycMKNUNEEo/URM62Dl77gI/AAAAAAAAm6Q/bdTtb-lSAhc/s288/DSCN4299.JPG"
height="216" width="288"&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh4.googleusercontent.com/-LTA3l3NFMAg/URM62-OZZGI/AAAAAAAAm6g/oeHTSMMLTJg/s288/DSCN4302.JPG"
height="216" width="288"&gt; &lt;/td&gt;
&lt;td align="center" valign="top"&gt;&lt;img alt=""
src="https://lh3.googleusercontent.com/-g8MjRHpNEMw/URM632PwXGI/AAAAAAAAm7E/NITA7RS0ets/s288/DSCN4308.JPG"
height="288" width="216"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh3.googleusercontent.com/-5wXtnnyE2z0/URM6_F8LZaI/AAAAAAAAm9I/r3uTD-jh_Cs/s288/IMG_2208.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;td valign="top"&gt;&lt;img alt=""
src="https://lh4.googleusercontent.com/-U5mEyb-GmA8/URM651b1fRI/AAAAAAAAm7U/nbV0Y0OtIhY/s288/DSCN4311.JPG"
height="216" width="288"&gt;&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
The conference collected feedback for each talk using green, red,
and yellow cards, a concept &lt;a
href="https://blogs.oracle.com/arungupta/entry/oredev_2010_trip_report"&gt;first





found in Oredev&lt;/a&gt;. As explained in the opening keynote, the rule
is getting green cards is good, yelllow card means so so and red
card means the speaker is not coming back to the conference. Here
are the cards that I received after my talk on Java EE 7:&lt;br&gt;
&lt;br&gt;
&lt;img alt=""
src="https://lh6.googleusercontent.com/-7oP7q4h-Djw/URM69gN4gtI/AAAAAAAAm8w/LpPpX7a9f_g/s800/IMG_2205.JPG"
height="300" width="400"&gt;&lt;br&gt;
&lt;br&gt;
I've heard the rumor that Nordic conferences don't like to repeat
speakers for more than 2-3 years in a row. This was my third year
but hey, the cards are all green. I'm keeping my fingers crossed for
next year ;-)&lt;br&gt;
&lt;br&gt;
Anyway, congratulations once again Mattias and team for a job very
well done!&lt;br&gt;
&lt;br&gt;
And the complete photo album:&lt;br&gt;
&lt;embed type="application/x-shockwave-flash"
src="https://picasaweb.google.com/s/c/bin/slideshow.swf"
flashvars="host=picasaweb.google.com&amp;amp;hl=en_US&amp;amp;feat=flashalbum&amp;amp;RGB=0x000000&amp;amp;feed=https%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2F101195212405190467512%2Falbumid%2F5842077592921751729%3Falt%3Drss%26kind%3Dphoto%26hl%3Den_US"
pluginspage="http://www.macromedia.com/go/getflashplayer"
height="192" width="288"&gt; &lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/Gnv0fwCH4OI" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/jfokus_2013_trip_report_a</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/java_ee_7_maven_archetype</id>
        <title type="html">Java EE 7 Maven Archetype - Available in NetBeans (TOTD #201)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/2VKBOAglJww/java_ee_7_maven_archetype" />
        <published>2013-02-02T05:40:25+00:00</published>
        <updated>2013-02-02T05:40:25+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="netbeans" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
Want to create a Java EE 7 application using Maven ?&lt;br&gt;
&lt;br&gt;
&lt;b&gt;mvn -DarchetypeGroupId=org.codehaus.mojo.archetypes
-DarchetypeArtifactId=webapp-javaee7
-DarchetypeVersion=0.1-SNAPSHOT
-DarchetypeRepository=https://nexus.codehaus.org/content/repositories/snapshots/
-DgroupId=org.glassfish -DartifactId=javaee7-sample
-Dversion=1.0-SNAPSHOT -Dpackage=org.glassfish.javaee7-sample
-Darchetype.interactive=false --batch-mode --update-snapshots
archetype:generate&lt;/b&gt;&lt;br&gt;
[INFO] Scanning for projects...&lt;br&gt;
Downloading:
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-metadata.xml&lt;br&gt;
Downloading:
http://repo1.maven.org/maven2/org/codehaus/mojo/maven-metadata.xml&lt;br&gt;
Downloaded:
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-metadata.xml
(11 KB at 42.6 KB/sec)&lt;br&gt;
Downloaded:
http://repo1.maven.org/maven2/org/codehaus/mojo/maven-metadata.xml
(22 KB at 65.6 KB/sec)&lt;br&gt;
Downloading:
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml&lt;br&gt;
Downloaded:
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml
(701 B at 4.3 KB/sec)&lt;br&gt;
[INFO]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&lt;br&gt;
[INFO]
------------------------------------------------------------------------&lt;br&gt;
[INFO] Building Maven Stub Project (No POM) 1&lt;br&gt;
[INFO]
------------------------------------------------------------------------&lt;br&gt;
Downloading:
http://repo1.maven.org/maven2/org/codehaus/mojo/maven-metadata.xml&lt;br&gt;
Downloading:
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-metadata.xml&lt;br&gt;
Downloaded:
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-metadata.xml
(11 KB at 64.9 KB/sec)&lt;br&gt;
Downloaded:
http://repo1.maven.org/maven2/org/codehaus/mojo/maven-metadata.xml
(22 KB at 77.8 KB/sec)&lt;br&gt;
Downloading:
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml&lt;br&gt;
Downloaded:
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml
(701 B at 3.1 KB/sec)&lt;br&gt;
[INFO] &lt;br&gt;
[INFO] &amp;gt;&amp;gt;&amp;gt; maven-archetype-plugin:2.2:generate
(default-cli) @ standalone-pom &amp;gt;&amp;gt;&amp;gt;&lt;br&gt;
[INFO] &lt;br&gt;
[INFO] &amp;lt;&amp;lt;&amp;lt; maven-archetype-plugin:2.2:generate
(default-cli) @ standalone-pom &amp;lt;&amp;lt;&amp;lt;&lt;br&gt;
[INFO] &lt;br&gt;
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @
standalone-pom ---&lt;br&gt;
[INFO] Generating project in Batch mode&lt;br&gt;
[INFO] Archetype defined by properties&lt;br&gt;
Downloading:
https://nexus.codehaus.org/content/repositories/snapshots/org/codehaus/mojo/archetypes/webapp-javaee7/0.1-SNAPSHOT/maven-metadata.xml&lt;br&gt;
Downloaded:
https://nexus.codehaus.org/content/repositories/snapshots/org/codehaus/mojo/archetypes/webapp-javaee7/0.1-SNAPSHOT/maven-metadata.xml
(786 B at 0.5 KB/sec)&lt;br&gt;
Downloading:
https://nexus.codehaus.org/content/repositories/snapshots/org/codehaus/mojo/archetypes/webapp-javaee7/0.1-SNAPSHOT/maven-metadata.xml&lt;br&gt;
Downloaded:
https://nexus.codehaus.org/content/repositories/snapshots/org/codehaus/mojo/archetypes/webapp-javaee7/0.1-SNAPSHOT/maven-metadata.xml
(786 B at 2.0 KB/sec)&lt;br&gt;
[INFO]
----------------------------------------------------------------------------&lt;br&gt;
[INFO] Using following parameters for creating project from
Archetype: webapp-javaee7:0.1-SNAPSHOT&lt;br&gt;
[INFO]
----------------------------------------------------------------------------&lt;br&gt;
[INFO] Parameter: groupId, Value: org.glassfish&lt;br&gt;
[INFO] Parameter: artifactId, Value: javaee7-sample&lt;br&gt;
[INFO] Parameter: version, Value: 1.0-SNAPSHOT&lt;br&gt;
[INFO] Parameter: package, Value: org.glassfish.javaee7-sample&lt;br&gt;
[INFO] Parameter: packageInPathFormat, Value:
org/glassfish/javaee7-sample&lt;br&gt;
[INFO] Parameter: package, Value: org.glassfish.javaee7-sample&lt;br&gt;
[INFO] Parameter: version, Value: 1.0-SNAPSHOT&lt;br&gt;
[INFO] Parameter: groupId, Value: org.glassfish&lt;br&gt;
[INFO] Parameter: artifactId, Value: javaee7-sample&lt;br&gt;
[INFO] project created from Archetype in dir:
/Users/arungup/code/workspaces/tmp/javaee7-sample&lt;br&gt;
[INFO]
------------------------------------------------------------------------&lt;br&gt;
[INFO] BUILD SUCCESS&lt;br&gt;
[INFO]
------------------------------------------------------------------------&lt;br&gt;
[INFO] Total time: 4.703s&lt;br&gt;
[INFO] Finished at: Sat Feb 02 07:31:54 EET 2013&lt;br&gt;
[INFO] Final Memory: 11M/125M&lt;br&gt;
[INFO]
------------------------------------------------------------------------&lt;br&gt;
&lt;br&gt;
That's it!&lt;br&gt;
&lt;br&gt;
&lt;a href="http://bertram2.netbeans.org:8080/job/web-main-javaee7/"&gt;NetBeans
Development Builds&lt;/a&gt; allows to create a Maven-based Java EE 7
web application now. &lt;a href="http://wiki.netbeans.org/JavaEE7"&gt;wiki.netbeans.org/JavaEE7&lt;/a&gt;
provide a complete list of planned features. &lt;a
href="https://blogs.oracle.com/arungupta/entry/java_ee_7_and_netbeans"&gt;TOTD
#199&lt;/a&gt; provide some more details on the features currently
working. Of course, this application will get deployed to &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/"&gt;GlassFish
4&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/2VKBOAglJww" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/java_ee_7_maven_archetype</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/glassfish_4_latest_builds_zip</id>
        <title type="html">GlassFish 4 Latest Builds, Zip, API, and Javadocs (TOTD #200)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/Rx0UA4Pq-8g/glassfish_4_latest_builds_zip" />
        <published>2013-01-30T12:00:00+00:00</published>
        <updated>2013-01-30T12:00:00+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javanet" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
Do you want a handy link to the latest GlassFish builds, zip
bundles, Java EE 7 API jar or javadocs ?&lt;br&gt;
&lt;br&gt;
Now they are available at &lt;a
href="http://download.java.net/glassfish/4.0/promoted/"&gt;download.java.net/glassfish/4.0/promoted&lt;/a&gt;!&lt;br&gt;
&lt;br&gt;
&lt;a href="http://download.java.net/glassfish/4.0/promoted/"&gt;&lt;img
alt=""
src="https://blogs.oracle.com/arungupta/resource/totd200-latest-glassfish.png"
border="2" height="345" width="625"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
The pattern is: &lt;code&gt;download.java.net/glassfish/4.0/promoted/latest-*&lt;/code&gt;.&lt;br&gt;
&lt;br&gt;
So &lt;a
href="http://%20download.java.net/glassfish/4.0/promoted/latest-glassfish.zip"&gt;&lt;a
href="http://download.java.net/glassfish/4.0/promoted/latest-glassfish.zip"&gt;download.java.net/glassfish/4.0/promoted/latest-glassfish.zip&lt;/a&gt;&lt;/a&gt;
gives you the latest GlassFish zip bundle. Similarly &lt;a
href="http://download.java.net/glassfish/4.0/promoted/latest-javaee-api-javadoc.jar"&gt;
download.java.net/glassfish/4.0/promoted/latest-javaee-api-javadoc.jar&lt;/a&gt;
gives you the latest Java EE 7 javadocs and &lt;a
href="http://download.java.net/glassfish/4.0/promoted/latest-web-unix.sh"&gt;
download.java.net/glassfish/4.0/promoted/latest-web-unix.sh&lt;/a&gt;
gives you the latest Unix installer for Java EE 7 Web profile. These
are all in turn link to the latest promoted build.&lt;br&gt;
&lt;br&gt;
The complete set of promoted builds are available as usual at &lt;a
href="http://download.java.net/glassfish/4.0/promoted"&gt;download.java.net/glassfish/4.0/promoted&lt;/a&gt;.
And the nightly builds at &lt;a
href="http://download.java.net/glassfish/4.0/nightly"&gt;download.java.net/glassfish/4.0/nightly&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
What is your favorite location to download GlassFish builds ?&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/Rx0UA4Pq-8g" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/glassfish_4_latest_builds_zip</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/java_ee_7_and_netbeans</id>
        <title type="html">Java EE 7 and NetBeans IDE - Early Support Available (TOTD #199)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/NjPlp9DM2YY/java_ee_7_and_netbeans" />
        <published>2013-01-29T18:38:31+00:00</published>
        <updated>2013-01-29T18:44:59+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="netbeans" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
&lt;a href="http://netbeans.org"&gt;NetBeans IDE&lt;/a&gt; provides the best
out-of-the-box experience for Java EE development, deployment, and
debugging. &lt;a
href="http://bertram2.netbeans.org:8080/job/web-main-javaee7/"&gt;Early
builds of NetBeans&lt;/a&gt; have already started providing support for
Java EE 7 features such as&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Registering GlassFish 4&lt;/li&gt;
&lt;li&gt;Creating Java EE 7 application&lt;/li&gt;
&lt;li&gt;Wizard for JAX-RS 2 Filters/Interceptors&lt;/li&gt;
&lt;li&gt;Initial support for Faces Flow&lt;/li&gt;
&lt;li&gt;Loading templates from a resource library&lt;/li&gt;
&lt;li&gt;Non-persistent EJB timers in Web profile&lt;/li&gt;
&lt;li&gt;Wizard for WebSocket endpoints&lt;/li&gt;
&lt;/ul&gt;
&lt;a href="http://wiki.netbeans.org/JavaEE7"&gt;wiki.netbeans.org/JavaEE7&lt;/a&gt;
provide a complete list of features slated for the release and the
builds can be downloaded from &lt;a
href="http://bertram2.netbeans.org:8080/job/web-main-javaee7/"&gt;bertram2.netbeans.org:8080/job/web-main-javaee7&lt;/a&gt;.
Here are some snapshots of the work completed so far.&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Creating a Java EE 7 Web application&lt;/b&gt;&lt;b&gt; and using GlassFish 4
server&lt;/b&gt;&lt;br&gt;
&lt;img alt=""
src="https://blogs.oracle.com/arungupta/resource/totd199-glassfish4-server.png"
height="243" width="431"&gt;&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Creating a WebSocket endpoint&lt;/b&gt;&lt;br&gt;
&lt;img alt=""
src="https://blogs.oracle.com/arungupta/resource/totd199-websocket-endpoint.png"
height="195" width="427"&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Wizard for creating WebSocket endpoint&lt;/b&gt;&lt;br&gt;
&lt;img alt=""
src="https://blogs.oracle.com/arungupta/resource/totd199-websocket-endpoint-new.png"
height="319" width="523"&gt;&lt;br&gt;
&lt;br&gt;
The generated code looks like:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@WebSocketEndpoint("/endpoint")&lt;br&gt;public class NewWSEndpoint {&lt;br&gt;&lt;br&gt; @WebSocketMessage&lt;br&gt; public String onMessage(String message) {&lt;br&gt; return null;&lt;br&gt; }&lt;br&gt; &lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
&lt;b&gt;Creating a JAX-RS 2 Filter&lt;/b&gt;&lt;br&gt;
&lt;img alt=""
src="https://blogs.oracle.com/arungupta/resource/totd199-jaxrs2-filter.png"
height="221" width="475"&gt;&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Wizard for creating a JAX-RS 2 Filter&lt;/b&gt;&lt;br&gt;
&lt;img alt=""
src="https://blogs.oracle.com/arungupta/resource/totd199-jaxrs2-filter-new.png"
height="444" width="517"&gt;&lt;br&gt;
&lt;br&gt;
By default it is a server-side filter but can be made client-side
filter too.&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Wizard for creating a JAX-RS 2 Interceptor&lt;/b&gt;&lt;br&gt;
&lt;img alt=""
src="https://blogs.oracle.com/arungupta/resource/totd199-jaxrs2-interceptor-new.png"
height="438" width="513"&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Creating a RESTful Java Client using JAX-RS 2 Client APIs&lt;/b&gt;&lt;br&gt;
&lt;img alt=""
src="https://blogs.oracle.com/arungupta/resource/totd199-restful-java-client.png"
height="320" width="483"&gt;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Wizard for creating a JAX-RS 2 Client&lt;/b&gt;&lt;br&gt;
&lt;img alt=""
src="https://blogs.oracle.com/arungupta/resource/totd199-restful-java-client-new.png"
height="507" width="515"&gt;&lt;br&gt;
&lt;br&gt;
This is a very early work-in-progress so any &lt;a
href="mailto:nbusers@netbeans.org"&gt;feedback&lt;/a&gt; is welcome.&lt;br&gt;
&lt;br&gt;
Download &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/"&gt;GlassFish

4.0 promoted build&lt;/a&gt;, register it with NetBeans IDE and take it
for a test drive!&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/NjPlp9DM2YY" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/java_ee_7_and_netbeans</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/jsf_2_2_faces_flow</id>
        <title type="html">JSF 2.2 Faces Flow - @FlowScoped, #{flowScope}, @FlowDefinition (TOTD #198)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/oce45na14c4/jsf_2_2_faces_flow" />
        <published>2013-01-28T23:03:16+00:00</published>
        <updated>2013-01-28T23:12:52+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="netbeans" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html"> &lt;br&gt;
JavaServer Faces 2.2 is more evolutionary than it is revolutionary.
This is by design as JSF 2.0 added a whole bunch of new features as
part of the Java EE 6 platform. The Preface 1 from the &lt;a
href="http://download.oracle.com/otndocs/jcp/jsf-2_2-pr-spec/index.html"&gt;JSF



2.2 Public Review specification&lt;/a&gt; provides a list of changes
between JSF 2.1 and 2.2. There are several changes coming in JSF 2.2
but the &lt;a
href="http://java.net/jira/secure/IssueNavigator.jspa?mode=hide&amp;amp;requestId=11471"&gt;big



ticket items&lt;/a&gt; are:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Faces Flow&lt;/li&gt;
&lt;li&gt;Resource Library Contract&lt;/li&gt;
&lt;li&gt;HTML5 Friendly Markup&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
This &lt;b&gt;T&lt;/b&gt;ip &lt;b&gt;O&lt;/b&gt;f &lt;b&gt;T&lt;/b&gt;he &lt;b&gt;D&lt;/b&gt;ay (TOTD) will
explain &lt;a
href="http://javaserverfaces-spec-public.java.net/nonav/proposals/JAVASERVERFACES_SPEC_PUBLIC-730/proposal.txt"&gt;Faces



Flow&lt;/a&gt;. Section 7.5 and 11.4.3 in the specification introduce
the feature.&lt;br&gt;
&lt;br&gt;
Faces Flow provides an encapsulation of related views/pages with an
application defined entry and exit points. For example, a check out
cart can consist of cart page, credit card details page, shipping
address page, and confirmation page. All these pages, along with
required resources and beans, can be packaged together as a module
which can then be reused in other applications. &lt;br&gt;
&lt;br&gt;
Each flow has a well-defined entry and exit point that have been
assigned some application specific meaning by the developer. Usually
the objects in a faces flow are designed to allow the user to
accomplish a task that requires input over a number of different
views. In our case, the navigation between pages for selecting
items, entering shipping address, credit card details, and
confirmation page would make a flow. All the pages and objects that
deal with the checking out process can be composed as modules. An
application thus become a collection of flows instead of just views.&lt;br&gt;
&lt;br&gt;
It takes the best part of other flow-based technologies such as ADF
Task Flow, Spring Web Flow, and Apace MyFaces CODI and standardizes
in JSF 2.2.&lt;br&gt;
&lt;br&gt;
&lt;b&gt; What is the need ? &lt;/b&gt;&lt;br&gt;
&lt;br&gt;
Imagine a multi-page shopping cart with one page for selecting the
items, a second page for shipping options, a third page for entering
credit card details, and a fourth page for final confirmation.
Managed Beans can be used to capture the data, session scope
variables pass information between pages, button clicks can be used
to invoke the business logic in backing EJBs, and (conditional)
navigation rules can be defined to go from one page to another.
There are a few issues with this approach:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;This flow of sequence will typically be part of a bigger
application. However an application, typically with several
pages, is one large flow and everything is visible with no
logical partitioning.&lt;/li&gt;
&lt;li&gt;The flow of pages or views cannot be encapsulated as a logical
unit and thus cannot be reused, e.g. incorporated into another
bigger flow easily.&lt;/li&gt;
&lt;li&gt;The lowest logical granularity is a page. The only way to
invoke application logic is to tie it to a UI component
activated by the user in a page. Business logic cannot be
invoked without any user initiated action.&lt;/li&gt;
&lt;li&gt;Same flow cannot be opened in multiple windows because session
scoped variables are used to pass information between pages. CDI
defines &lt;code&gt;@ConversationScoped&lt;/code&gt; but that is only part
of the solution.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;There is no scope defined that can span multiple pages but
less than a session.&lt;/li&gt;
&lt;/ul&gt;
Faces Flow provide a solution to the issues mentioned above.&lt;br&gt;
&lt;br&gt;
&lt;b&gt;What's new in JSF 2.2 for flows ?&lt;/b&gt;&lt;br&gt;
&lt;br&gt;
The flow of application is no longer restricted to flow between
pages but instead defined as flow between "nodes". There are five
different types of nodes:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;View: Any JSF page in the application&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Method Call: Invoke application logic from flow graph via an
EL&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Switch: Navigation decisions in the flow graph based on
boolean EL&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Flow Call: Call another flow with parameters and receive
return values&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Flow Return: Return to the calling flow&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
The nodes define the entry and exit points of a flow.&lt;br&gt;
&lt;br&gt;
Two new annotations are introduced:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;@FlowScoped&lt;/code&gt; is a CDI scope that defines the scope
of bean in the specified flow. This enables automatic
activation/passivation of the bean when the scope is
entered/exited.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;@FlowDefinition&lt;/code&gt; is a class level annotation that
allows the flow definition to be defined using the fluent &lt;code&gt;FlowBuilder&lt;/code&gt;
API.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
A new EL object, &lt;code&gt;#{flowScope}&lt;/code&gt;, for flow local storage
is also introduced. This maps to &lt;code&gt;facesContext.getApplication().getFlowHandler().getCurrentFlowScope()&lt;/code&gt;.&lt;br&gt;
&lt;br&gt;
&lt;b&gt;How are flows packaged ?&lt;/b&gt;&lt;br&gt;
&lt;br&gt;
Flows can be packaged in JAR files or in directories.&lt;br&gt;
&lt;br&gt;
JAR packaging requires flows to be explicitly declared in &lt;code&gt;META-INF/faces-config.xml&lt;/code&gt;
in the JAR file. Flow nodes are packaged in &lt;code&gt;META-INF/flows/&amp;lt;flowname&amp;gt;&lt;/code&gt;
where &lt;code&gt;&amp;lt;flowname&amp;gt;&lt;/code&gt; is a JAR directory entry whose
name is identical to that of a flow id in the corresponding &lt;code&gt;faces-config.xml&lt;/code&gt;.
&lt;code&gt;@FlowScoped&lt;/code&gt; and &lt;code&gt;@FlowDefinition&lt;/code&gt; beans
must be packaged in the JAR file and accompanied by &lt;code&gt;META-INF/beans.xml&lt;/code&gt;.
&lt;br&gt;
&lt;br&gt;
A sample JAR file looks like:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;META-INF/faces-config.xml
META-INF/flows/flow1/entry.xhtml
META-INF/flows/flow1/next.xhtml
META-INF/flows/flow1/end.xhtml
META-INF/flows/flow2/start.xhtml
META-INF/flows/flow2/next.xhtml
META-INF/flows/flow2/end.xhtml
META-INF/beans.xml
org/glassfish/sample/MyFlow1Bean.class
org/glassfish/sample/MyFlow2Bean.class
org/glassfish/sample/MyFlowDefintion.class&lt;/pre&gt;
Flows packaged in directories use convention-over-configuration. The
conventions are:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Every View Declaration Language file in that directory is a
view node of that flow.&lt;/li&gt;
&lt;li&gt;The start node of the flow is the view whose name is the same
as the name of the flow.&lt;/li&gt;
&lt;li&gt;Navigation among any of the views in the directory is
considered to be within the flow.&lt;/li&gt;
&lt;li&gt;Navigation to a view outside of that directory is considered
to be an exit of the flow.&lt;/li&gt;
&lt;li&gt;Optional &lt;code&gt;&amp;lt;flowname&amp;gt;-flow.xml&lt;/code&gt; that
represents the flow definition. The rules in this file overrides
the conventions described above.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A sample directory looks like:&lt;br&gt;
&lt;/p&gt;
&lt;pre&gt;flow1/flow1.xhtml&lt;br&gt;flow1/flow1a.xhtml&lt;br&gt;flow1/flow1b.xhtml&lt;br&gt;flow2/flow2-flow.xml&lt;br&gt;flow2/flow2.xhtml&lt;br&gt;flow2/flow2a.xhtml&lt;br&gt;flow2/flow2b.xhtml&lt;br&gt;WEB-INF/...&lt;br&gt;&lt;/pre&gt;
&lt;b&gt; &lt;/b&gt;&lt;b&gt;Show me the code!&lt;/b&gt;&lt;br&gt;
&lt;br&gt;
Lets try a sample now!&lt;br&gt;
&lt;br&gt;
The source code for the two samples explained below can be &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd198-flow.zip"&gt;downloaded

here&lt;/a&gt;. A complete explanation of the sample including the code
walk-through is shown in the video:&lt;br&gt;
&lt;br&gt;
&lt;iframe width="640" height="360" src="http://www.youtube.com/embed/sczWa97oy6U" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;
 &lt;br&gt;&lt;br&gt;
This will run on &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b72.zip"&gt;GlassFish

4.0 b72&lt;/a&gt;. For now, you'll need to replace &lt;code&gt;glassfish/modules/javax.faces.jar&lt;/code&gt;
with &lt;a
href="https://maven.java.net/content/groups/public/org/glassfish/javax.faces/2.2.0-SNAPSHOT/javax.faces-2.2.0-20130126.094249-235.jar"&gt;javax.faces-2.2.0-SNAPSHOT.jar&lt;/a&gt;
and replacing &lt;code&gt;glassfish/modules/javax.el.jar&lt;/code&gt; with &lt;a
href="http://search.maven.org/remotecontent?filepath=org/glassfish/javax.el/3.0-b03/javax.el-3.0-b03.jar"&gt;javax-el-3.0-b03.jar&lt;/a&gt;.
This JARs will soon be integrated in the GlassFish build. Ah, the
joys of bleeding edge development!&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/oce45na14c4" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/jsf_2_2_faces_flow</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/java_ee_7_maven_application</id>
        <title type="html">Java EE 7 Maven Application (TOTD #197)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/nWivjFm2Co8/java_ee_7_maven_application" />
        <published>2013-01-26T14:39:39+00:00</published>
        <updated>2013-01-26T14:39:39+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="maven" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;p&gt;Did you know that Java EE 7 APIs are now published in maven ?&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;The complete set of coordinates are &lt;a
href="https://wikis.oracle.com/display/GlassFish/Java+EE+7+Maven+Coordinates"&gt;described

here&lt;/a&gt;. So how do you build a simple Java EE 7 maven
application ?&lt;br&gt;
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Generate the ususal Java EE 6 maven application as:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;mvn -DarchetypeGroupId=org.codehaus.mojo.archetypes
-DarchetypeArtifactId=webapp-javaee6 -DarchetypeVersion=1.5
-DarchetypeRepository=http://repo.maven.apache.org/maven2
-DgroupId=org.glassfish -DartifactId=hello-javaee7
-Dversion=1.0-SNAPSHOT -Dpackage=org.glassfish.hellojavaee7
-Darchetype.interactive=false --batch-mode archetype:generate&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;In the generated pom.xml, replace&lt;br&gt;
&lt;pre&gt;&amp;lt;dependencies&amp;gt;&lt;br&gt; &amp;lt;dependency&amp;gt;&lt;br&gt; &amp;lt;groupId&amp;gt;javax&amp;lt;/groupId&amp;gt;&lt;br&gt; &amp;lt;artifactId&amp;gt;javaee-web-api&amp;lt;/artifactId&amp;gt;&lt;br&gt; &amp;lt;version&amp;gt;6.0&amp;lt;/version&amp;gt;&lt;br&gt; &amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;&lt;br&gt; &amp;lt;/dependency&amp;gt;&lt;br&gt;&amp;lt;/dependencies&amp;gt;&lt;br&gt;&lt;/pre&gt;
&lt;p&gt;with&lt;br&gt;
&lt;/p&gt;
&lt;pre&gt;&amp;lt;repositories&amp;gt;&lt;br&gt; &amp;lt;repository&amp;gt; &lt;br&gt; &amp;lt;id&amp;gt;Java EE 7&amp;lt;/id&amp;gt; &lt;br&gt; &amp;lt;url&amp;gt;https://maven.java.net/content/groups/promoted/&amp;lt;/url&amp;gt; &lt;br&gt; &amp;lt;/repository&amp;gt; &lt;br&gt;&amp;lt;/repositories&amp;gt;&lt;br&gt;&lt;br&gt;&amp;lt;dependencies&amp;gt;&lt;br&gt; &amp;lt;dependency&amp;gt; &lt;br&gt; &amp;lt;groupId&amp;gt;javax&amp;lt;/groupId&amp;gt; &lt;br&gt; &amp;lt;artifactId&amp;gt;javaee-api&amp;lt;/artifactId&amp;gt; &lt;br&gt; &amp;lt;version&amp;gt;7.0-b72&amp;lt;/version&amp;gt; &lt;br&gt; &amp;lt;/dependency&amp;gt; &lt;br&gt;&amp;lt;/dependencies&amp;gt;&lt;/pre&gt;
&lt;br&gt;
Notice, there is a new &amp;lt;version&amp;gt; of dependency for each &lt;a
href="http://download.java.net/glassfish/4.0/promoted/"&gt;GlassFish
4 promoted build&lt;/a&gt;. This may be simplified in the coming
builds.&lt;br&gt;
&lt;br&gt;
The &amp;lt;artifactId&amp;gt; can be changed to &lt;code&gt;javaee-web-api&lt;/code&gt;
if your application requires Java EE 7 Web Profile API only.&lt;br&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;And now all Java EE 7 APIs so far integrated in GlassFish are
available in your application.&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;You can also include specific API JAR files explicitly in your
project directly. The latest APIs are available in the format:&lt;br&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Java EE 7 Full Platform: &lt;a
href="http://download.java.net/glassfish/4.0/promoted/javaee-api-7.0-b72.jar"&gt;http://download.java.net/glassfish/4.0/promoted/javaee-api-7.0-b72.jar&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Java EE 7 Web Profile: &lt;a
href="http://download.java.net/glassfish/4.0/promoted/javaee-web-api-7.0-b72.jar"&gt;http://download.java.net/glassfish/4.0/promoted/javaee-web-api-7.0-b72.jar&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Corresponding javadocs: &lt;a
href="http://download.java.net/glassfish/4.0/promoted/javaee-web-api-7.0-b72-javadoc.jar"&gt;http://download.java.net/glassfish/4.0/promoted/javaee-web-api-7.0-b72-javadoc.jar&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In general, you can replace "b72" in the URL with the latest
promoted build number to get the latest artifacts. A simplified
URL for the latest set of these artifacts is in the works!&lt;br&gt;
&lt;/p&gt;
&lt;ol&gt;
&lt;/ol&gt;
&lt;p&gt;What next ? Maven archetype and &lt;a
href="http://wiki.netbeans.org/JavaEE7"&gt;support in NetBeans
coming soon&lt;/a&gt;!&lt;br&gt;
&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/nWivjFm2Co8" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/java_ee_7_maven_application</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/default_datasource_in_java_ee</id>
        <title type="html"> Default DataSource in Java EE 7: Lesser XML and More Defaults (TOTD #196)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/BEQwpQAKEtQ/default_datasource_in_java_ee" />
        <published>2013-01-23T07:30:00+00:00</published>
        <updated>2013-01-23T07:30:00+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jpa" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jpa21" scheme="http://roller.apache.org/ns/tags/" />
        <category term="persistence" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
Section E.5.5.20 in the &lt;a
href="http://download.oracle.com/otndocs/jcp/java_ee-7-pr-spec/index.html"&gt;Java
EE 7 Platform specification&lt;/a&gt; defines a new Default Data Source
that must be provided by a Java EE 7-compliant runtime. This
pre-configured data source can be used by application for accessing
the associated database. It is accessible to the application under
the JNDI name:&lt;br&gt;
&lt;pre&gt;
java:comp/DefaultDataSource&lt;/pre&gt;
&lt;br&gt;
This can be accessed in the application as:&lt;br&gt;
&lt;pre&gt;
@Resource(name="myDataSource", lookup="java:comp/DefaultDataSource")&lt;br&gt;DataSource myDS;&lt;/pre&gt;
&lt;br&gt;
If the binding is not specified, the mapping of the reference will
default to this default data source. So the above fragment is
equivalent to:&lt;br&gt;
&lt;pre&gt;
@Resource(name="myDataSource")&lt;br&gt;DataSource myDS;&lt;/pre&gt;
&lt;br&gt;
Section 8.2.1.5 in the &lt;a
href="http://download.oracle.com/otndocs/jcp/persistence-2_1-pr-spec/index.html"&gt;JPA
2.1 specification&lt;/a&gt; says &lt;br&gt;
&lt;br&gt;
&lt;meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1"&gt;
&lt;p&gt;&lt;i&gt;If neither &lt;/i&gt;&lt;i&gt;&lt;code&gt;jta-data-source&lt;/code&gt;&lt;/i&gt;&lt;i&gt; and &lt;/i&gt;&lt;i&gt;&lt;code&gt;non-jta-data-source&lt;/code&gt;&lt;/i&gt;&lt;i&gt;
elements are specified, the deployer must specify a JTA data
source at deployment or a JTA data source must be provided by
the container, and a JTA
&lt;/i&gt;&lt;i&gt;&lt;code&gt; EntityManagerFactory&lt;/code&gt;&lt;/i&gt;&lt;i&gt; will be created
to correspond to it.
&lt;/i&gt; &lt;/p&gt;
&lt;title&gt;Per.book&lt;/title&gt;
&lt;br&gt;
This means a Java EE 7 application can have the following
persistence.xml:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br&gt;&amp;lt;persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&amp;gt;&lt;br&gt; &amp;lt;persistence-unit name="myPU" transaction-type="JTA"&amp;gt;&lt;br&gt; &lt;b&gt;&amp;lt;jta-data-source&amp;gt;java:comp/DefaultDataSource&amp;lt;/jta-data-source&amp;gt;&lt;/b&gt;&lt;br&gt; &amp;lt;/persistence-unit&amp;gt;&lt;br&gt;&amp;lt;/persistence&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
This is semantically equivalent to:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br&gt;&amp;lt;persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&amp;gt;&lt;br&gt; &amp;lt;persistence-unit name="movieplex7PU" transaction-type="JTA"/&amp;gt;&lt;br&gt;&amp;lt;/persistence&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
Notice, no &lt;code&gt;jta-data-source&lt;/code&gt;.&lt;br&gt;
&lt;br&gt;
In both cases, the default data source will be provisioned and
available to the application. In GlassFish 4, this is bound to the
JDBC resource &lt;code&gt;jdbc/__default&lt;/code&gt;.&lt;br&gt;
&lt;br&gt;
And this can be verified by giving the command:&lt;br&gt;
&lt;pre&gt;./bin/asadmin list-jdbc-resources&lt;br&gt;jdbc/sample&lt;br&gt;jdbc/__TimerPool&lt;br&gt;&lt;b&gt;jdbc/__default&lt;/b&gt;&lt;br&gt;Command list-jdbc-resources executed successfully.&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
Lesser XML and more defaults makes Java EE 7 more lightweight and
user friendly!&lt;br&gt;
&lt;br&gt;
Download &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/"&gt;GlassFish
4.0 promoted build&lt;/a&gt; and try it today!&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/BEQwpQAKEtQ" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/default_datasource_in_java_ee</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/jpa_2_1_implementation_eclipselink</id>
        <title type="html">JPA 2.1 Implementation - EclipseLink M6 integrated in GlassFish 4 (TOTD #195)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/0dDRGTSozCM/jpa_2_1_implementation_eclipselink" />
        <published>2013-01-18T22:46:29+00:00</published>
        <updated>2013-01-18T22:46:29+00:00</updated> 
        <category term="/General" label="General" />
        <category term="eclipselink" scheme="http://roller.apache.org/ns/tags/" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jpa" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr338" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">As &lt;a
href="https://blogs.oracle.com/arungupta/entry/jpa_2_1_schema_generation"&gt;TOTD
#187&lt;/a&gt; explained, one of the new features in JPA 2.1 is Schema
Generation. It refers to generation of database artifacts like
tables, indexes, and constraints in a database schema. Read &lt;a
href="https://blogs.oracle.com/arungupta/entry/jpa_2_1_schema_generation"&gt;TOTD
#187&lt;/a&gt; for more details. This &lt;b&gt;T&lt;/b&gt;ip &lt;b&gt;O&lt;/b&gt;f &lt;b&gt;T&lt;/b&gt;he
&lt;b&gt;D&lt;/b&gt;ay (TOTD) will explain how to use this feature in GlassFish
4.&lt;br&gt;
&lt;br&gt;
JPA 2.1 is implemented in EclipseLink and the &lt;a
href="http://wiki.eclipse.org/EclipseLink/Development/JPA_2.1"&gt;status&lt;/a&gt;
shows that a decent progress is made. &lt;a
href="http://www.eclipse.org/eclipselink/downloads/milestones.php"&gt;EclipseLink
Milestone&lt;/a&gt; builds shows the dates when milestones are released.
It typically takes a few days for the milestone to be integrated in
GlassFish 4 after the release.&lt;br&gt;
&lt;br&gt;
How do you know which milestone is integrated in GlassFish 4 ?&lt;br&gt;
&lt;br&gt;
Issue the following commmand in &lt;code&gt;glassfish/modules&lt;/code&gt;
directory:&lt;br&gt;
&lt;pre&gt;unzip -p org.eclipse.persistence.core.jar META-INF/MANIFEST.MF | grep Bundle-Version&lt;/pre&gt;
to see an output as:&lt;br&gt;
&lt;pre&gt;Bundle-Version: 2.5.0.v20130110-d839ca4&lt;/pre&gt;
If we break the version string then it shows this is version 2.5.0
and dated 20130110 in the format YYYYMMDD, that would be Jan 10,
2013. Based upon the &lt;a
href="http://www.eclipse.org/eclipselink/downloads/milestones.php"&gt;milestone
release dates&lt;/a&gt;, this indicates M6 is integrated.&lt;br&gt;
&lt;br&gt;
I tried this with the &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/nightly/latest-glassfish.zip"&gt;latest
nightly build&lt;/a&gt; (dated Jan 18). By the time you read this blog,
a newer version may be integrated and so the version string may look
different.&lt;br&gt;
&lt;br&gt;
Now lets see this in action!&lt;br&gt;
&lt;br&gt;
The sample code explained below can be &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd195-schema-gen.zip"&gt;downloaded
here&lt;/a&gt; and run on &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/nightly/glassfish-4.0-b72-01_17_2013.zip"&gt;GlassFish
4 1/17 nightly&lt;/a&gt;. A promoted build after this nightly should
work too.&lt;br&gt;
&lt;br&gt;
Create an Entity class as:&lt;br&gt;
&lt;pre&gt;@Entity&lt;br&gt;@Table&lt;br&gt;@NamedQueries({&lt;br&gt; @NamedQuery(name = "Employee.findAll", query = "SELECT e FROM Employee e")&lt;br&gt;})&lt;br&gt;public class Employee implements Serializable {&lt;br&gt; private static final long serialVersionUID = 1L;&lt;br&gt; @Id&lt;br&gt; @GeneratedValue(strategy = GenerationType.AUTO)&lt;br&gt; private int id;&lt;br&gt; &lt;br&gt; @Column(length=40)&lt;br&gt; private String name;&lt;br&gt;&lt;/pre&gt;
This is a simple &lt;code&gt;Employee&lt;/code&gt; entity that has two fields &lt;code&gt;id&lt;/code&gt;
and &lt;code&gt;name&lt;/code&gt;. A trivial &lt;code&gt;@NamedQuery&lt;/code&gt; is
defined to retrieve the list of employees.&lt;br&gt;
&lt;br&gt;
The associated &lt;code&gt;persistence.xml&lt;/code&gt; looks like:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br&gt;&amp;lt;persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&amp;gt;&lt;br&gt; &amp;lt;persistence-unit name="MyPU" transaction-type="JTA"&amp;gt;&lt;br&gt; &amp;lt;jta-data-source&amp;gt;jdbc/sample&amp;lt;/jta-data-source&amp;gt;&lt;br&gt; &amp;lt;properties&amp;gt;&lt;br&gt; &amp;lt;property name="javax.persistence.schema-generation-action" value="drop-and-create"/&amp;gt;&lt;br&gt; &amp;lt;property name="javax.persistence.schema-generation-target" value="database"/&amp;gt; &lt;br&gt; &amp;lt;property name="eclipselink.deploy-on-startup" value="true"/&amp;gt;&lt;br&gt; &amp;lt;/properties&amp;gt;&lt;br&gt; &amp;lt;/persistence-unit&amp;gt;&lt;br&gt;&amp;lt;/persistence&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
Other than the usual elements like &lt;code&gt;&amp;lt;persistence-unit&amp;gt;&lt;/code&gt;
and &lt;code&gt;&amp;lt;jta-data-source&amp;gt;&lt;/code&gt;, the newly introduced
properties - &lt;code&gt;javax.persistence.schema-generation-action&lt;/code&gt;
and &lt;code&gt;javax.persistence.schema-generation-target&lt;/code&gt; define
the action and target for the schema generation. The action is to
drop and create the tables. The target defines to perform the action
in the database. These properties control the behavior of schema
generation and their meaning is defined in &lt;a
href="https://blogs.oracle.com/arungupta/entry/jpa_2_1_schema_generation"&gt;TOTD
#187&lt;/a&gt;. Notice, the third property is EclipseLink specific and
is specified to eagerly initialize the Persistence Unit. This will
ensure that the schema is generated during the application
deployment itself. Otherwise it is generated when the PU is first
accessed.&lt;br&gt;
&lt;br&gt;
This will generate the table in the database defined by &lt;code&gt;jdbc/sample&lt;/code&gt;
JDBC resource. This resource is pre-defined for JavaDB that is
already bundled with GlassFish 4.&lt;br&gt;
&lt;br&gt;
After this, you can write a simple EJB as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@Stateless&lt;br&gt;public class EmployeeBean {&lt;br&gt;&lt;br&gt; @PersistenceContext&lt;br&gt; EntityManager em;&lt;br&gt; &lt;br&gt; public void persist(Employee e) {&lt;br&gt; em.persist(e);&lt;br&gt; }&lt;br&gt; &lt;br&gt; public List&amp;lt;Employee&amp;gt; get() {&lt;br&gt; return em.createNamedQuery("Employee.findAll", Employee.class).getResultList();&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
And invoke it from a Servlet as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;for (int i=0; i&amp;lt;5; i++) {&lt;br&gt; bean.persist(new Employee("Name" + i));&lt;br&gt;}&lt;br&gt;for (Employee e : bean.get()) {&lt;br&gt; out.println(e.getName() + "&amp;lt;br&amp;gt;");&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
A different set of properties may be specified as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&amp;lt;properties&amp;gt;&lt;br&gt; &amp;lt;property name="javax.persistence.schema-generation-action" value="drop-and-create"/&amp;gt;&lt;br&gt; &amp;lt;property name="javax.persistence.schema-generation-target" value="scripts"/&amp;gt; &lt;br&gt; &amp;lt;property name="javax.persistence.ddl-create-script-target" value="createfoo.sql"/&amp;gt; &lt;br&gt; &amp;lt;property name="javax.persistence.ddl-drop-script-target" value="dropfoo.sql"/&amp;gt; &lt;br&gt; &amp;lt;property name="eclipselink.deploy-on-startup" value="true"/&amp;gt;&lt;br&gt; &amp;lt;property name="eclipselink.application-location" value="/tmp"/&amp;gt;&lt;br&gt;&amp;lt;/properties&amp;gt;&lt;br&gt;&lt;/pre&gt;
These properties specify the &lt;code&gt;action&lt;/code&gt; as
"drop-and-create", i.e. drop and create the tables. The &lt;code&gt;target&lt;/code&gt;
specifies the the action to be performed in a script. The &lt;code&gt;*.script-target&lt;/code&gt;
property specifies the name of the files for create and drop DDL.
The following scripts are generated:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&lt;b&gt;more /tmp/createfoo.sql &lt;/b&gt;&lt;br&gt;CREATE TABLE EMPLOYEE (ID INTEGER NOT NULL, NAME VARCHAR(40), PRIMARY KEY (ID))&lt;br&gt;CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))&lt;br&gt;INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)&lt;br&gt;CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))&lt;br&gt;INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 0)&lt;br&gt;&lt;br&gt;&lt;b&gt;more /tmp/dropfoo.sql &lt;/b&gt;&lt;br&gt;DROP TABLE EMPLOYEE&lt;br&gt;DELETE FROM SEQUENCE WHERE SEQ_NAME = 'SEQ_GEN'&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
By default, the scripts are generated in &lt;code&gt;glassfish/domains/domain1&lt;/code&gt;
directory. In this case, an EclipseLink-specific property to
identify the base location of the generated files is specified.&lt;br&gt;
&lt;br&gt;
As &lt;a
href="https://blogs.oracle.com/arungupta/entry/jpa_2_1_schema_generation"&gt;TOTD
#187&lt;/a&gt; explains, you can bundle DDL and DML scripts to generate
and populate the database. Are you ready to test drive &lt;a
href="http://jcp.org/en/jsr/detail?id=338"&gt;JPA 2.1&lt;/a&gt; implemented
using &lt;a
href="http://wiki.eclipse.org/EclipseLink/Development/2.5.0"&gt;EclipseLink
2.5&lt;/a&gt; in &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/"&gt;GlassFish 4&lt;/a&gt;
?&lt;br&gt;
&lt;br&gt;
&lt;a
href="http://download.oracle.com/otndocs/jcp/persistence-2_1-pr-spec/index.html"&gt;JPA
2.1 Public Review specification&lt;/a&gt; has been available for a few
days now. The Appendix A in the specification provide revision
history in case you want to focus on the newly added features
only.&amp;nbsp; If you are a JUG member, you may consider &lt;a
href="http://glassfish.java.net/adoptajsr/"&gt;adopting this JSR&lt;/a&gt;
and &lt;a href="http://java.net/projects/jpa-spec/lists/users/archive"&gt;provide
feedback&lt;/a&gt;!&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/0dDRGTSozCM" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/jpa_2_1_implementation_eclipselink</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/jax_rs_client_api_and</id>
        <title type="html"> JAX-RS Client API and GlassFish 4 - Logging HTTP messages (TOTD #194)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/_mmRhpNrGtk/jax_rs_client_api_and" />
        <published>2013-01-11T22:32:18+00:00</published>
        <updated>2013-01-11T22:32:18+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jaxrs" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr339" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
One of the main features added in JAX-RS 2 is Client API. This API
is used to access Web resources and provides integration with &lt;a
href="https://blogs.oracle.com/arungupta/entry/jax_rs_custom_entity_providers"&gt;JAX-RS
Providers&lt;/a&gt;. Without this API, the users need to use a low-level
&lt;code&gt;HttpUrlConnection&lt;/code&gt; to access the REST endpoint.&lt;br&gt;
&lt;br&gt;
If the resource looks like:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@Path("/fruit")&lt;br&gt;public class MyResource {&lt;br&gt;&lt;br&gt; @GET&lt;br&gt; public String get() {&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
then, before this API, the endpoint can be accessed as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;URL url = new URL("http://. . ./webresources/fruit");
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) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; //. . .
}&lt;/pre&gt;
With this newly introduced API, the endpoint can be accessed as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;Client client = ClientFactory.newClient();&lt;br&gt;WebTarget target = client.target("http://. . ./webresources/fruit");&lt;br&gt;String response = target.request().get(String.class);&lt;br&gt;&lt;/pre&gt;
&lt;code&gt;Client&lt;/code&gt; is the entry point to the Client API and is used
to build and execute client requests and consume responses returned.
The default instance of &lt;code&gt;Client&lt;/code&gt; can be obtained by
calling &lt;code&gt;ClientFactory.newClient&lt;/code&gt;. Using this we can
create a &lt;code&gt;WebTarget&lt;/code&gt; by specifying URI of the web
resource. These targets are then used to prepare client request
invocation by specifying additional query or matrix parameters and
resolving the URI template for different names. Finally, one of the
HTTP methods is invoked on the prepared client.&lt;br&gt;
&lt;br&gt;
The fluency of the API hides the complexity but a better
understanding of the flow allows to write better code.&lt;br&gt;
&lt;br&gt;
All the classes introduced in the specification are available in &lt;code&gt;javax.ws.rs.client&lt;/code&gt;
package.&lt;br&gt;
&lt;br&gt;
Lets take a look at a complete sample. The complete source code can
be &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd194-endpoint.zip"&gt;downloaded
here&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
For a resource defined as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@Path("/fruit")&lt;br&gt;public class MyResource {&lt;br&gt;&lt;br&gt; @GET&lt;br&gt; public String get() {&lt;br&gt; return Database.getAll();&lt;br&gt; }&lt;br&gt; &lt;br&gt; @GET&lt;br&gt; @Path("{name}")&lt;br&gt; public String get(@PathParam("name")String payload) {&lt;br&gt; return Database.get(payload);&lt;br&gt; }&lt;br&gt; &lt;br&gt; @POST&lt;br&gt; public void post(String payload) {&lt;br&gt; Database.add(payload);&lt;br&gt; }&lt;br&gt; &lt;br&gt; @PUT&lt;br&gt; public void put(String payload) {&lt;br&gt; Database.add(payload);&lt;br&gt; }&lt;br&gt; &lt;br&gt; @DELETE&lt;br&gt; public void delete(String payload) {&lt;br&gt; Database.delete(payload);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
A Client invoking all the HTTP methods look like:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;Client client = ClientFactory.newClient();&lt;br&gt;WebTarget target = client.target("http://" &lt;br&gt; + request.getServerName() &lt;br&gt; + ":"&lt;br&gt; + request.getServerPort()&lt;br&gt; + request.getContextPath()&lt;br&gt; + "/webresources/fruit");&lt;br&gt;&lt;br&gt;// POST&lt;br&gt;target.request().post(Entity.text("apple"));&lt;br&gt;&lt;br&gt;// PUT&lt;br&gt;target.request().put(Entity.text("banana"));&lt;br&gt;&lt;br&gt;// GET (all)&lt;br&gt;String r = target.request().get(String.class);&lt;br&gt;&lt;br&gt;// GET (one)&lt;br&gt;r = target.path("apple").request().get(String.class);&lt;br&gt;&lt;br&gt;// DELETE&lt;br&gt;target.path("banana").request().delete();&lt;br&gt;&lt;br&gt;// GET (all)&lt;br&gt;r = target.request().get(String.class);&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
And here are the message dumps:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;INFO: 1 * LoggingFilter - Request received on thread http-listener-1(5)&lt;br&gt;1 &amp;gt; &lt;b&gt;POST&lt;/b&gt; http://localhost:8080/endpoint/webresources/fruit&lt;br&gt;1 &amp;gt; Content-Type: text/plain&lt;br&gt;apple&lt;br&gt;&lt;br&gt;INFO: 2 * LoggingFilter - Response received on thread http-listener-1(5)&lt;br&gt;2 &amp;lt; 204&lt;br&gt;2 &amp;lt; Date: Fri, 11 Jan 2013 22:21:23 GMT&lt;br&gt;2 &amp;lt; Server: GlassFish Server Open Source Edition 4.0&lt;br&gt;2 &amp;lt; X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 4.0 Java/Oracle Corporation/1.7)&lt;br&gt;&lt;br&gt;INFO: 3 * LoggingFilter - Request received on thread http-listener-1(5)&lt;br&gt;3 &amp;gt; &lt;b&gt;PUT&lt;/b&gt; http://localhost:8080/endpoint/webresources/fruit&lt;br&gt;3 &amp;gt; Content-Type: text/plain&lt;br&gt;banana&lt;br&gt;&lt;br&gt;INFO: 4 * LoggingFilter - Response received on thread http-listener-1(5)&lt;br&gt;4 &amp;lt; 204&lt;br&gt;4 &amp;lt; Date: Fri, 11 Jan 2013 22:21:23 GMT&lt;br&gt;4 &amp;lt; Server: GlassFish Server Open Source Edition 4.0&lt;br&gt;4 &amp;lt; X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 4.0 Java/Oracle Corporation/1.7)&lt;br&gt;&lt;br&gt;INFO: 5 * LoggingFilter - Request received on thread http-listener-1(5)&lt;br&gt;5 &amp;gt; &lt;b&gt;GET&lt;/b&gt; http://localhost:8080/endpoint/webresources/fruit&lt;br&gt;&lt;br&gt;INFO: 6 * LoggingFilter - Response received on thread http-listener-1(5)&lt;br&gt;6 &amp;lt; 200&lt;br&gt;6 &amp;lt; Date: Fri, 11 Jan 2013 22:21:23 GMT&lt;br&gt;6 &amp;lt; Content-Length: 15&lt;br&gt;6 &amp;lt; Content-Type: text/html&lt;br&gt;6 &amp;lt; Server: GlassFish Server Open Source Edition 4.0&lt;br&gt;6 &amp;lt; X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 4.0 Java/Oracle Corporation/1.7)&lt;br&gt;[apple, banana]&lt;br&gt;&lt;br&gt;INFO: 7 * LoggingFilter - Request received on thread http-listener-1(5)&lt;br&gt;7 &amp;gt; &lt;b&gt;GET&lt;/b&gt; http://localhost:8080/endpoint/webresources/fruit/apple&lt;br&gt;&lt;br&gt;INFO: 8 * LoggingFilter - Response received on thread http-listener-1(5)&lt;br&gt;8 &amp;lt; 200&lt;br&gt;8 &amp;lt; Date: Fri, 11 Jan 2013 22:21:23 GMT&lt;br&gt;8 &amp;lt; Content-Length: 5&lt;br&gt;8 &amp;lt; Content-Type: text/html&lt;br&gt;8 &amp;lt; Server: GlassFish Server Open Source Edition 4.0&lt;br&gt;8 &amp;lt; X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 4.0 Java/Oracle Corporation/1.7)&lt;br&gt;apple&lt;br&gt;&lt;br&gt;INFO: 9 * LoggingFilter - Request received on thread http-listener-1(5)&lt;br&gt;9 &amp;gt; &lt;b&gt;DELETE&lt;/b&gt; http://localhost:8080/endpoint/webresources/fruit/banana&lt;br&gt;&lt;br&gt;INFO: 10 * LoggingFilter - Response received on thread http-listener-1(5)&lt;br&gt;10 &amp;lt; 204&lt;br&gt;10 &amp;lt; Date: Fri, 11 Jan 2013 22:21:23 GMT&lt;br&gt;10 &amp;lt; Server: GlassFish Server Open Source Edition 4.0&lt;br&gt;10 &amp;lt; X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 4.0 Java/Oracle Corporation/1.7)&lt;br&gt;&lt;br&gt;INFO: 11 * LoggingFilter - Request received on thread http-listener-1(5)&lt;br&gt;11 &amp;gt; &lt;b&gt;GET&lt;/b&gt; http://localhost:8080/endpoint/webresources/fruit&lt;br&gt;&lt;br&gt;INFO: 12 * LoggingFilter - Response received on thread http-listener-1(5)&lt;br&gt;12 &amp;lt; 200&lt;br&gt;12 &amp;lt; Date: Fri, 11 Jan 2013 22:21:23 GMT&lt;br&gt;12 &amp;lt; Content-Length: 7&lt;br&gt;12 &amp;lt; Content-Type: text/html&lt;br&gt;12 &amp;lt; Server: GlassFish Server Open Source Edition 4.0&lt;br&gt;12 &amp;lt; X-Powered-By: Servlet/3.0 JSP/2.2 (GlassFish Server Open Source Edition 4.0 Java/Oracle Corporation/1.7)&lt;br&gt;[apple]&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
This has been tested on &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b70.zip"&gt;GlassFish
4 build 70&lt;/a&gt; with the following dependencies:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;&amp;lt;dependency&amp;gt;&lt;br&gt; &amp;lt;groupId&amp;gt;javax.ws.rs&amp;lt;/groupId&amp;gt;&lt;br&gt; &amp;lt;artifactId&amp;gt;javax.ws.rs-api&amp;lt;/artifactId&amp;gt;&lt;br&gt; &amp;lt;version&amp;gt;2.0-m10&amp;lt;/version&amp;gt;&lt;br&gt; &amp;lt;type&amp;gt;jar&amp;lt;/type&amp;gt;&lt;br&gt; &amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;&lt;br&gt;&amp;lt;/dependency&amp;gt;&lt;br&gt;&amp;lt;dependency&amp;gt;&lt;br&gt; &amp;lt;groupId&amp;gt;org.glassfish.jersey.core&amp;lt;/groupId&amp;gt;&lt;br&gt; &amp;lt;artifactId&amp;gt;jersey-common&amp;lt;/artifactId&amp;gt;&lt;br&gt; &amp;lt;version&amp;gt;2.0-m10&amp;lt;/version&amp;gt;&lt;br&gt; &amp;lt;type&amp;gt;jar&amp;lt;/type&amp;gt;&lt;br&gt;&amp;lt;/dependency&amp;gt;&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
Here are some more pointers to follow:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a
href="http://jcp.org/aboutJava/communityprocess/pr/jsr339/index.html"&gt;JAX-RS
2

Specification Public Review&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jax-rs-spec.java.net/"&gt;Latest status on
specification&lt;/a&gt; (jax-rs-spec.java.net)&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a
href="http://jax-rs-spec.java.net/nonav/2.0-SNAPSHOT/apidocs/index.html"&gt;Latest
JAX-RS

2.0 Javadocs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jersey.java.net/"&gt;Latest status on Jersey&lt;/a&gt;
(Reference Implementation of JAX-RS 2 - jersey.java.net)&lt;/li&gt;
&lt;li&gt;&lt;a
href="http://jersey.java.net/nonav/apidocs/snapshot/jersey/index.html"&gt;Latest
Jersey

API Javadocs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/latest-glassfish.zip"&gt;Latest
GlassFish

4.0 Promoted Build&lt;/a&gt;&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Follow &lt;a href="https://twitter.com/#%21/gf_jersey"&gt;@gf_jersey&lt;/a&gt;&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Provide feedback on Jersey 2 to &lt;a
href="http://java.net/projects/jersey/lists/users/archive"&gt;users@jersey.java.net&lt;/a&gt;
and JAX-RS specification to &lt;a
href="http://java.net/projects/jax-rs-spec/lists/users/archive"&gt;users@jax-rs-spec.java.net&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/_mmRhpNrGtk" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/jax_rs_client_api_and</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/jax_rs_custom_entity_providers</id>
        <title type="html"> JAX-RS Custom Entity Providers (TOTD #193)</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/Nv2MbYk1x9w/jax_rs_custom_entity_providers" />
        <published>2013-01-07T21:49:52+00:00</published>
        <updated>2013-01-07T21:49:52+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jaxrs" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jersey" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr339" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
JAX-RS defines &lt;i&gt;Entity Providers&lt;/i&gt; that supply mapping services
between on-the-wire representations and their associated Java types.
The entities, also known as "message payload" or "payload" represent
the main part of an HTTP message. These are specified as method
parameters and return types of resource methods. Several standard
Java types such as &lt;code&gt;String&lt;/code&gt;, &lt;code&gt;byte[]&lt;/code&gt;, &lt;code&gt;javax.xml.bind.JAXBElement&lt;/code&gt;,
&lt;code&gt;java.io.InputStream&lt;/code&gt;, &lt;code&gt;java.io.File&lt;/code&gt;, and
others have a pre-defined mapping and is required by the
specification. Applications may provide their own mapping to custom
types using &lt;code&gt;MessageBodyReader&lt;/code&gt; and &lt;code&gt;MessageBody&lt;/code&gt;&lt;code&gt;Writer&lt;/code&gt;
interfaces. This allows to extend the JAX-RS runtime easily to
support your own custom entity providers.&lt;br&gt;
&lt;br&gt;
The &lt;code&gt;MessageBodyReader&lt;/code&gt; interface defines the contract
for a provider that supports the conversion of a stream to a Java
type. The &lt;code&gt;MessageBodyWriter&lt;/code&gt; interface defines the
contract for a provider that supports the conversion of a Java type
to a stream. This &lt;b&gt;T&lt;/b&gt;ip &lt;b&gt;O&lt;/b&gt;f &lt;b&gt;T&lt;/b&gt;he &lt;b&gt;D&lt;/b&gt;ay
(TOTD) will explain how to write these custom entity providers.&lt;br&gt;
&lt;br&gt;
Note, this functionality was defined in JAX-RS 1.0 as opposed to
Client API, Client- and Server-side async, Hypermedia, and many
other features. The complete source code for this sample application
can be &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd193-readerwriter.zip"&gt;downloaded

here&lt;/a&gt; and will work on &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b70.zip"&gt;GlassFish

4.0 b70&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
Here is a simple resource that returns name of the fruit based upon
the &lt;code&gt;index&lt;/code&gt; passed as parameter:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@Path("fruits")&lt;br&gt;public class MyResource {&lt;br&gt; private String[] response = { "apple", "banana", "mango" };&lt;br&gt; &lt;br&gt; @POST&lt;br&gt; public String getFruit(int index) {&lt;br&gt; return response[index % 3];&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
This resource can be invoked using the newly introduced Client API
as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;Client client = ClientFactory.newClient();&lt;br&gt;WebTarget target = client.target("http://"&lt;br&gt; + request.getServerName()&lt;br&gt; + ":"&lt;br&gt; + request.getServerPort()&lt;br&gt; + request.getContextPath()&lt;br&gt; + "/webresources/fruits");&lt;br&gt;String fruit = target&lt;br&gt; .request()&lt;br&gt; .post(Entity.text("1"), String.class);&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
If we update the resource such that the &lt;code&gt;index&lt;/code&gt;
parameter is passed as the following object:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;public class MyObject implements Serializable {&lt;br&gt; public static final String MIME_TYPE = "application/myType";&lt;br&gt;&lt;br&gt; private int index;&lt;br&gt;&lt;br&gt; public MyObject() {&lt;br&gt; }&lt;br&gt;&lt;br&gt; public MyObject(int index) {&lt;br&gt; this.index = index;&lt;br&gt; }&lt;br&gt;&lt;br&gt; public int getIndex() {&lt;br&gt; return index;&lt;br&gt; }&lt;br&gt;&lt;br&gt; public void setIndex(int index) {&lt;br&gt; this.index = index;&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
Then the resource method would look like:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@POST&lt;br&gt;@Consumes(value=MyObject.MIME_TYPE)&lt;br&gt;public String getFruit(MyObject mo) {&lt;br&gt; return response[Integer.valueOf(mo.getIndex()) % 3];&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
The additional &lt;code&gt;@Consumes&lt;/code&gt; annotation defines the media
type that the method can accept. The following custom entity
providers are defined to support this custom type. The first one, &lt;code&gt;MyReader&lt;/code&gt;,
defines the conversion of on-the-wire representation to &lt;code&gt;MyObject&lt;/code&gt;
Java type.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@Provider&lt;br&gt;@Consumes(MyObject.MIME_TYPE)&lt;br&gt;public class MyReader implements MessageBodyReader&amp;lt;MyObject&amp;gt; {&lt;br&gt;&lt;br&gt; @Override&lt;br&gt; public boolean isReadable(Class&amp;lt;?&amp;gt; type, Type type1, Annotation[] antns, MediaType mt) {&lt;br&gt; return MyObject.class.isAssignableFrom(type);&lt;br&gt; }&lt;br&gt;&lt;br&gt; @Override&lt;br&gt; public MyObject readFrom(Class&amp;lt;MyObject&amp;gt; type, &lt;br&gt; Type type1, &lt;br&gt; Annotation[] antns, &lt;br&gt; MediaType mt, MultivaluedMap&amp;lt;String, String&amp;gt; mm, &lt;br&gt; InputStream in) throws IOException, WebApplicationException {&lt;br&gt; try {&lt;br&gt; ObjectInputStream ois = new ObjectInputStream(in);&lt;br&gt; return (MyObject)ois.readObject();&lt;br&gt; } catch (ClassNotFoundException ex) {&lt;br&gt; Logger.getLogger(MyReader.class.getName()).log(Level.SEVERE, null, ex);&lt;br&gt; }&lt;br&gt; return null;&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
The interface require two methods, &lt;code&gt;isReadable&lt;/code&gt; and &lt;code&gt;readFrom&lt;/code&gt;,
to be implemented. The implementation has &lt;code&gt;@Consumes&lt;/code&gt;
annotation restricting the media type supported by this entity
provider.&lt;br&gt;
&lt;br&gt;
The second one, &lt;code&gt;MyWriter&lt;/code&gt;, defines the conversion from
&lt;code&gt;MyObject&lt;/code&gt; Java type to on-the-wire representation.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@Provider&lt;br&gt;@Produces(MyObject.MIME_TYPE)&lt;br&gt;public class MyWriter implements MessageBodyWriter&amp;lt;MyObject&amp;gt; {&lt;br&gt;&lt;br&gt; @Override&lt;br&gt; public boolean isWriteable(Class&amp;lt;?&amp;gt; type, Type type1, Annotation[] antns, MediaType mt) {&lt;br&gt; return MyObject.class.isAssignableFrom(type);&lt;br&gt; }&lt;br&gt;&lt;br&gt; @Override&lt;br&gt; public long getSize(MyObject t, Class&amp;lt;?&amp;gt; type, Type type1, Annotation[] antns, MediaType mt) {&lt;br&gt; // As of JAX-RS 2.0, the method has been deprecated and the &lt;br&gt; // value returned by the method is ignored by a JAX-RS runtime. &lt;br&gt; // All MessageBodyWriter implementations are advised to return -1 from &lt;br&gt; // the method.&lt;br&gt; &lt;br&gt; return -1;&lt;br&gt; }&lt;br&gt;&lt;br&gt; @Override&lt;br&gt; public void writeTo(MyObject t, &lt;br&gt; Class&amp;lt;?&amp;gt; type, &lt;br&gt; Type type1, &lt;br&gt; Annotation[] antns, &lt;br&gt; MediaType mt, &lt;br&gt; MultivaluedMap&amp;lt;String, Object&amp;gt; mm, &lt;br&gt; OutputStream out) throws IOException, WebApplicationException {&lt;br&gt; ObjectOutputStream oos = new ObjectOutputStream(out);&lt;br&gt; oos.writeObject(t);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
The interface require three methods &lt;code&gt;isWriteable&lt;/code&gt;, &lt;code&gt;getSize&lt;/code&gt;,
&lt;code&gt;writeTo&lt;/code&gt; to be implemented. The implementation of
getSize method is recommended to return -1 as JAX-RS runtime is
required to compute the actual &lt;code&gt;Content-Length&lt;/code&gt; header
value. The implementation has &lt;code&gt;@Produces&lt;/code&gt; annotation
restricting the media type supported by this entity provider.&lt;br&gt;
&lt;br&gt;
The reader and writer entity providers are marked with &lt;code&gt;@Provider&lt;/code&gt;
and are thus automatically discovered at runtime on the server-side.
But until &lt;a href="http://java.net/jira/browse/JERSEY-1634"&gt;JERSEY-1634&lt;/a&gt;
is fixed, they need to be explicitly specified in the &lt;code&gt;Application&lt;/code&gt;
class as:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@ApplicationPath("webresources")&lt;br&gt;public class MyApplication extends Application {&lt;br&gt; @Override&lt;br&gt; public Set&amp;lt;Class&amp;lt;?&amp;gt;&amp;gt; getClasses() {&lt;br&gt; Set&amp;lt;Class&amp;lt;?&amp;gt;&amp;gt; resources = new java.util.HashSet&amp;lt;&amp;gt;();&lt;br&gt; resources.add(MyResource.class);&lt;br&gt; resources.add(MyReader.class);&lt;br&gt; resources.add(MyWriter.class);&lt;br&gt; return resources;&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
On the client-side, the providers need to be explicitly registered
as shown:&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;Client client = ClientFactory.newClient();&lt;br&gt;client&lt;br&gt; .configuration()&lt;br&gt; .register(MyReader.class)&lt;br&gt; .register(MyWriter.class);&lt;br&gt;String fruit = target&lt;br&gt; .request()&lt;br&gt; .post(Entity.entity(new MyObject(1), MyObject.MIME_TYPE), String.class);&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
Notice, how invoking the endpoint requires to specify the media type
as part of &lt;code&gt;post&lt;/code&gt; method invocation.&lt;br&gt;
&lt;br&gt;
The complete source code for this sample application can be &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd193-readerwriter.zip"&gt;downloaded

here&lt;/a&gt; and will work on &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/glassfish-4.0-b70.zip"&gt;GlassFish

4.0 b70&lt;/a&gt;.&lt;br&gt;
&lt;p&gt;Here are some more pointers to follow&lt;br&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a
href="http://jcp.org/aboutJava/communityprocess/pr/jsr339/index.html"&gt;JAX-RS
2
Specification Public Review&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jax-rs-spec.java.net/"&gt;Latest status on
specification&lt;/a&gt; (jax-rs-spec.java.net)&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a
href="http://jax-rs-spec.java.net/nonav/2.0-SNAPSHOT/apidocs/index.html"&gt;Latest
JAX-RS
2.0 Javadocs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jersey.java.net/"&gt;Latest status on Jersey&lt;/a&gt;
(Reference Implementation of JAX-RS 2 - jersey.java.net)&lt;/li&gt;
&lt;li&gt;&lt;a
href="http://jersey.java.net/nonav/apidocs/snapshot/jersey/index.html"&gt;Latest
Jersey
API Javadocs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/latest-glassfish.zip"&gt;Latest
GlassFish
4.0 Promoted Build&lt;/a&gt;&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Follow &lt;a href="https://twitter.com/#%21/gf_jersey"&gt;@gf_jersey&lt;/a&gt;&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Provide feedback on Jersey 2 to &lt;a
href="http://java.net/projects/jersey/lists/users/archive"&gt;users@jersey.java.net&lt;/a&gt;
and JAX-RS specification to &lt;a
href="http://java.net/projects/jax-rs-spec/lists/users/archive"&gt;users@jax-rs-spec.java.net&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/Nv2MbYk1x9w" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/jax_rs_custom_entity_providers</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/batch_applications_in_java_ee</id>
        <title type="html"> Batch Applications in Java EE 7 - Undertanding JSR 352 Concepts: TOTD #192</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/Qi6kGuBqXaE/batch_applications_in_java_ee" />
        <published>2013-01-02T23:34:26+00:00</published>
        <updated>2013-01-02T23:35:57+00:00</updated> 
        <category term="/General" label="General" />
        <category term="batch" scheme="http://roller.apache.org/ns/tags/" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr352" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
Batch processing is execution of series of "jobs" that is suitable
for non-interactive, bulk-oriented and long-running tasks. Typical
examples are end-of-month bank statement generation, end-of-day jobs
such as interest calculation, and ETL (extract-transform-load) in a
data warehouse. These tasks are typically data or computationally
intensive, execute sequentially or in parallel, and may be initiated
through various invocation models, including ad-hoc, scheduled, and
on-demand.&lt;br&gt;
&lt;br&gt;
&lt;a href="http://jcp.org/en/jsr/detail?id=352"&gt;JSR 352&lt;/a&gt; will
define a programming model for batch applications and a runtime for
scheduling and executing jobs. This blog will explain the main
concepts in JSR 352.&lt;br&gt;
&lt;br&gt;
The diagram below highlight the key concepts of a batch processing
architecture.&lt;br&gt;
&lt;br&gt;
&lt;img alt=""
src="https://blogs.oracle.com/arungupta/resource/jsr352-schematic.png"
height="248" width="600"&gt;&lt;br&gt;
&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;A &lt;i&gt;Job&lt;/i&gt; is an instance that encapsulates an entire batch
process. A job is typically put together using a &lt;i&gt;Job
Specification Language&lt;/i&gt; and consists of multiple steps. The
Job Specification Language for JSR 352 is implemented with XML
and is referred as "Job XML".&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;A &lt;i&gt;Step&lt;/i&gt; is a domain object that encapsulates an
independent, sequential phase of a job. A step contains all of
the information necessary to define and control the actual batch
processing.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;JobOperator&lt;/i&gt; provides an interface to manage all aspects
of job processing, including operational commands, such as
start, restart, and stop, as well as job repository commands,
such as retrieval of job and step executions.&lt;/li&gt;
&lt;li&gt;&lt;i&gt;JobRepository&lt;/i&gt; holds information about jobs current
running and jobs that run in the past. JobOperator provides
access to this repository.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Reader-Processor-Writer&lt;/i&gt; pattern is the primary pattern
and is called as &lt;i&gt;Chunk-oriented &lt;/i&gt;&lt;i&gt;processing&lt;/i&gt;. In
this, &lt;i&gt;ItemReader&lt;/i&gt; reads one item at a time, &lt;i&gt;ItemProcessor&lt;/i&gt;
processes the item based upon the business logic, such as
calculate account balance and hands it to &lt;i&gt;ItemWriter&lt;/i&gt; for
aggregation. Once the 'chunk' number of items are aggregated,
they are written out, and the transaction is committed.&lt;br&gt;
&lt;br&gt;
JSR 352 also defines roll-your-own batch pattern, called as &lt;i&gt;Batchlet&lt;/i&gt;.
This batch pattern is invoked once, runs to completion, and
returns an exit status. This pattern must implement and honor a
"cancel" callback to enable operational termination of the
Batchlet.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
A Job XML for a chunk-oriented processing may look like:&lt;br&gt;
&lt;pre&gt;&lt;br&gt;&amp;lt;job id="myJob" xmlns="http://batch.jsr352/jsl"&amp;gt;&lt;br&gt; &amp;lt;step id="myStep" &amp;gt;&lt;br&gt; &amp;lt;chunk reader="MyItemReader" &lt;br&gt; writer="MyItemWriter" &lt;br&gt; processor="MyItemProcessor"&lt;br&gt; buffer-size="5"&lt;br&gt; checkpoint-policy="item"&lt;br&gt; commit-interval="10" /&amp;gt; &lt;br&gt; &amp;lt;/step&amp;gt;&lt;br&gt;&amp;lt;/job&amp;gt;&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;The &amp;lt;job&amp;gt; has an "id" attribute that defines the logical
name of the job and is used for identification purposes. &lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Each &amp;lt;job&amp;gt; can multiple &amp;lt;step&amp;gt;s where each
&amp;lt;step&amp;gt; identifies a job step and it's characteristics.
Each &amp;lt;step&amp;gt; has an "id" attribute that defines the logical
name of the job and is used for identification purposes. &lt;br&gt;
&lt;/li&gt;
&lt;li&gt;A &amp;lt;step&amp;gt; may have &amp;lt;chunk&amp;gt; or &amp;lt;batchlet&amp;gt;
element, this &amp;lt;step&amp;gt; has a &amp;lt;chunk&amp;gt;. A &amp;lt;chunk&amp;gt;
identifies a chunk type step and implements the
reader-processor-writer pattern of batch. &lt;br&gt;
&lt;/li&gt;
&lt;li&gt;The "reader", "processor", and "writer" attributes specify the
class names of an item reader, processor, and writer
respectively.&lt;/li&gt;
&lt;li&gt;"buffer-size" specifies number of items to read and buffer
before writing. When enough items have been read to fill the
buffer, the buffer is emptied to a list and the configured
ItemWriter is invoked with the list of items.&lt;/li&gt;
&lt;li&gt;"checkpoint-policy" attribute specifies the checkpoint policy
that governs commit behavior for this chunk. Valid values are
"item", "time" and "custom". The "item" policy means chunk is
checkpointed after a specified number of items are processed.
The "time" policy means the chunk is committed after a specified
amount of time. The "custom" policy means the chunk is
checkpointed according to a checkpoint algorithm implementation.
The default policy is "item".&lt;/li&gt;
&lt;li&gt;"commit-interval" specifies the commit interval for the
specified checkpointed policy. The unit meaning of the
commit-interval specifies depends on the specified checkpoint
policy. For "item" policy, commit-interval specifies a number of
items. For "time" policy, commit- interval specifies a number of
seconds. The commit-interval attribute is ignored for "custom"
policy.&lt;br&gt;
&lt;br&gt;
When the configured checkpoint policy directs it is time to
checkpoint, all the items read and processed so far are passed
to the "writer".&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here is a simple reader:&lt;br&gt;
&lt;/p&gt;
&lt;pre&gt;@ItemReader&lt;br&gt;public class MyItemReader {&lt;br&gt; private static int id;&lt;br&gt; MyCheckPoint checkpoint = null;&lt;br&gt; &lt;br&gt; @Open&lt;br&gt; void open(MyCheckPoint checkpoint) {&lt;br&gt; this.checkpoint = checkpoint;&lt;br&gt; System.out.println(getClass().getName() + ".open: " + checkpoint.getItemCount());&lt;br&gt; }&lt;br&gt; &lt;br&gt; @ReadItem&lt;br&gt; MyBatchRecord read() {&lt;br&gt; checkpoint.incrementByOne();&lt;br&gt; return new MyBatchRecord(++id);&lt;br&gt; }&lt;br&gt; &lt;br&gt; @CheckpointInfo&lt;br&gt; MyCheckPoint getCheckPoint() {&lt;br&gt; return checkpoint;&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
&lt;p&gt;Methods marked with &lt;code&gt;@Open&lt;/code&gt;, &lt;code&gt;@ReadItem&lt;/code&gt;,
and &lt;code&gt;@CheckpointInfo&lt;/code&gt; are required.&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;Here is a simple processor that rejects every other item:&lt;br&gt;
&lt;/p&gt;
&lt;pre&gt;@ItemProcessor&lt;br&gt;public class MyItemProcessor {&lt;br&gt; @ProcessItem&lt;br&gt; MyBatchRecord process(MyBatchRecord record) {&lt;br&gt; return (record.getId() % 2 == 0) ? record : null;&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
&lt;p&gt;And here is a simple writer:&lt;br&gt;
&lt;/p&gt;
&lt;pre&gt;@ItemWriter&lt;br&gt;public class MyItemWriter {&lt;br&gt; MyCheckPoint checkpoint = null;&lt;br&gt; &lt;br&gt; @Open&lt;br&gt; void open(MyCheckPoint checkpoint) {&lt;br&gt; this.checkpoint = checkpoint;&lt;br&gt; System.out.println(getClass().getName() + ".open: " + checkpoint.getItemCount());&lt;br&gt; }&lt;br&gt; &lt;br&gt; @WriteItems&lt;br&gt; void write(List&amp;lt;MyBatchRecord&amp;gt; list) {&lt;br&gt; System.out.println("Writing the chunk...");&lt;br&gt; for (MyBatchRecord record : list) {&lt;br&gt; System.out.println(record.getId());&lt;br&gt; }&lt;br&gt; checkpoint.increment(list.size());&lt;br&gt; System.out.println("... done.");&lt;br&gt; }&lt;br&gt; &lt;br&gt; @CheckpointInfo&lt;br&gt; MyCheckPoint getCheckPoint() {&lt;br&gt; return checkpoint;&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
&lt;p&gt;Finally a simple implementation of &lt;code&gt;MyCheckpoint&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;
&lt;pre&gt;public class MyCheckPoint {&lt;br&gt; int itemCount;&lt;br&gt;&lt;br&gt; public int getItemCount() {&lt;br&gt; return itemCount;&lt;br&gt; }&lt;br&gt;&lt;br&gt; public void setItemCount(int itemCount) {&lt;br&gt; this.itemCount = itemCount;&lt;br&gt; }&lt;br&gt; &lt;br&gt; void incrementByOne() {&lt;br&gt; itemCount++;&lt;br&gt; }&lt;br&gt;&lt;br&gt; void increment(int size) {&lt;br&gt; itemCount += size;&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;br&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;p&gt;Together, &lt;code&gt;MyItemReader&lt;/code&gt;, &lt;code&gt;MyItemWriter&lt;/code&gt;,
&lt;code&gt;MyItemProcessor&lt;/code&gt;, &lt;code&gt;MyCheckPoint&lt;/code&gt;, and &lt;code&gt;batch.xml&lt;/code&gt;,
will read/process/write 5 items and commit when 10 such items have
been processed.&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;&lt;a href="http://jcp.org/en/jsr/detail?id=352"&gt;JSR 352
specification&lt;/a&gt; defines several other concepts such as how Job
XML can define sequencing of jobs, listeners to interpose on job
execution, transaction management, and running jobs in partitioned
and concurrent modes. Subsequent blog will explain some of those
concepts.&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;A complete replay of &lt;a
href="https://oracleus.activeevents.com/connect/sessionDetail.ww?SESSION_ID=4105"&gt;Java

Batch for Cost-Optimized Business Efficiency&lt;/a&gt; from JavaOne
2012 can be &lt;a
href="https://oracleus.activeevents.com/connect/sessionDetail.ww?SESSION_ID=4105"&gt;seen









here&lt;/a&gt; (click on CON4105_mp4_4105_001 in Media).&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;Each feature will be added to the JSR subject to EG approval. You
can share your feedback to &lt;a
href="http://java.net/projects/jbatch/lists/public/archive"&gt;public@jbatch.java.net&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;The APIs and implementation of JSR 352 are not integrated in &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/"&gt;GlassFish
4 promoted builds&lt;/a&gt; yet. &lt;/p&gt;
Here are some more references for you:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a
href="http://jcp.org/aboutJava/communityprocess/pr/jsr352/index.html"&gt;Java

API for Batch Processing Public Review Downloads&lt;/a&gt;&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java.net/projects/jbatch/"&gt;Specification
Project&lt;/a&gt; (jbatch.java.net)&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://java.net/projects/jbatch/lists/public/archive"&gt;JSR

Expert Group Discussion Archive&lt;/a&gt; (public@jbatch.java.net)&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://wikis.oracle.com/display/GlassFish/PlanForGlassFish4.0#PlanForGlassFish4.0-SpecificationStatus"&gt;Java

EE 7 Specification Status&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Here are some other Java EE 7 primers published so far:&lt;br&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/simple_jms_2_0_sample"&gt;Simple
JMS 2.0 Sample&lt;/a&gt; (TOTD #191)
&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/what_s_new_in_servlet"&gt;What's

New in Servlet 3.1 ?&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/concurrency_utilities_for_java_ee"&gt;Concurrency

Utilities for Java EE&lt;/a&gt; (JSR 236)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/collaborative_whiteboard_using_websocket_in"&gt;Collaborative

Whiteboard using WebSocket in GlassFish 4&lt;/a&gt; (TOTD #189)
&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/non_blocking_i_o_using"&gt;Non-blocking

I/O using Servlet 3.1&lt;/a&gt; (TOTD #188)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/what_s_new_in_ejb"&gt;What's

New in EJB 3.2 ?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/jpa_2_1_schema_generation"&gt;JPA

2.1 Schema Generation&lt;/a&gt; (TOTD #187)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/websocket_applications_using_java_jsr"&gt;WebSocket

Applications using Java&lt;/a&gt; (JSR 356)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/jersey_2_in_glassfish_4"&gt;Jersey

2 in GlassFish 4&lt;/a&gt; (TOTD #182)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/websockets_and_java_ee_7"&gt;WebSocket

and Java EE 7&lt;/a&gt; (TOTD #181)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/json_p_java_api_for"&gt;Java

API for JSON Processing&lt;/a&gt; (JSR 353)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/jms_2_0_early_draft"&gt;JMS

2.0 Early Draft&lt;/a&gt; (JSR 343)&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
And of course, more on their way! Do you want to see any particular
one first ?&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/Qi6kGuBqXaE" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/batch_applications_in_java_ee</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/simple_jms_2_0_sample</id>
        <title type="html">Simple JMS 2.0 Sample - @JMSDestinationDefinition and Synchronous Message Receive: TOTD #191</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/dutFO-faymg/simple_jms_2_0_sample" />
        <published>2012-12-26T20:59:19+00:00</published>
        <updated>2012-12-26T21:00:25+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jms2" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr343" scheme="http://roller.apache.org/ns/tags/" />
        <category term="totd" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
&lt;a
href="https://blogs.oracle.com/arungupta/entry/jms_2_0_early_draft"&gt;JMS














2.0 Early Draft - Simplified API Sample Code&lt;/a&gt; explained some of
the changes that are made in JMS 2.0 to "catch up" with all the
changes in the Java SE and EE platform over the past few years. The
main goals of JMS 2.0 are:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Changes to improve ease-of-development&lt;/li&gt;
&lt;li&gt;Clarification of relationship between JMS and other Java EE
specifications&lt;/li&gt;
&lt;li&gt;Definition of a new mandatory API to allow any JMS provider to
be integrated with any other Java EE Application Server&lt;/li&gt;
&lt;li&gt;Other enhancements as requested by the community&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
This &lt;b&gt;T&lt;/b&gt;ip &lt;b&gt;O&lt;/b&gt;f &lt;b&gt;T&lt;/b&gt;he &lt;b&gt;D&lt;/b&gt;ay (TOTD) will
explain a simple sample showing how to send a message and receive it
synchronously. The complete source code for the sample can be &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd191-send-message-sample.zip"&gt;downloaded














here&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
This is a Stateless EJB that has a single method to send a message.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@Stateless&lt;br&gt;public class MessageSender {&lt;br&gt;&lt;br&gt; @Inject&lt;br&gt; JMSContext context;&lt;br&gt; &lt;br&gt; @Resource(mappedName="java:global/jms/myQueue")&lt;br&gt; Queue queue;&lt;br&gt;&lt;br&gt; public void sendMessage(String message) {&lt;br&gt; context.createProducer().send(queue, message);&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
In this code:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;JMSContext&lt;/code&gt; is a new interface introduced in the
simplified API in JMS 2.0. This combines in a single object the
functionality of two separate objects from the JMS 1.1 API: a &lt;code&gt;Connection&lt;/code&gt;
and a &lt;code&gt;Session&lt;/code&gt;. &lt;br&gt;
&lt;br&gt;
A &lt;code&gt;JMSContext&lt;/code&gt; may be injected in the Java EE web
and EJB containers using the &lt;code&gt;@Inject&lt;/code&gt; annotation. A
&lt;code&gt;JMSContext&lt;/code&gt; created in this way is described as
being &lt;i&gt;container-managed&lt;/i&gt;. A container-managed &lt;code&gt;JMSContext&lt;/code&gt;
will be closed automatically by the container. Applications
running in the Java EE web and EJB containers are not permitted
to create more than one active session on a connection. This
allows to combine them in a single object offering a simpler
API. This is the recommended way for creating JMS context in
Java EE applications.&lt;br&gt;
&lt;br&gt;
A &lt;code&gt;JMSContext&lt;/code&gt; may be created by calling one of the
&lt;code&gt;createContext&lt;/code&gt; methods on a &lt;code&gt;ConnectionFactory&lt;/code&gt;.
A &lt;code&gt;JMSContext&lt;/code&gt; that is created this way is described
as being &lt;i&gt;application-managed&lt;/i&gt;. An application-managed &lt;code&gt;JMSContext&lt;/code&gt;
must be closed when no longer needed by calling its &lt;code&gt;close&lt;/code&gt;
method. Applications running in a Java SE environment or in the
Java EE application client container are permitted to create
multiple active sessions on the same connection. This allows the
same physical connection to be used in multiple threads
simultaneously. The &lt;code&gt;createContext&lt;/code&gt; method is
recommended to create &lt;code&gt;JMSContext&lt;/code&gt; in such
applications.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;The Java EE Platform requires a preconfigured JMS &lt;code&gt;ConnectionFactory&lt;/code&gt;
accessible to the application under the JNDI name:&lt;br&gt;
&lt;pre&gt;java:comp/DefaultJMSConnectionFactory&lt;/pre&gt;
The annotation &lt;code&gt;@JMSConnectionFactory&lt;/code&gt; may be used
to specify the JNDI lookup name of the &lt;code&gt;ConnectionFactory&lt;/code&gt;
used to create the JMSContext as:&lt;br&gt;
&lt;pre&gt;@Inject&lt;br&gt;@JMSConnectionFactory("java:comp/DefaultJMSConnectionFactory")&lt;br&gt;JMSContext context;&lt;br&gt;
&lt;/pre&gt;
If no lookup name is specified or the &lt;code&gt;@JMSConnectionFactory&lt;/code&gt;
is omitted then the platform default JMS connection factory will
be used. The above code fragment is equivalent to:&lt;br&gt;
&lt;pre&gt;@Inject
JMSContext context;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;@Resource&lt;/code&gt; defines a dependency on a resource
needed by the application. In this case, it specifies the JNDI
name of the destination to which the message needs to be sent.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;When an application needs to send messages it uses the &lt;code&gt;createProducer&lt;/code&gt;
method to create &lt;code&gt;JMSProducer&lt;/code&gt; which provides
methods to configure and send messages. The various &lt;code&gt;setProperty&lt;/code&gt;
methods are used to set property on the message being sent.
There are several other methods like &lt;code&gt;setPriority&lt;/code&gt;,
&lt;code&gt;setDeliveryDelay&lt;/code&gt;, and &lt;code&gt;setTimeToLive&lt;/code&gt;
to set other quality-of-service attributes for the message being
sent.&lt;br&gt;
&lt;br&gt;
Messages may be sent synchronously or asynchronously.
Synchronous messages are sent using one of the &lt;code&gt;send&lt;/code&gt;
methods. Asynchronous messages are sent using &lt;code&gt;setAsync&lt;/code&gt;
method and assigning a &lt;code&gt;CompletionListener&lt;/code&gt;. When
the message has been successfully sent the JMS provider invokes
the callback method &lt;code&gt;onCompletion&lt;/code&gt; on the &lt;code&gt;CompletionListener&lt;/code&gt;
object. If the message is not sent for some reason or an
acknowledgement from the remote JMS server is not received then
&lt;code&gt;onException&lt;/code&gt; callback method is called. An
asynchronous send is not permitted in a Java EE application.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
This is a Stateless EJB that has a single method to receive the
message synchronously.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@Stateless&lt;br&gt;public class MessageReceiverSync {&lt;br&gt;&lt;br&gt; @Inject&lt;br&gt; private JMSContext context;&lt;br&gt; &lt;br&gt; @Resource(mappedName="java:global/jms/myQueue")&lt;br&gt; Queue myQueue;&lt;br&gt;&lt;br&gt; public String receiveMessage() {&lt;br&gt; String message = context.createConsumer(myQueue).receiveBody(String.class, 1000);&lt;br&gt; return "Received " + message;&lt;br&gt; }&lt;br&gt;}&lt;br&gt;&lt;/pre&gt;
&lt;br&gt;
In this code:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;JMSContext&lt;/code&gt; referring to the preconfigured JMS &lt;code&gt;ConnectionFactory&lt;/code&gt;
is injected by the container.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;@Resource&lt;/code&gt; defines a dependency on the JMS
destination on which the message is received.&lt;/li&gt;
&lt;li&gt;When an application needs to receive messages it uses one of
the several &lt;code&gt;createConsumer&lt;/code&gt; or &lt;code&gt;createDurableConsumer&lt;/code&gt;
methods to create a &lt;code&gt;JMSConsumer&lt;/code&gt;. &lt;code&gt;createConsumer&lt;/code&gt;
creates a non-durable subscription on the specified destination.
This means that a client will only see the messages published on
the destination when the subscriber is active. If the subscriber
is not active, it is missing messages published on the
destination. &lt;code&gt;createDurableConsumer&lt;/code&gt; creates an
unshared durable subscription of a specified topic and creates a
consumer on that subscription. This allows the subscriber will
receive all messages published on a topic, including the ones
published when there is no active consumer associated with it.
The JMS provider retains a record of this durable subscription
and ensures that all messages from the topic's publishers are
retained until they are delivered to, and acknowledged by, a
consumer on this durable subscription or until they have
expired.&lt;br&gt;
&lt;br&gt;
A &lt;code&gt;JMSConsumer&lt;/code&gt; provides methods to receive messages
either synchronously or asynchronously. &lt;code&gt;receive&lt;/code&gt;
methods are used for synchronous delivery of the messages. A &lt;code&gt;MessageListener&lt;/code&gt;
object may be registered with the client for asynchronous
delivery of the messages. &lt;code&gt;onMessage&lt;/code&gt; method of the
&lt;code&gt;MessageListener&lt;/code&gt; object are called as messages are
received. Asynchronous delivery of messages will not work until
&lt;a href="http://java.net/jira/browse/MQ-264"&gt;MQ-264&lt;/a&gt; is
fixed.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
Next is a Servlet that ties all the pieces together. It defines the
JMS Destination and send and receive the message using the
previously defined EJBs.&lt;br&gt;
&lt;br&gt;
&lt;pre&gt;@JMSDestinationDefinition(name = "java:global/jms/myQueue",&lt;br&gt; resourceAdapterName = "jmsra",&lt;br&gt; className = "javax.jms.Queue",&lt;br&gt; destinationName="queue1234",&lt;br&gt; description="My Queue")&lt;br&gt;@WebServlet(urlPatterns = {"/TestServlet"})&lt;br&gt;public class TestServlet extends HttpServlet {&lt;br&gt; &lt;br&gt; @EJB MessageSender sender;&lt;br&gt; &lt;br&gt; @EJB MessageReceiverSync receiver;&lt;br&gt;&lt;br&gt;&lt;br&gt; void doGet(HttpServletRequest request, HttpServletResponse response) {&lt;br&gt; . . .&lt;br&gt; String m = "Hello there";&lt;br&gt; sender.sendMessage(m);&lt;br&gt; out.format("Message sent: %1$s.&amp;lt;br&amp;gt;", m);&lt;br&gt; out.println("Receiving message...&amp;lt;br&amp;gt;");&lt;br&gt; String message = receiver.receiveMessage();&lt;br&gt; out.println("Message received: " + message); &lt;br&gt; . . .&lt;br&gt; }&lt;br&gt;&lt;/pre&gt;
In this code:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;@JMSDestinationDefinition defines the JMS destination. The &lt;code&gt;name&lt;/code&gt;
attribute defines the JNDI name of the destination being
defined, &lt;code&gt;destinationName&lt;/code&gt; attribute defines the
name of the queue or topic, and &lt;code&gt;className&lt;/code&gt;
attribute defines the JMS destination implementation class name.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;doGet&lt;/code&gt; method uses the injected EJBs to send and
receive the message.&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
The complete source code for the sample can be &lt;a
href="https://blogs.oracle.com/arungupta/resource/totd191-send-message-sample.zip"&gt;downloaded














here&lt;/a&gt;. "mvn package" and deploy the generated WAR file.&lt;br&gt;
&lt;br&gt;
Download &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/"&gt;GlassFish














4 build 68 onwards&lt;/a&gt; and try this sample today!&lt;br&gt;
&lt;br&gt;
The latest progress on JMS 2.0 can be tracked at:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://jms-spec.java.net"&gt;jms-spec.java.net&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;JSR 343 EG archive at &lt;a
href="http://java.net/projects/jms-spec/lists/jsr343-experts/archive"&gt;jsr343-experts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Discussion at &lt;a
href="http://java.net/projects/jms-spec/lists/users/archive"&gt;users@jms-spec&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://jcp.org/en/jsr/detail?id=343"&gt;JSR 343&lt;/a&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a
href="http://java.net/projects/jms-spec/pages/Home#Latest_draft_specification_and_javadocs"&gt;Latest
Specification&lt;/a&gt;&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Latest Javadocs (&lt;a
href="http://java.net/projects/jms-spec/sources/repository/content/jms2.0/target/jms-2.0-javadoc.jar"&gt;download&lt;/a&gt;,
&lt;a
href="http://jms-spec.java.net/2.0-SNAPSHOT/apidocs/index.html"&gt;online&lt;/a&gt;)&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;Help us make JMS 2.0 better, simpler, easier to use. Join &lt;a
href="http://java.net/projects/jms-spec/lists/users/archive"&gt;users@jms-spec&lt;/a&gt;
and contribute!&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/dutFO-faymg" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/simple_jms_2_0_sample</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/javaone_2013_russia_india_china</id>
        <title type="html"> JavaOne 2013 Russia, India, China, USA: Save the Date</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/SuCfx1NiA2w/javaone_2013_russia_india_china" />
        <published>2012-12-21T18:24:13+00:00</published>
        <updated>2012-12-21T18:24:13+00:00</updated> 
        <category term="/General" label="General" />
        <category term="china" scheme="http://roller.apache.org/ns/tags/" />
        <category term="conf" scheme="http://roller.apache.org/ns/tags/" />
        <category term="dates" scheme="http://roller.apache.org/ns/tags/" />
        <category term="india" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaone" scheme="http://roller.apache.org/ns/tags/" />
        <category term="russia" scheme="http://roller.apache.org/ns/tags/" />
        <category term="usa" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
&lt;a href="http://www.oracle.com/javaone/index.html"&gt;&lt;img
alt="JavaOne" title="JavaOne"
src="https://blogs.oracle.com/arungupta/resource/javaone-logo.png"
border="0" height="189" width="532"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Moscow, Russia&lt;/b&gt;: April 23-24, 2013&lt;sup&gt;*&lt;/sup&gt;&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Hyderabad, India&lt;/b&gt;: May 8-9, 2013&lt;sup&gt;*&lt;/sup&gt;&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Shanghai, China&lt;/b&gt;: Jul 23-25, 2013&lt;sup&gt;*&lt;/sup&gt;&lt;br&gt;
&lt;br&gt;
&lt;b&gt; San Francisco, USA&lt;/b&gt;: Sep 22-26, 2013&lt;sup&gt;*&lt;/sup&gt;&lt;br&gt;
&lt;br&gt;
&lt;sup&gt;*&lt;/sup&gt; The dates are subject to change.&lt;br&gt;
&lt;br&gt;
Venue, Agenda, CFP, and other details to come later.&lt;br&gt;
&lt;br&gt;
Did you know that recording of all Technical Sessions from JavaOne
San Francisco 2012 is available ? &lt;a
href="https://oracleus.activeevents.com/connect/search.ww?event=javaone"&gt;Watch
them there&lt;/a&gt;!&lt;br&gt;
&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/SuCfx1NiA2w" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/javaone_2013_russia_india_china</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/adopt_a_jsr_for_java</id>
        <title type="html">Adopt-a-JSR for Java EE 7 - Getting Started</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/n4KbWx2eaiY/adopt_a_jsr_for_java" />
        <published>2012-12-19T13:26:06+00:00</published>
        <updated>2012-12-19T13:26:06+00:00</updated> 
        <category term="/General" label="General" />
        <category term="adoptajsr" scheme="http://roller.apache.org/ns/tags/" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jcp" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
&lt;a href="http://java.net/projects/adoptajsr/pages/Home"&gt;Adopt-a-JSR&lt;/a&gt;
is an initiative started by JUG leaders to encourage JUG members to
get involved in a JSR, in order to increase grass roots
participation. This allows JUG members to provide early feedback to
specifications before they are finalized in the JCP. The standards
in turn become more complete and developer-friendly after getting
feedback from a wide variety of audience. &lt;a
href="http://java.net/projects/adoptajsr/pages/Home"&gt;adoptajsr.org&lt;/a&gt;
provide more details about the logistics and benefits for you and
your JUG. A similar activity was conducted for &lt;a
href="http://java.net/projects/adoptopenjdk/pages/AdoptOpenJDK"&gt;OpenJDK&lt;/a&gt;
as well. &lt;a
href="http://www.heise.de/developer/artikel/Java-Community-Process-Adopt-a-JSR-1771091.html"&gt;Markus
Eisele&lt;/a&gt; also provide a great introduction to the program (in
German).&lt;br&gt;
&lt;br&gt;
Java EE 7 (&lt;a href="http://jcp.org/en/jsr/detail?id=342"&gt;JSR 342&lt;/a&gt;)
is scheduled to go final in Q2 2013. There are several new JSRs that
are getting included in the platform (e.g. WebSocket, JSON, and
Batch), a few existing ones are getting an overhaul (e.g. JAX-RS 2
and JMS 2), and several other getting minor updates (e.g. JPA 2.1
and Servlets 3.1). Each Java EE 7 JSR can leverage your expertise
and would love your JUG to adopt a JSR.&lt;br&gt;
&lt;br&gt;
&lt;b&gt;What does it mean to adopt a JSR ?&lt;/b&gt;&lt;br&gt;
&lt;ol&gt;
&lt;li&gt;Your JUG is going to identify a particular JSR, or multiple
JSRs, that is of interest to the JUG members. This is mostly
done by polling/discussing on your local JUG members list.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Your JUG will download and review the specification(s) and
javadocs for clarity and completeness. The complete set of Java
EE 7 specifications, their download links, and EG archives are &lt;a
href="https://wikis.oracle.com/display/GlassFish/PlanForGlassFish4.0#PlanForGlassFish4.0-SpecificationStatus"&gt;listed

here&lt;/a&gt;. &lt;a href="http://glassfish.java.net/adoptajsr/"&gt;glassfish.org/adoptajsr&lt;/a&gt;
provide specific areas where different specification leads are
looking for feedback.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Your JUG can then think of a sample application that can be
built using the chosen specification(s). An existing use case
(from work or a personal hobby project) may be chosen to be
implemented instead. This is where your creativity and
uniqueness comes into play.&lt;br&gt;
&lt;/li&gt;
&lt;/ol&gt;
Most of the implementations are already integrated in &lt;a
href="http://download.java.net/glassfish/4.0/promoted"&gt;GlassFish 4&lt;/a&gt;
and others will be integrated soon. You can also explore integration
of multiple technologies and provide feedback on the simplicity and
ease-of-use of the programming model. Especially look for
integration with existing Java EE technologies and see if you find
any discrepancies. Report any missing features that may be included
in future release of the specification.&lt;br&gt;
&lt;br&gt;
The most important part is to provide feedback by filing bugs on the
&lt;a
href="https://wikis.oracle.com/display/GlassFish/PlanForGlassFish4.0#PlanForGlassFish4.0-SpecificationStatus"&gt;corresponding

spec or RI project&lt;/a&gt;. Any thing that is not clear either in the
spec or implementation should be filed as a bug. This is what will
ensure that specification and implementation leads are getting the
required feedback and improving the quality of the final deliverable
of the JSR.&lt;br&gt;
&lt;br&gt;
&lt;b&gt;How do I get started ?&lt;/b&gt;&lt;br&gt;
&lt;br&gt;
A simple way to get started can be achieved by following S.M.A.R.T.
as explained below.&lt;br&gt;
&lt;br&gt;
&lt;table border="0" cellpadding="5" cellspacing="5" width="100%"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;b&gt;S&lt;/b&gt;pecific&lt;/td&gt;
&lt;td valign="top"&gt;Identify who all will be involved ? What
would you like to accomplish ? For example, even though
building a sample app will provide real-world validity of
the API but because of time constraints you may identify
that reviewing the specification and javadocs only can be
accomplished. Establish a time frame by which the activities
need to be complete. &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;b&gt;M&lt;/b&gt;easurable&lt;/td&gt;
&lt;td valign="top"&gt;Define a success for metrics. For example,
this could be the number of bugs filed. Remember, quality of
bugs is more important that quantity of bugs. Define your
end goal, for example, reviewing 4 chapters of the
specification or completing the sample application. Create a
dashboard that will highlight your JUG's contribution to
this effort.&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;b&gt;A&lt;/b&gt;ttainable&lt;/td&gt;
&lt;td valign="top"&gt;Make sure JUG members understand the time
commitment required for providing feedback. This can vary
based upon the level of involvement (any is good!) and the
number of specifications picked. &lt;a
href="http://java.net/projects/adoptajsr/pages/Home#What_do_we_work_on_for_a_JSR?"&gt;adoptajsr.org&lt;/a&gt;
defines different categories of involvement. Once again, any
level of involvement is good. Just reviewing a chapter, a
section, or javadocs for your usecase is helpful.&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;b&gt;R&lt;/b&gt;elevant&lt;/td&gt;
&lt;td valign="top"&gt;Pick JSRs that JUG members are willing and
able to work. If the JUG members are not interested then
they might loose motivation half-way through. The "able"
part is tricky as you can always stretch yourself and learn
a new skill ;-)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;&lt;b&gt;T&lt;/b&gt;ime-bound&lt;/td&gt;
&lt;td valign="top"&gt;Define a time table of activities with
clearly defined tasks. A tentative time table may look like:&lt;br&gt;
&lt;br&gt;
Dec 25: Discuss and agree upon the specifications with JUG&lt;br&gt;
Jan 1: Start Adopt-a-JSR for Java EE 7&lt;br&gt;
Jan 15: Initial spec reading complete. Keep thinking through
the application that will be implemented.&lt;br&gt;
Jan 22: Early design of the sample application is ready&lt;br&gt;
Jan 29: JUG members agree upon the application&lt;br&gt;
Next 4 weeks: Implement the application&lt;br&gt;
&lt;br&gt;
Of course, you'll need to alter this based upon your
commitment. Maintaining an activity dashboard will help you
monitor and track the progress.&lt;br&gt;
&lt;br&gt;
Make sure to keep filing bugs through out the process!&lt;br&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;br&gt;
12 JUGs from around the world (&lt;a
href="http://soujava.org.br/servicos/adopt-a-jsr/"&gt;SouJava&lt;/a&gt;, &lt;a
href="https://groups.google.com/forum/?fromgroups=#%21forum/campinasjug"&gt;Campinas

JUG&lt;/a&gt;, &lt;a href="http://www.jugchennai.in/"&gt;Chennai JUG&lt;/a&gt;, &lt;a
href="http://www.meetup.com/Londonjavacommunity/"&gt;London Java
Community&lt;/a&gt;, &lt;a
href="http://www.bejug.org/confluenceBeJUG/display/BeJUG/Home"&gt;BeJUG&lt;/a&gt;,
&lt;a href="http://www.moroccojug.org/"&gt;Morocco JUG&lt;/a&gt;, &lt;a
href="http://itpjava.org/"&gt;Peru JUG&lt;/a&gt;, &lt;a
href="http://www.jug.or.id/"&gt;Indonesia JUG&lt;/a&gt;, &lt;a
href="http://www.congojug.com/xwiki/bin/view/Main/WebHome"&gt;Congo
JUG&lt;/a&gt;, &lt;a href="http://www.meetup.com/sv-jug/"&gt;Silicon Valley
JUG&lt;/a&gt;, &lt;a
href="http://www.madridjug.org/xwiki/bin/view/Main/WebHome"&gt;Madrid
JUG&lt;/a&gt;, and &lt;a
href="http://www.madridjug.org/xwiki/bin/view/Main/WebHome"&gt;Houston

JUG&lt;/a&gt;) have already adopted one of the Java EE 7 JSRs. I'm
already helping some JUGs bootstrap and would love to help your JUG
too.&lt;br&gt;
&lt;br&gt;
What are you waiting for ?&lt;br&gt;
&lt;br&gt;
&lt;img alt=""
src="https://blogs.oracle.com/arungupta/resource/adoptajsr-dec18-2012.png"
height="313" width="600"&gt;&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/n4KbWx2eaiY" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/adopt_a_jsr_for_java</feedburner:origLink></entry>
    <entry>
        <id>https://blogs.oracle.com/arungupta/entry/what_s_new_in_servlet</id>
        <title type="html"> What's new in Servlet 3.1 ? - Java EE 7 moving forward</title>
        <author><name>arungupta  </name></author>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/MilesToGo/~3/h7SWuYdgao8/what_s_new_in_servlet" />
        <published>2012-12-18T21:35:14+00:00</published>
        <updated>2013-01-08T23:28:59+00:00</updated> 
        <category term="/General" label="General" />
        <category term="glassfish" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee" scheme="http://roller.apache.org/ns/tags/" />
        <category term="javaee7" scheme="http://roller.apache.org/ns/tags/" />
        <category term="jsr340" scheme="http://roller.apache.org/ns/tags/" />
        <category term="servlet31" scheme="http://roller.apache.org/ns/tags/" />
        <content type="html">&lt;br&gt;
Servlet 3.0 was released as part of Java EE 6 and made huge changes
focused at ease-of-use. The idea was to leverage the latest language
features such as annotations and generics and modernize how Servlets
can be written. The web.xml was made as optional as possible. Servet
3.1 (&lt;a href="http://jcp.org/en/jsr/detail?id=340"&gt;JSR 340&lt;/a&gt;),
scheduled to be part of Java EE 7, is an incremental release
focusing on couple of key features and some clarifications in the
specification.&lt;br&gt;
&lt;br&gt;
The main features of Servlet 3.1 are explained below:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;Non-blocking I/O - Servlet 3.0 allowed asynchronous request
processing but only traditional I/O was permitted. This can
restrict scalability of your applications. Non-blocking I/O
allow to build scalable applications. &lt;a
href="https://blogs.oracle.com/arungupta/entry/non_blocking_i_o_using"&gt;TOTD






#188&lt;/a&gt; provide more details about how non-blocking I/O can
be done using Servlet 3.1.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;HTTP protocol upgrade mechanism - &lt;a
href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.42"&gt;Section





14.42&lt;/a&gt; in the HTTP 1.1 specification (&lt;a
href="http://www.ietf.org/rfc/rfc2616.txt"&gt;RFC 2616&lt;/a&gt;)
defines an upgrade mechanism that allows to transition from HTTP
1.1 to some other, incompatible protocol. The capabilities and
nature of the application-layer communication after the protocol
change is entirely dependent upon the new protocol chosen. After
an upgrade is negotiated between the client and the server, the
subsequent requests use the new chosen protocol for message
exchanges. A typical example is how WebSocket protocol is
upgraded from HTTP as described in &lt;a
href="http://tools.ietf.org/html/rfc6455#section-1.3"&gt;Opening
Handshake&lt;/a&gt; section of &lt;a
href="http://tools.ietf.org/html/rfc6455"&gt;RFC 6455&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
The decision to upgrade is made in &lt;code&gt;Servlet.service&lt;/code&gt;
method. This is achieved by adding a new method: &lt;code&gt;HttpServletRequest.upgrade&lt;/code&gt;
and two new interfaces: &lt;code&gt;javax.servlet.http.HttpUpgradeHandler&lt;/code&gt;
and &lt;code&gt;javax.servlet.http.WebConnection&lt;/code&gt;.&lt;br&gt;
&lt;br&gt;
&lt;a
href="http://java.net/projects/tyrus/sources/source-code-repository/content/trunk/containers/servlet/src/main/java/org/glassfish/tyrus/servlet/TyrusHttpUpgradeHandler.java"&gt;
TyrusHttpUpgradeHandler&lt;/a&gt; shows how WebSocket protocol
upgrade is done in &lt;a href="http://tyrus.java.net/"&gt;Tyrus&lt;/a&gt;
(Reference Implementation for Java API for WebSocket).&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;Security enhancements&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;Applying run-as security roles to #init and #destroy methods&lt;/li&gt;
&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/Session_fixation"&gt;Session



fixation&lt;/a&gt; attack by adding &lt;code&gt;HttpServletRequest.changeSessionId&lt;/code&gt;
and a new interface &lt;code&gt;HttpSessionIdListener&lt;/code&gt;. You
can listen for any session id changes using these methods.&lt;/li&gt;
&lt;li&gt;Default security semantic for non-specified HTTP method in &lt;code&gt;&amp;lt;security-constraint&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Clarifying the semantics if a parameter is specified in the
URI and payload&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;Miscellaneous&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;ServletResponse.reset&lt;/code&gt; clears any data that
exists in the buffer as well as the status code, headers. In
addition, Servlet 3.1 will also clears the state of calling &lt;code&gt;getServletOutputStream&lt;/code&gt;
or &lt;code&gt;getWriter&lt;/code&gt;.&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ServletResponse.setCharacterEncoding&lt;/code&gt;: Sets the
character encoding (MIME charset) of the response being sent
to the client, for example, to UTF-8.&lt;/li&gt;
&lt;li&gt;Relative protocol URL can be specified in &lt;code&gt;HttpServletResponse.sendRedirect&lt;/code&gt;.
This will allow a URL to be specified without a scheme. That
means instead of specifying
"http://anotherhost.com/foo/bar.jsp" as a redirect address,
"//anotherhost.com/foo/bar.jsp" can be specified. In this case
the scheme of the corresponding request will be used.&lt;/li&gt;
&lt;li&gt;Clarification in &lt;code&gt;HttpServletRequest.getPart&lt;/code&gt;
and &lt;code&gt;.getParts&lt;/code&gt; without multipart configuration.&lt;/li&gt;
&lt;li&gt;Clarification that &lt;code&gt;ServletContainerInitializer&lt;/code&gt;
is independent of &lt;code&gt;metadata-complete&lt;/code&gt; and is
instantiated per web application.&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p&gt;A complete replay of &lt;a
href="https://oracleus.activeevents.com/connect/sessionDetail.ww?SESSION_ID=6793"&gt;What's



New in Servlet 3.1: An Overview&lt;/a&gt; from JavaOne 2012 can be &lt;a
href="https://oracleus.activeevents.com/connect/sessionDetail.ww?SESSION_ID=6793"&gt;seen








here&lt;/a&gt; (click on CON6793_mp4_6793_001 in Media).&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;Each feature will be added to the JSR subject to EG approval. You
can share your feedback to &lt;a
href="http://java.net/projects/servlet-spec/lists/users/archive"&gt;users@servlet-spec.java.net&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;
Here are some more references for you:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a
href="http://java.net/projects/servlet-spec/downloads/directory/Public%20Review"&gt;Servlet



3.1 Public Review Candidate Downloads&lt;/a&gt;&lt;br&gt;
&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a
href="http://java.net/projects/servlet-spec/downloads/download/Public%20Review/servlet-3.1-pdr-draft.pdf"&gt;Servlet



3.1 PR Candidate Spec&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a
href="http://java.net/projects/servlet-spec/downloads/download/Public%20Review/javax.servlet-api-3.1-pdr-draft-javadoc.jar"&gt;Servlet







3.1 PR Candidate Javadocs&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;a href="http://java.net/projects/servlet-spec/"&gt;Servlet
Specification Project&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a
href="http://java.net/projects/servlet-spec/lists/users/archive"&gt;JSR









Expert Group Discussion Archive&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://wikis.oracle.com/display/GlassFish/PlanForGlassFish4.0#PlanForGlassFish4.0-SpecificationStatus"&gt;Java









EE 7 Specification Status&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Several features have already been integrated in &lt;a
href="http://dlc.sun.com.edgesuite.net/glassfish/4.0/promoted/"&gt;GlassFish

4 Promoted Builds&lt;/a&gt;. Have you tried any of them ?&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;Here are some other Java EE 7 primers published so far:&lt;br&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/concurrency_utilities_for_java_ee"&gt;Concurrency
Utilities for Java EE&lt;/a&gt; (JSR 236)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/collaborative_whiteboard_using_websocket_in"&gt;Collaborative
Whiteboard using WebSocket in GlassFish 4&lt;/a&gt; (TOTD #189)&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/non_blocking_i_o_using"&gt;Non-blocking
I/O using Servlet 3.1&lt;/a&gt; (TOTD #188)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/what_s_new_in_ejb"&gt;What's
New in EJB 3.2 ?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/jpa_2_1_schema_generation"&gt;JPA
2.1 Schema Generation&lt;/a&gt; (TOTD #187)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/websocket_applications_using_java_jsr"&gt;WebSocket
Applications using Java&lt;/a&gt; (JSR 356)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/jersey_2_in_glassfish_4"&gt;Jersey
2 in GlassFish 4&lt;/a&gt; (TOTD #182)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/websockets_and_java_ee_7"&gt;WebSocket
and Java EE 7&lt;/a&gt; (TOTD #181)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/json_p_java_api_for"&gt;Java
API for JSON Processing&lt;/a&gt; (JSR 353)&lt;/li&gt;
&lt;li&gt;&lt;a
href="https://blogs.oracle.com/arungupta/entry/jms_2_0_early_draft"&gt;JMS
2.0 Early Draft&lt;/a&gt; (JSR 343)&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
And of course, more on their way! Do you want to see any particular
one first ?&lt;br&gt;
&lt;br&gt;&lt;img src="http://feeds.feedburner.com/~r/MilesToGo/~4/h7SWuYdgao8" height="1" width="1"/&gt;</content>
    <feedburner:origLink>https://blogs.oracle.com/arungupta/entry/what_s_new_in_servlet</feedburner:origLink></entry>
</feed>
