Miles to go …

August 14, 2010

Java EE 6 & GlassFish workshop delivered at San Francisco JUG – Slides & Demos available

Filed under: glassfish, netbeans — arungupta @ 3:50 am

Roberto and I delivered a 2-part Java EE 6 & GlassFish 3 workshop at the San Francisco JUG last week. Over approximately 7 hours, we gave a preview of Java EE 6, explained the key technologies introduced in the platform, and did lot of coding using NetBeans IDE.

Roberto’s slides are given below:

And my slides are next:

The completed project from the workshop is now available here. This bundle contains the entire code sample built through out the workshop. The coding sessions are also available in screencast #30, also shown below:

Here is some feedback from the attendees:

The best JUG meeting I’ve ever attended. It was very informative, helpful and relevant. I particularly liked Arun’s follow-along coding demonstrations. I would suggest that the speakers be encouraged to use a mic. If I had not been sitting two rows from the front, then I would have had a hard time hearing Roberto.

It was interesting to hear from the source which parts of EE6 they thought were most valuable, and where new things overlapped with old, and what advantages there were in using standards-based solutions over frameworks like Spring, even when they tend to be behind in usability and power. Also liked the taste of NetBeans, being an Eclipse user.

Very fruitful evening. Thanks so much to the speakers and organizers.

I really enjoyed both nights. There were several JEE 6 (now I now the correct way to say it) technologies that I had heard of but quite didn’t understand … especially in regards to how they integrate. Now I do.…

Thanks aleksandar for organizing this JavaEE6 learning series. It was very helpful and head start on the cool features of EE6. Thanks to arun and Roberto for there well written presentations and hands on workshop. Will look forward for part 2 of this series.

Really enjoyed. Roberto gave a good high level overview of JavaEE (and he was funny) and Arun’s talk was educational and easy to follow along with. Very impressed with how easy it was to get the examples working with NetBeans. Looking forward to Thursday.

Really enjoyed both presentations. The fact that it was hands on added an extra dimension to the learning experience. Looking forward to the next session. Thanks to Roberto and Arun!

This was a fantastic intro to Java EE 6. I really liked Roberto’s down-to-earth overview of Java EE and its role in the enterprise Java world. In his workshop, Arun did an amazing job making Java EE 6 on GlassFish with NetBeans feel really approachable – if not too easy. Great participation from the audience.

The hands-on component worked great for me.

And the ratings are encouraging too …

As always, there is room for improvement and lessons to learn :-)

Check out some pictures:

Thank you Sasa for giving us an opportunity to talk about Java EE 6 & GlassFish 3 at San Francisco JUG!

Technorati: conf sanfrancisco jug sfjug glassfish javaee6

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • email
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

July 30, 2010

Dallas Tech Fest 2010 Trip Report

Filed under: glassfish, netbeans — arungupta @ 3:40 pm

Oracle was a gold sponsor of Dallas Tech Fest 2010 – 9 parallel tracks and 5 sessions/track.

I gave a 3-hour hands-on workshop on Java EE 6, GlassFish, and NetBeans. The room was packed during the first part (about 60 or so) and most of the audience retained for second part. The workshop explained several advantages of Java EE 6 such as simplicity, ease-of-use, and richness of the platform. These concepts were demonstrated using multiple coding sessions involving several technologies from the platform. Specifically it showed:

  • Creating simple Java EE 6 application using JSP, Servlets 3.0, Enterprise Java Beans 3.1
  • Facelets-based page creation using Java Server Faces 2
  • Contexts & Dependency Injection with Java Server Faces 2
  • Accessing database table using Java Persistence API 2
  • RESTful Web services using JAX-RS

NetBeans IDE specific features like Deploy-on-Save and Session-Preservation features that boosts your development productivity were also demonstrated using code samples.

The slides are now available:

Watch Tim Rayburn (one of the conference organizers) talks about where Dallas Tech Fest is today and how they like to evolve it for next year:

One of the attendees mentioned after the workshop that it was like "drinking from the fire hose". The content could be overwhelming for users who are not familiar with NetBeans and new to Java EE 6. As repeated multiple times during the workshop, all the code shown in the workshop is clearly explained in screencast #30 (also in-lined below).

Feel free to re-run the workshop at your own pace and convenience. And you can always post any comment on this blog or GlassFish forum for question and/or clarifications.

Check out some pictures from the event:

On a personal front, met a few avid readers of my blog, connected with some Oracle folks, and barely met Ted Neward. I found Texas very humid and hot early in the morning for me. But still managed to squeeze in a 10K run, at a much slower pace:

One of the advantage of staying at Westin hotels is that they have a running map close to their hotel. And if not then their "Westin Workout" gyms are typically well equipped – even a stepper and exercise ball ;-)

Thanks Erik & Tim for providing me the opportunity to speak, I definitely look forward to participating next year!

And here is the complete photo album below:

Technorati: conf dallastechfest dallas glassfish javaee6 netbeans

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • email
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

July 28, 2010

FISL 2010 Trip Report

Filed under: glassfish, netbeans — arungupta @ 6:04 am

4998 attendees registered and participated at the 11th edition of FISL – the biggest open source conference in Brazil. This was my second year at FISL. Even though the attendance was slightly down from last year but there was no let down in the energy. With 13 parallel tracks and sessions running from 9am to 11pm, it can be absolutely overwhelming. However most of the sessions were in Portuguese (with no English translation) so I could not attend.

I presented on the Java EE 6 Toolshow to an audience of approx 200. This slides-free session showed how NetBeans 6.9 provides comprehensive tooling around Java EE 6 and GlassFish 3. The session showed:

  • Simplicity and ease-of-use for creating Java EE 6 web applications
  • Boost productivity using Deploy-on-Save and Session-preservation across multiple redeployments
  • JSP, Servlets 3.0, EJB 3.1 in Java EE 6 web apps
  • Database access using Java Persistence API 2.0
  • Using Facelets with Java Server Faces 2.0
  • Contexts & Dependency Injection 1.0 with JSF 2
  • RESTful Web services using JAX-RS

The screencast #30 made the session delivery quite a breeze and you can watch the entire session by watching the multi-part screencasts.

Meeting Bruno Souza and Fabiane Nardon was a good highlight of the trip. They are both fairly well known in the Brazilian community and we shared stories from last year’s presence of Sun Microsystems at FISL. Check out their latest adventure at toolscloud.com where they provide open source tools-based development environment in the cloud.

Personally, I stayed for only couple of days because I had to come back to run a race (more on that in next blog) and attend a wedding over the weekend. A short trip but always good to spend face-to-face time with the local community.

Check out some pictures from the trip:

And the complete album at:

Technorati: conf fisl brazil oracle glassfish javaee6 netbeans

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • email
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

July 20, 2010

Screencast #30: Java EE 6 & GlassFish 3 using NetBeans 6.9 – 5 screencasts

Filed under: frameworks, glassfish, javaee, netbeans, screencast — arungupta @ 5:43 am

This 5-part screencast shows how NetBeans 6.9 provides comprehensive tooling for Java EE 6 & GlassFish 3. The video tutorial starts with building a simple Java EE 6 application and evolves to add features from several new technologies such as Java Persistence API 2, Java Server Faces 2, Contexts & Dependency Injection, and Java API for RESTful Web services from the platform. Specifically, the different parts show:

  1. How to create a simple Java EE 6 application using JSP, Servlets 3, and EJB 3.1
  2. Reading values from a database table using Java Persistence API 2 POJO entities
  3. Create a template-based website using Facelets with Java Server Faces 2
  4. Use Contexts & Dependency Injection with JSF 2
  5. Publish a RESTful Web service using JAX-RS

Enjoy!

Please give us feedback on GlassFish Forums.

Technorati: screencast javaee6 glassfish tutorial netbeans

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • email
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

July 11, 2010

Java Road Trip 2010 – New Orleans Stop

Filed under: glassfish, javaee, netbeans — arungupta @ 12:28 am

Java Road Trip is a tour across 20 cities in the United States showcasing Oracle’s commitment to everything Java.

I talked about Java EE 6 & GlassFish 3 at the New Orleans yesterday. The day started with an overcast sky, caught up with heat wave around the country (around 91 degrees), showed a reflection of super humidity (about 80%), and then ended with a thunder, lightning, and a heavy downpour while I was boarding the flight to back home.

The venue of the event was University of New Orleans but the taxi driver had no clue, even after talking to multiple folks, on how to reach there. But finally we reached after calling up his taxi company, asking at a Shell station, entering a different university, and talking to a cop. I can only we did not loose any attendees because of the location.

There were about 30 attendees spread across 3 parallel running sessions. I talked about simplicity, light-weight, extensible, and power of Java EE 6. There were no slides and only demos – after all, code is king! The key points shown were:

  • Servlets 3.0 make "web.xml" optional and instead use annotations to specify that information
  • Enterprise JavaBeans (EJB) can be bundled in a WAR file.
  • Java Server Faces 2 uses Facelets as the templating language. This allows templates to be created and applied across different .XHTML pages easily. The different scopes allow the bean to be used appropriately.
  • Creation of Java Persistence API (JPA) entity classes from a database table.
  • Creation of RESTful resources – can be done as a simple root resource or generate from a database table or an entity.

All of these features were demonstrated using NetBeans although all of them can be easily achieved using Eclipse as well. A consolidated list of Java EE 6 & GlassFish 3 Demos will help you feel some of the features mentioned above.

Here are some other relevant links for the Road Trip:

Many more cities (Austin, Houston, Denver, Salt Lake City, Seattle, and Portland) are planned before the trip makes it final stop at the San Francisco Bay Area. So make sure to catch up on a local or near by city and talk to speakers from Oracle. 

On a personal note, the hotel was in the French Quarter neighborhood so there was lot to see around. Being in the downtown, I had to restrict myself with indoor running only. The flight out of New Orleans got delayed because of thunder, lightning, and heavy downpour and so I missed my connection but caught the tail-end of a birthday party I was supposed to attend back home.

Anyway check out some pictures from the New Orleans stop:

Check out the complete album:

Technorati: conf neworleans javaroadtrip glassfish v3 javaee6 netbeans oracle

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • email
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

June 18, 2010

Uber Conf 2010 – Day 4 Report – OSGi/Java EE in GlassFish and Getting Started with Clojure

Filed under: frameworks, glassfish, netbeans, running — arungupta @ 11:30 am

Uber Conf Day 4 (Day 3, 2, and 1) started with yet another 10 miler with fellow attendees in 1 hr 18 mins and 7:49 pace. It was slightly slower than the day before – guess physical exhaustion was setting in ;-) Here are the mile splits:

Thanks to Andy for showing how to turn on the Auto-Lap feature in Garmin 305 … really handy!

I gave a talk on how GlassFish provides a great execution environment for deploying OSGi, Java EE, and hybrid applications easily. The slides are given below:

The remainder of the day was spent in Clojure track by Stuart Halloway. Next are some basic notes for getting started with Clojure:

Why Clojure ?

  • Power (hosted on jvm)
  • Robustness (functional)
  • Concurrency (identity, state, time)
  • Abstraction (OO done right)
  • Focus (lisp)

Together, these features add up to simplicity. Simplicity means

  • absence of incidental complexity
  • sufficient to meet your design constraints

Simplicity does not mean

  • Familiarity has nothing to do with simplicity
  • its not superficial, goes to the bone (e.g. only simpler syntax is just a sugar wrapper, look for the supported idioms)
  • does not mean easy, its very hard to be simple

Lot of code in Clojure is not about "set" something, its about invoke a function on it.

How to get started ?

Download the latest stable release or cutting edge build. The Clojure REPL (Read-Evaluate-Print Loop) is the easiest way to run a Clojure program as shown below:

~/tools/clojure/clojure-1.1.0 >java -cp clojure.jar clojure.main
Clojure 1.1.0
user=> (print "Hello World")
Hello Worldnil
user=> ^D

OR

~/tools/clojure/jun7 >java -cp clojure.jar clojure.main
Clojure 1.2.0-master-SNAPSHOT
user=> (print "Hello World")
Hello Worldnil
user=> ^D

Notice, the first fragment shows how to run REPL using the latest stable release and the second fragment shows the same using the cutting edge build. "Ctrl+D" exits the REPL shell. Stuart mentioned that the Clojure community stays on the cutting edge build most of the times.

Alternatively, you can also clone "labrepl" from "http://github.com/relevance/labrepl" which is an environment for exploring the Clojure language. It also provides complete instructions for getting started with NetBeans/Enclojure, Eclipse/Counterclockwise, Maven, Max/Linux command line, Windows command line, IDEA/La Clojure, and Emacs.

Configuring Clojure in NetBeans using the Enclojure plugin with NetBeans 6.9 gives the following error:

but works easily with NetBeans 6.8. The IDE seem to support REPL, Java/Clojure integration, syntax highlighting, brace/paren/bracket matching, code navigation, debugger and lots of interesting features.

Here is a typical REPL getting started session with NetBeans and Enclojure:

Here are some equivalent syntax with Java:

Semantic Java Clojure
new new Widget("foo") (Widget. "foo")
Access static members Math.PI Math/PI
Access instance members rnd.nextInt() (.nextInt rnd)
Chaining access person.getAddress().getZipCode() (.. person getAddress getZipCode)
  • "defn" is a symbol so no new syntax for adding a method.
  • ^ introduces metadata for the next symbol, "greet" in this case. You can put metadata anywhere.
  • "clojure.core" is the core of Clojure’s implementation
  • "javadoc" knows the default JDK javadocs, can make a local copy and/or extend it
  • "show" is Java reflection
  • "dir", "show", "source" are promoted from community version to the bleeding edge build.
  • Source is not always exposed
  • [1 2 3] Call the function 1 with arguments 2 & 3.
  • ‘(1 2 3) don’t evaluate it and print as is, just tick it.
  • Idiomatically Clojure requires less parentheses than Java
  • Every single function in Clojure is Runnable and Callable

  • Java interop is simple, wrapper-free (raw), performant, complete

Compojure is a small, open source Web framework for Clojure based upon Ring (similar to Python’s WSGI and Ruby’s Rack). Otherwise Clojure apps are deployed as a JAR file.

A subsequent blog will show how to deploy a simple Clojure JAR file and a simple web app using Compojure on GlassFish.

And finally, here are my top-10 reasons (in no particular order) that I’d like to attend UberConf next year:

  1. Long 90 minute sessions
  2. Lots of hands-on workshops
  3. Fun Run as part of the formal agenda
  4. Beautiful location (Westin Westminster) with lots of running trails
  5. Great food (breakfast + lunch + dinner)
  6. Small attendance so intimate discussions with speakers
  7. Great set of speakers
  8. Rarely see session hopping
  9. Pure technology, no product pitching
  10. Swags are nice – bracelet-style USB stick with all the presos, 2 different tee-shirts, fancy folder and some additional goodies for speakers

See ya next year, hopefully!

Technorati: conf uberconf denver clojure compojure glassfish netbeans javaee osgi

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • email
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

June 3, 2010

Jazoon 2010 Day 3 – Java EE 6 on Cloud, HTML 5 with JSF 2 and another run on Üetliberg

Filed under: frameworks, glassfish, javaee, netbeans, running — arungupta @ 2:13 pm

The Day 3 of Jazoon (Day 1 & 2) started with a great presentation on Gaia satellite and Data Processing by William O’Mullane. Gaia is a European Space Agency space mission that will be launched in Summer of 2012 to compile a catalog of approximately 1 billion stars. Most of their software is Java-based and have been fairly happy with the decision taken 10 years ago. They are very happy with the performance of Java and in certain cases its even 10x faster than C.

I gave a talk on "Running Java EE 6 applications in the Cloud". The talk explained flexibility, light-weight, extensibility, and ease-of-use of Java EE 6. It demonstrated a simple sample development and rapid deployment feature using NetBeans IDE. And then quickly jumped into how this application can be deployed on Amazon EC2, RightScale, Elastra, and Joyent infrastructure. I learned about the Simple Cloud API (Storage only) and Apache libcloud from Doug Tidwell’s talk yesterday and so will try them as well.

I gave a tee-shirt from the Bay Area JUG Roundup to Rainer Grau – moderator of the conference and he was kind enough to change it for rest of the day. See his picture below.

The slides from my talk are available below:

More detailed steps to deploy your Java EE 6 application on each cloud management / provider mentioned above will be available in a later blog. Instant feedback via twitter is always much appreciated as shown in the case below:

The Spring 3.0 Themes and Trends talk was quite a dejavu because it was mostly a rehash of what is available in the Java EE 6 today. And I could not understand why would anybody use Spring (instead of Java EE) to use the goodness of the JSF and JPA technologies ?

Roger’s talk on "Exploring HTML 5 with JSF 2" was very interesting and had a packed room, small but packed. He showed lots of HTML 5 samples and how Java Server Faces 2 can be used to include new tags like audio / video in a JSF composite component, Web Sockets and even Web Workers with JSF 2. His slides are available at:

Roger & I will work on publishing detailed steps on these demos in the coming days.

Spring Roo was a good one but it seems like that its basically trying to bring Ruby-on-Rails concepts like Dynamic Functions and Scaffold with some usual tooling tricks and heavy code generation to the Java programming language. One more framework, one more convention, one more programming style … not sure if it fills any gap!

Dan & Aslak presented on Real Java EE Testing with Arquillian and this was mostly a demo-driven talk showing how different Java EE technologies can be easily tested using ShrinkWrap and Arquillian. And the cool thing is that they support deployment to GlassFish Embedded as well.

Here are some pictures from earlier today:

And the day concluded with yet another great run up Üetliberg, just a simple out & back but 1404 ft elevation gain in 4.59 miles. The elevation map is shown below:

More details about the run are given below:

Here are some pictures captured during the run:

It is just beautiful – definitely worth going at least once!

Last but not the least, Roger & I had a great dinner at au gratin – a great restaurant + adjoining bar on the first floor on Bahnhofplatz. They’ve got great food variety at a great location, reasonably priced (as per the Swiss standards ;-) , and an American Football aficionado server by the name David. If you meet him, say our hello to him :-)

And here is the complete photo album:

This was my first Jazoon conference in the beautiful country of Switzerland and I thoroughly enjoyed it. I had some useful conversations and made some good contacts. I’d love to come back here again next year as well!

Next step Über Conf

Technorati: conf jazoon zurich javaee glassfish cloud amazon rightscale elastra joyent html5 jsf2 spring

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • email
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

May 11, 2010

TOTD #135: JSF2 Composite Components using NetBeans IDE – lightweight Java EE 6

Filed under: glassfish, javaee, javaserverfaces, netbeans, totd — arungupta @ 11:44 pm

NetBeans IDE provide comprehensive feature set to build applications using Java Server Faces 2 (JSR 314). This Tip Of The Day (TOTD) explains how to create JSF composite components using wizards provided by the NetBeans IDE.

The JSF2 specification, section 3.6 defines composite components as:

A tree of "UIComponent" instances, rooted at a top level component, that can be thought of and used as a single component in a view. The component hierarchy of this subtree is described in the composite component defining page.

This definition is good from the specification perspective but can help with some layman explanation. Essentially, a composite component is what it says – a composition of two or more components such that it behaves like a single component. For example, consider four components in a panel grid where 2 components are "h:outputText" to display prompts and other 2 are "h:inputText" to receive input from the user. The composite components allow all of these components (1 panel grid + 2 "h:inputText" + 2 "h:outputText") packaged as a single component.

Resource Handling and Facelets, both features newly introduced in the JSF2 specification, makes the creation of composite component much easier. The Resource Handling defines a standard location for bundling resources in a web application and Facelets defines a cleaner templating language that enables composition. In technical terms:

A composite component is any Facelet markup file that resides inside of a resource library.

Lets create a simple Web application using JSF 2 that accepts a username/password and displays it in a new page. The application is first created using the traditional "h:inputText" and "h:outputText" elements and is then converted to use a composite component.

Before we dig into composite component creation using JSF2, here are the steps listed to create one using JSF 1.2:

  1. Implement UIComponent subclass
  2. Markup rendering code in Renderer
  3. Register your component and renderer in faces-config.xml
  4. Implement your JSP tag
  5. And the TLD

There is Java code involved, sub-classing from JSF classes, deployment descriptor editing in "faces-config.xml", declaring TLDs and then implementing the JSP tag. Creating a composite component in JSF 1.2 was quite a chore and spread all over. There are lots of files

With that background, lets see what it takes us to create a composite component using JSF2.

The CDI backing bean for the application looks like:

package server;

import javax.enterprise.context.RequestScoped;
import javax.inject.Named;

@Named("simplebean")
@RequestScoped
public class SimpleBean {
    String name;
    String password;

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

The "index.xhtml" Facelet markup file looks like:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html">
  <h:head>
    <title>Enter Name &amp; Password</title>
  </h:head>
  <h:body>
    <h1>Enter Name &amp; Password</h1>
    <h:form>
      <h:panelGrid columns="2">
        <h:outputText value="Name:"/>
        <h:inputText value="#{simplebean.name}" title="name"
                     id="name" required="true"/>
        <h:outputText value="Password:"/>
        <h:inputText value="#{simplebean.password}" title="password"
                     id="password" required="true"/>
      </h:panelGrid>
      <h:commandButton action="show" value="submit"/>
    </h:form>
  </h:body>
</html>

And the "show.xhtml" Facelet markup looks like:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html">
  <h:head>
    <title>Show Name &amp; Password</title>
  </h:head>
  <h:body>
    <h1>Show Name &amp; Password</h1>
    <h:panelGrid columns="2">
      <h:outputText value="Name:"/>
      <h:outputText value="#{simplebean.name}" />
      <h:outputText value="Password:"/>
      <h:outputText value="#{simplebean.password}" />
    </h:panelGrid>
  </h:body>
</html>

Now select the <panelGrid> fragment in "index.xhtml" as shown below:

Right-click and select "Convert To Composite Component …" and specify the values as given in the wizard below:

Note, most of the values are default and only the "File Name:" is changed. After clicking on "Finish" in the wizard, the updated page looks like:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:ez="http://java.sun.com/jsf/composite/ezcomp">
  <h:head>
    <title>Enter Name &amp; Password</title>
  </h:head>
  <h:body>
    <h1>Enter Name &amp; Password</h1>
    <h:form>
      <ez:username-password/>
      <h:commandButton action="show" value="submit"/>
    </h:form>
  </h:body>
</html>

The namspace/prefix "http://java.sun.com/jsf/composite/ezcomp" is added to the markup page. <ez:username-password> is the composite component used instead of those multiple components. The namespace prefix, "ez", and the tag name, "username-password", are chosen based upon the values entered in the wizard.

The JSF 2 specification, section 3.6.1.4 defines that:

The occurrence of the string “http://java.sun.com/jsf/composite/” in a Facelet XML namespace declaration means that whatever follows that last “/” is taken to be the name of a resource library.

The resource library location is relative to the Facelet markup file that is using it. So in our case, all the code is rightly encapsulated in the "resources/ezcomp/username-password.xhtml" file as:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml"
     xmlns:cc="http://java.sun.com/jsf/composite"
     xmlns:h="http://java.sun.com/jsf/html">

    <!-- INTERFACE -->
    <cc:interface>
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
      <h:panelGrid columns="2">
        <h:outputText value="Name:"/>
        <h:inputText value="#{simplebean.name}" title="name"
                   id="name" required="true"/>
        <h:outputText value="Password:"/>
        <h:inputText value="#{simplebean.password}" title="password"
                   id="password" required="true"/>
      </h:panelGrid>
 </cc:implementation>
</html>

Notice, the composite component name matches the Facelet markup file name. The markup file lives in "resources/ezcomp" directory as indicated by the namespace value.

<cc:interface> defines metadata that describe the characteristics of component, such as supported attributes, facets, and attach points for event listeners. <cc:implementation> contains the markup substituted for the composite component.

The "index.xhtml" page is using the composite component and is conveniently called the using page. Similarly the "username-password.xhtml" page is defining the composite component and is conveniently called the defining page. In short, creating composite components in JSF2 requires the following steps:

  1. Move the required tags to a separate Facelet markup file, "defining page", in the "resources" directory
  2. Declare the namespace/prefix derived from "http://java.sun.com/jsf/composite" and the directory name
  3. Refer the composite component in the "using page".

Much simpler and cleaner than JSF 1.2. Are you using JSF 2 composite components ?

The entire source code used in this blog can be downloaded here.

JSF 2 implementation is bundled with GlassFish Server Open Source Edition, try it today!

Technorati: totd glassfish v3 netbeans jsf2 javaee composite components ajax

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • email
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

April 8, 2010

Java EE 6, GlassFish, NetBeans, Eclipse, OSGi at Über Conf: Jun 14-17, Denver

Filed under: eclipse, glassfish, javaee, netbeans — arungupta @ 10:54 am
Über Conf is a conference by No Fluff Just Stuff gang and plans to blow the minds of attendees with over 100 in-depth sessions (90 minutes each) from over 40 world class speakers on the Java platform and pragmatic Agile practices targeted at developers, architects, and technical managers.

Get your hands dirty and learn from the industry leaders in an intimate setting where the attendance is capped at 500 and in the beautiful city of Denver.

I’ll be speaking on:

  • Java EE 6 & GlassFish v3: Paving the path for the future
  • Getting the best of both worlds: OSGi & Java together

The talks will start with an introduction of key concepts and then provide a detailed overview of the technology. The talks will be interspersed with multiple demos to leave you feel empowered. There will be NetBeans and Eclipse (hopefully IDEA too) showing the simplicity, ease-of-use, and increased productivity with Java EE 6. There will be multiple demos showing OSGi application development and how OSGi + Java EE leverage the best of both worlds.

Keeping with the spirit of "No Fluff Just Stuff", the material presented will be purely technical :-)

Hear Jay Zimmerman (Über Conf Director) talk about the event. My first engagement with NFJS was Rich Web Experience 2007 and that was a great experience, truly "rich". This is my first speaking engagement with NFJS and looking forward to a long term relationship :-)

On a personal front, I never ran in Denver so looking forward to some nice runs in the mile high city! Any recommendations ?

Technorati: conf nofluffjuststuff uberconf denver glassfish javaee netbeans eclipse intellij osgi

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • email
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot

April 5, 2010

TOTD #125: Creating an OSGi bundles using NetBeans and deploying in GlassFish

Filed under: frameworks, glassfish, netbeans — arungupta @ 5:48 pm

NetBeans has a modular architecture where each module is created as an NBM. OSGi is another popular modular system for Java applications and used by GlassFish to provide a light-weight Java EE 6 compliant application server.

There are a lot of similarities between NBM and OSGi:

  • Runtime container manages lifecycle and dependencies of modules
  • Both are packaged as JAR, metadata stored in META-INF/MANIFEST.MF and some other information
  • Runtime starts up, read meta information and sets up dependencies
  • Every module has its own class loader loading explicitly declared dependencies only

The following presentation explain the similarities and differences between NBM and OSGi very clearly:

Netigso provides a bridge between NBM and OSGi bundles. Using Netigso, NetBeans 6.9 allows you to choose between creating a NBM or an OSGi bundle.

This Tip Of The Day (TOTD) shows how to create an OSGi bundle using NetBeans and deploy in GlassFish.

  1. Download and Install NetBeans 6.9 latest nightly build from here.
  2. Create a new NetBeans module by selecting "New Project…" and picking the values as shown in the image below:

    and click on "Next >".

  3. The module can be created either stand-alone or added to a suite (more on this later). For now, lets create a stand-alone module as shown below:

    and click on "Next >".

  4. On the bundle configuration page, specify the options as shown below:

    and click on "Finish". "Code Name Base" is name of the base package. Notice "Generate OSGi Bundle" is selected which is what will generate the OSGi bundle instead of NBM. The generated directory structure looks like:

    The "manifest.mf" looks like:

    Manifest-Version: 1.0
    Bundle-Localization: hello/Bundle
    Bundle-Name: %OpenIDE-Module-Name
    Bundle-SymbolicName: hello
    Bundle-Version: 1.0

  5. Right-click on "Source Packages", select "New", "Installer / Activator …" as shown below:

    Take the default values as shown below:

    and click on "Finish". The generated source code looks like:

    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package hello;
    
    import org.osgi.framework.BundleActivator;
    import org.osgi.framework.BundleContext;
    
    /**
     * Manages a bundle's lifecycle. Remember that an activator is optional and
     * often not needed at all.
     */
    public class Installer implements BundleActivator {
    
     public void start(BundleContext c) throws Exception {
     }
    
     public void stop(BundleContext c) throws Exception {
     }
    }
    

    The code that needs to be executed during starting and stopping this OSGi bundle can now be added to "start" and "stop" methods respectively. To keep it simple, add the following line to "start" method:

    System.out.println("OSGi Bundle from NetBeans: Started");
    

    and the following to "stop" method:

    System.out.println("OSGi Bundle from NetBeans: Stopped");
    
  6. Right-click on the project and select "Create NBM" as shown below:

    This creates "hello.jar" in the "build" directory of project.

  7. Fire up your GlassFish as "asadmin start-domain" and copy "hello.jar" to "glassfishv3/glassfish/domains/domain1/autodeploy/bundles" directory to deploy the bundle. It shows a log statement as:

    [#|2010-04-02T18:37:07.001-0700|INFO|glassfishv3.0|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=24;_ThreadName={felix.fileinstall.poll=5000, felix.fileinstall.bundles.new.start=true, service.pid=org.apache.felix.fileinstall.b3dcd962-8b41-4669-858b-7c2e7d32d5c8, felix.fileinstall.dir=/Users/arungupta/tools/glassfish/v3/final/glassfishv3/glassfish/domains/domain1/autodeploy/bundles/, felix.fileinstall.filename=org.apache.felix.fileinstall-autodeploy-bundles.cfg, service.factorypid=org.apache.felix.fileinstall, felix.fileinstall.debug=1};|OSGi Bundle from NetBeans: Started|#]

    The message printed from our generated bundle is highlighted in the bold. TOTD #118 shows other ways to manage OSGi bundles in GlassFish.

If you’d like to create multiple OSGi bundles that are related to each other then you create a "Module Suite" as shown below:

Multiple modules can be added by right-clicking on "Modules"

and either creating a new module or adding an existing one. Make sure to check "Generate OSGi Bundle" for the newly created bundle as well. Once the modules are added, then you can right-click on the suite, select "OSGi" and build all the modules in the suite together by selecting "Build Bundles" as shown below:

All the modules are now created in "/build/cluster/modules" directory of your suite.

Clicking on "Build Bundle Repository" creates an OSGi Bundle Repository (a federated repository of bundles).

UPDATED (Apr 8, 2010): Adding Maven-based OSGi functionality from NetBeans based upon a user comment, thanks Petr!

NetBeans also allows Maven-based OSGi projects to be easily created. This allows you to create pure-OSGi bundles without any NBM "fluff".

  1. Create a new Maven project and select "Maven OSGi Bundle":

    and click on "Next >".

  2. Enter the project details as:

    and click on "Finish".

  3. Expand "Source Packages", right click on the generated package and select "New", "Bundle Activator …":

    Take the defaults as shown below:

    and click on "Finish".

  4. The generated code looks like:

    import org.osgi.framework.BundleActivator;
    import org.osgi.framework.BundleContext;
    
    /**
     *
     * @author arungupta
     */
    public class NewActivator implements BundleActivator {
    
        public void start(BundleContext context) throws Exception {
            //TODO add activation code here
        }
    
        public void stop(BundleContext context) throws Exception {
            //TODO add deactivation code here
        }
    
    }
    

    Add add the following line to "start" method:

    System.out.println("OSGi Bundle from NetBeans/Maven: Started");
    

    and the following to "stop" method:

    System.out.println("OSGi Bundle from NetBeans/Maven: Stopped");
    
  5. Right-click the project and select "Clean and Build" to build "target/maven-osgi-1.0-SNAPSHOT.jar" in your project directory. This bundle can now be dropped in "glassfish/domains/domain1/autodeploy/bundles" to see a message like:

    [#|2010-04-08T11:54:09.721-0700|INFO|glassfishv3.0|javax.enterprise.system.std.com.sun.enterprise.v3.services.impl|_ThreadID=24;_ThreadName={felix.fileinstall.poll=5000, felix.fileinstall.bundles.new.start=true, service.pid=org.apache.felix.fileinstall.b3dcd962-8b41-4669-858b-7c2e7d32d5c8, felix.fileinstall.dir=/Users/arungupta/tools/glassfish/v3/final/glassfishv3/glassfish/domains/domain1/autodeploy/bundles/, felix.fileinstall.filename=org.apache.felix.fileinstall-autodeploy-bundles.cfg, service.factorypid=org.apache.felix.fileinstall, felix.fileinstall.debug=1};|OSGi Bundle from NetBeans/Maven: Started|#]

    And the generated manifest looks like:

    Manifest-Version: 1.0
    Export-Package: org.example.mavenosgi;uses:="org.osgi.framework"
    Built-By: arungupta
    Tool: Bnd-0.0.357
    Bundle-Name: maven-osgi OSGi Bundle
    Created-By: Apache Maven Bundle Plugin
    Bundle-Version: 1.0.0.SNAPSHOT
    Build-Jdk: 1.6.0_17
    Bnd-LastModified: 1270752743664
    Bundle-ManifestVersion: 2
    Bundle-Activator: org.example.mavenosgi.NewActivator
    Import-Package: org.example.mavenosgi,org.osgi.framework;version="1.5"
    Bundle-SymbolicName: org.example.maven-osgi
    

Technorati: totd netbeans glassfish osgi nbm module

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • DZone
  • email
  • StumbleUpon
  • Technorati
  • Twitter
  • Slashdot
Older Posts »

The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Powered by WordPress