Miles to go …

March 25, 2010

Day 2 – Tech Days 2010, Hyderabad

Filed under: General — arungupta @ 11:07 pm

Follow up from Day 1.

The opening of Day 2 started with "awesome", "fantastic", and "extraordinary" as the feedback when Simon asked about the Day 1. The attendees charged into the Hyderabad International Convention Center, the venue of Tech Days, on Day 2 as evident in the video below:

Georges Saab, Vice President, Fusion Middleware, Oracle talked about Oracle Application Grid and its various components such as WebLogic, Tuxedo, JRockit, Coherence, JDeveloper, ADF, and EclipseLink. Nandini Ramani showcased how Java platform has evolved over past few years and modularity is one of the key themes going forward. Her talk was loaded with several demos including mine on JSF, CDI, Bean Validation, and JAX-RS using NetBeans.

The "strange and unusual talent show", a usual activity on Day 2, had 9 participants and its probably the largest group I’ve ever seen. The attendees are encouraged to show their talent and it ranged from a poem, martial arts, dancing, singing, and many others. Watch all the fun in the video below:

My session on "Using the latest Java Persistence API 2 Features" was well received in a packed hall (with a capacity of 1500) and the slides are now available:

Using the latest Java Persistence API 2 Features – Tech Days 2010 India

Always good to see instant feedback via #techdays:

  • @javachap: In @arungupta session, Java Persistence API. It’s houseful! #techdays
  • @mohdabdurraafay: @arungupta your session was awesome. :) was very much in depth. Thanks. #techdays #techdays2010
  • @neilghosh: @arungupta excellent jpa session bt t-shirt din’t reach me :( #techdays #glassfish
  • @neilghosh: #techdays Day2 was more fun ..Liked the Tag Line "Code is king" by @arungupta it was fun interacting with geniuses from Sun Micro -Oracle ;)
  • @manishagarwal_: @arungupta Hey Arun.. I attended your sessions todays.. they were awesome..very interactive and useful.. am now :) downloading NetBeans 6.8
  • @bjgindia: @arungupta And really a great feeling meeting you! Got inspired towards #JavaEE6 and #glassfish v3 :)

And then the last technical session of this trip showing Java EE 6 tools (mostly NetBeans and Eclipse) concluded Tech Days. This slide-free session showed TOTD #123, TOTD #122, TOTD #120, TOTD #115, TOTD #102, and many others.

The evening finally concluded with a visit to 10 Downing Street and some R&R :-)

Here are pictures from Day 2:

And the complete album (including photos from Spark IT and Ruby Conf):

Here are the sessions presented in this trip:

  • Spark IT 2010
    • Java EE 6 & GlassFish v3: Paving the path for the future
    • Improving Engineering Process Using Hudson
    • Getting Started with Rails on GlassFish Hands-on Lab
    • Powering the Next Generation Services with the Java Platform
    • Java EE 6 Toolshow
  • Ruby Conf India 2010
    • GlassFish can support multiple Ruby frameworks … really ?
  • Tech Days 2010, India
    • Java EE 6 & GlassFish v3: Paving the path for the future
    • OSGi & Java EE in GlassFish
    • Using the Latest Java Persistence API 2 Features
    • Java EE 6 Toolshow

And finally, this trip is coming to an end. Now, I’m certainly looking forward to head back home and have some quality time with family :-)

Technorati: conf techdays hyderbad india glassfish v3 javaee  netbeans

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

March 24, 2010

Day 1 – Tech Days 2010, Hyderabad

Filed under: General — arungupta @ 10:27 am
Ravichandra Kulur and band kick started the Tech Days, Hyderabad 2010 with flute, guitar, keyboard and drums playing Carnatic music. Ravi, a bachelor in Electrical Engineering, while nurturing his classical flute playing skills decided to take up music professionally from 1999.

He has extensively toured over 26 countries and performed over 1000 concerts like WOMAD in UK, Sfinks in Belgium, and San Fransciso Jazz Festival to name a few. The band certainly delighted the approx 3000 crowd with a breathtaking symphony. Enjoy 2 part video of the performance:

Accompanying him are Alwyn Fernandez (Guitarist), Prakash KN (Base Guitarist), Yogendra Hule (Drums), and Solomon (Keyboard).

Krishna Dhawan, Managing Director, Oracle India talked about the re-enforced commitment to Java.

James Gosling gave an overview of the Java ecosystem talking about different profiles / editions at a higher level. I certainly loved his Java EE 6 simplicity and ease-of-use demo with NetBeans 6.8 and GlassFish v3. His message to college graduates was "Learn Once, Work Anywhere" for the Java language. Another key message from him to the entire audience was "You have permission to have fun" … so much like him :-) It was certainly good catching up with him before the keynote.

The Java EE 6 / GlassFish v3 presentation had about 800 attendees and showed the key messages of Flexibility, Light weight, and Extensibility of Java EE 6 and Modular, Embeddable, and Extensible GlassFish v3. The slides are now available:

Java EE 6 & GlassFish v3: Paving the path for the future – Tech Days 2010 India

OSGi and Java EE in GlassFish provided an introduction to OSGi, how OSGi bundles can be easily created using Maven (TOTD #36) and NetBeans (blog coming soon), different ways to manage OSGi bundles in GlassFish (TOTD #118), explained the concept hybrid applications, and showed a demo of OSGi Declarative Services in GlassFish (TOTD #125). The slides are available at:

OSGi and Java EE in GlassFish – Tech Days 2010 India

The evening started with a nice debut performance by an upcoming Tollywood band, enjoy part of the musical extravaganza:

And concluded with a sumptuous dinner at Paradise Persis.

Here are some pictures from earlier today:

And the evolving album so far (including photos from Spark IT and Ruby Conf):

Tech Days is also happening in the satellite cities of Chennai and Bangalore on Mar 26th, register here!

Technorati: conf techdays hyderbad india glassfish v3 javaee osgi netbeans

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

March 22, 2010

Day 2 – Ruby Conf India 2010 Trip Report

Filed under: General — arungupta @ 3:33 am

Ruby Conf India 2010 Day 2 (follow up from Day 1) started with Nick Sieger‘s presentation on "Rails 3 Through Choices".

He started by talking about the state of Ruby in 2010

  • New Ruby Gems site (gemcutter), ported 11k gems
  • Multiple alternative Ruby VMs, Ruby 1.8 is 7 years old
    • JRuby 1.5 in April 2010
    • Rubinius in Q2 2010
    • Ruby 2.0
  • RubyToolBox, RailsPlugins.org, Github, Rails Guides are some of the popular and useful websites

Liked the "Auto" mode of camera analogy with Rails 3, basically start changing the settings as you get more advanced.

Here are some of the highlights of Rails 3:

  • –skip-activerecord, –skip-testunit, –skip-prototype are new options in Rails 3
  • script/server | generate | console == script/rails s g c == rails server generate console (within the app directory)
  • Routing is much cleaner
  • XSS safety is default in Rails 3
  • Railties: extension API for Rails – encapsulates configuration information and enables decoupling.
    • Four main components: Initialization, Rake tasks, Generators, Logging Events.
    • All components in Rails are themselves Railties.
  • Rack is now bundled in Rails 3
  • ActiveModel: creates a contract between controller and model (7 methods), can be connected to any backend data store, provides a bunch of default functionality
  • Migration from 2.0 -> 3.0: bit.ly/online-railsconf-slides has a presentation on migration from earlier versions.

Railties certainly reminds me of the recent modularity in JDK 7 and GlassFish v3. Watch Nick’s demo of Rails 3 in this 2-part video. It showed how Rails 3 Active Model can be used to store data in Neo4j (a graph database) instead of a traditional relational database.

My "GlassFish can support multiple Ruby frameworks … really ?" talked about the pluggable architecture of GlassFish v3 and how it supports multiple Ruby frameworks. It described the 3 deployment models of Rails applications in GlassFish (Gem, WAR, Directory-based), showed live samples of Rails and Sinatra applications, talked about the advantages of NetBeans, and a lot about JRuby. All my talks on Rails/GlassFish end up promoting JRuby a lot as that is indeed the entry point for deploying your Rails applications on GlassFish. Anyway, enjoy the complete slides at:

GlassFish can support multiple Ruby frameworks … really ?

And I received the following messages few minutes after the presentation was posted on slideshare:

Here are some of the tweets during/after the talk:

  • @gautamrege Really cool article by @arungupta Day 1 – Ruby Conf India 2010 « Miles to go … http://ow.ly/1oZ9M #rubyconfindia
  • @ytvinay sitting with @nicksieger and listening 2 @arungupta ‘s gr8 talk on glassfish n jruby. is this really happening? #rubyconfindia #honoured
  • @yob_au Enjoying Arun Gupta’s jruby and glassfish talk at #rubyconfindia – very clear overview and demos for an MRI traditionalist like me
  • @arjunghosh Second day @ #rubyconfindia Some interesting talks until now,like Nic one on Rails 3, @arungupta ‘s Glassfish,Sahar’s Templating
  • @vijay_dev feeling completely at home in the GlassFish talk! Helps to be a Java and Rails guy :-) #rubyconfindia

Totally love the instant feedback :-) You can follow the complete set of comments at #rubyconfindia.

Post lunch I had a brief hacking session with Obie and ran a local version of bizconf.org using JRuby/Rails 2.3.5/GlassFish Gem/PostgreSQL. Other than installing the required gems, every thing was pretty straight forward. It re-confirms the fact that JRuby is just Ruby and can run any Rails application on GlassFish in a seamless manner.

I would’ve loved to attend Roy’s closing keynote but had to step out because of a prior personal commitment.

Overall, Ruby Conf India turned out to be an excellent experience. I certainly enjoyed spending time with Nick, Ola, Obie and a bunch of folks from ThoughtWorks, specifically Roy, Sagar, Tina, Rohit, Christabel, and Judy. The entire team put a wondertastic show and I certainly hope this is a more regular event.

There is a relentless demand for entrepreneurial spirit and trying out the bleeding edge technologies. I hope other similar conferences will start showing up in the near future. I also hope that the local community pick up efforts to take leadership roles and start organizing free Ruby or Rails workshop to expand the Ruby ecosystem. And of course, I certainly wish they all use JRuby, after all it’s Ruby. And once you are using JRuby, that’s it – GlassFish serves your Rails, Sinatra, Ramaze, and any other Rack-based framework applications.

Here are a few pictures from Day 2:

And the complete album so far:

The speaker gift is certainly a nice gesture and my son will surely it enjoy more than me. Thanks a lot to Thought Works for organizing the conference!

On a little bit of fun front, totally loved the following advertisement of "Bingo! Spicy Masala Remix" on the local TV channels:

2 conferences, 2 cities, 2 hotels, 5 planned + 1 unplanned sessions covered, 1 city + 4 planned sessions remaining!

Next stop is Tech Days, Hyderabad!

Technorati: conf rubyconfindia ruby jruby rubyonrails glassfish bangalore bengaluru india

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

March 21, 2010

Mahaswami Software enjoys the “perfect marriage” of JRuby + Rails + GlassFish

Filed under: General — arungupta @ 3:42 am

Mahaswami Software (based in Bengaluru, India) uses its homegrown Rapid Application Development framework to deliver quality applications in quick time. The framework leverages JRuby, Rails, and the J2EE platform along with Test Driven Development and Continuous integration tools. Mahaswami offers product development services and specific consulting on JRuby/Rails based application development. The Mahaswami team actively contributes back to the Ruby and Rails community.

And they picked GlassFish for a web-based supply chain management product for a large enterprise application service provider in India. They picked GlassFish instead of JBoss because they loved the web-based admin console and high performance.

Watch more details in the following video:

Here is what the customer has to say about their experience:

We were pleasantly surprised by this team’s fantastic ability to deliver complex solutions with great agility, and have gained an edge to our product development efforts.

Do you have any JRuby/Rails/GlassFish consulting requirements in Bengaluru ? Mahaswami Software is your one stop shop for providing all the services.

See other similar success stories here.

Technorati: mahaswami bangalore bengaluru india jruby rubyonrails glassfish stories

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

March 20, 2010

Day 1 – Ruby Conf India 2010

Filed under: General — arungupta @ 4:58 pm
Roy Singham, founder and chairman of ThoughtWorks Inc, kick started Ruby Conf India by stating that this conference is more important than just Ruby in India. He also mentioned that this conference is sponsored by developers in India instead of any big corporations.  He talked about a global shift is happening because of the passion outside silicon valley in open source, Ruby, Python and other similar technologies. In his opinion, India & Brazil are going to reshape the world of software. He’d like Ruby conference to present the best of humanity, innovative and welcome to all. I think inclusive as opposed to exclusive is certainly a key message for the Ruby audience.

Ola‘s talk on "The Future of Programming Languages" was interesting as always. He talked about different types of languages such as general purpose (Java & Ruby), special purpose (Erlang & JavaScript), Domain specific (SQL), Functional, Logic, Object-oriented (Prototype or class-based), Multi paradigm (some aspects of each such as C# or Scala).

An interesting part of his talk explored the key Ruby features inherited from which other languages. Lets see how many can you guess ?

  1. Multiple assignments like a, b, c = 1, 2, 3
  2. Regular expressions
  3. $/ (input record separator), $= case insensitive
  4. Object Orientation
  5. Message Passing & Introspection
  6. Mixins
  7. Closures

Try to note down your answers and then match with the corrects ones at the end of this blog :-)

Obie‘s talk on Blood, Sweat, and Rails was well tailored to the Indian audience. The reference to "All izz well" and couple of pictures from the movie 3 Idiots got a good laugh but then he got reprimanded during his talk to stop using the "F" bomb. From my prior experience, I counted approx 14 times of him dropping the bomb ;-)

Matz skyped in and talked about current state of Ruby and the future. Matz is to Ruby as James Gosling is to Java so the attendees were extremely excited to see him live on the skype session.

It took him 6 months to write the first "Hello World" in Ruby and the first run crashed. But that started the long journey bringing Ruby to its current state. The name "Ruby" was chosen on Feb 24, 1993 and is officially considered the birthday of Ruby. During a later Q&A session he mentioned the name "Ruby" was chosen because the language came after "Perl" which was named after a gem and "Diamond" etc were too long a name. Later on he found out that Pearl is a birth stone for the month of June and Ruby is the birth stone for the month of July so it turned out logical that way as well :-)

Matz also mentioned that Ruby 1.9.2 will be released end of August and then start working on Ruby 2.0. Ruby’s future will be faster, more powerful, distributed programming, faster IPC, multi-core aware, broader (for embedded devices to HPC environments), smaller implementation, and more modular.

The social gathering in the evening was fun and gave me the opportunity to interact with lots of folks from the local community. I answered the question "What has Oracle got to do with Rails" at least 4 times during the social. Here are several articles on that topic:

  • Ruby on Rails on Oracle: A simple tutorial
  • Ruby on Rails with Oracle FAQ
  • Ruby on Rails on Oracle Wiki

And, of course, now Oracle owns GlassFish that allows native deployment of Rails along with Java EE applications.

The highlight for me was finding a happy customer using the "perfect marriage" of JRuby, Rails, and GlassFish. More details coming on that in a separate blog. I’m giving a session on "GlassFish supports multiple Ruby frameworks … really ?" at 11am on Day 2.

Now here are some pictures so far:

And here is the evolving album so far:

And now the answers from Ola’s talk:

  1. Multiple assignments like a, b, c = 1, 2, 3 from CLU (also templates, generators)
  2. Regular expressions from Perl
  3. $/ (input record separator), $= case insensitive from Perl
  4. Object Orientation from Smalltalk
  5. Message Passing & Introspection from Smalltalk
  6. Mixins from Lisp Machine Lisp
  7. Closures from Scheme

How many did you get right ? :)

Now looking forward to Day 2 starting in a few more hours.

Technorati: conf rubyconfindia ruby jruby rubyonrails glassfish bangalore bengaluru india oracle

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

March 19, 2010

Spark IT 2010 Trip Report

Filed under: General — arungupta @ 5:50 pm
Spark IT 2010 – the inaugural conference by CIOL and PCQuest (@pcquest) wrapped up earlier today.

With 1000+ attendees, 3 session tracks, and 1 hands-on lab running simultaneously, there was a lot for the attendees to consume.

Watch a brief video chat with Anil Chopra, Editor PCQuest on why/where/how of the conference:

Here are the three originally planned sessions (+ slides) I delivered over the past couple of days:

Java EE 6 & GlassFish v3: Paving the path for the future – Spark IT 2010

Improving Engineering Processes using Hudson – Spark IT 2010

Getting Started with Rails on GlassFish (Hands-on Lab) – Spark IT 2010

The fourth session was a slide-free session and showed Java EE 6 tooling using NetBeans (TOTD #122, screencast #29, TOTD #95, TOTD #94, TOTD #93) and Eclipse (TOTD #102 and TOTD #99). Future sessions will include IntellIJ as well as the support over there is still primitive and I need to spend more time trying to understand it ;-)  

One of the Day 2 keynote session speaker could not deliver the session and so I was called to talk about something that might be of interest to the broader set of attendees. After much thinking I delivered a presentation talking about the evolution of the Java platform and how it provides a rich and robust platform for creating next generation services. The session also included details on some features in the upcoming JDK 7 which was well appreciated. Anyway, the slides are available here:

Powering the Next Generation Services with Java Platform – Spark IT 2010

The Hudson session was also covered here and Day 2 keynote session got coverage here.

There were tons of interesting discussions with @tshanky, @venkat_s, @iamprabhu, @rbhardwaj1, @binodmaliel, @akkirajub, @simon, Dr B V Kumar, and several other speakers.

Many thanks to Cyber Media and all the volunteers who did a meticulous job in coordinating the conference!

Now a little bit about my personal stay at the hotel.

Selva Kumaran is the current Mr Bengaluru and was amongst top-10 in Mr India Body Building Championship last year. He provides free personal training sessions to the guests staying at Goldfinch Hotel. And I certainly availed couple of sessions there and totally enjoyed them. He is one of the reasons I’ll probably go back and stay at that hotel :-)

Another reason to go back to this hotel is Kabab Studio restaurant on their terrace. An open air dining, live ghazal singing, and well marinated barbecue together adds to the overall ambience. 

Here are some pictures from the conference:

And the complete evolving album at:

So for now, 1 conference, 4 planned + 1 unplanned sessions, and 1 hotel are covered. Many thanks to Cyber Media for inviting and hosting us. I certainly look forward to participating in SparkIT 2011.

There are 2 more conferences, 5 planned sessions, 2 hotels, and 1 more city still remaining.

The first Ruby Conf India starts tomorrow … yaay! And of course you’ll hear about how GlassFish seamlessly supports multiple Ruby frameworks on Mar 21 (Sunday) at 11am in Track1.

Technorati: conf bengaluru india glassfish netbeans eclipse javaee jruby rubyonrails sparkit

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

March 15, 2010

TOTD #124: OSGi Declarative Services in GlassFish – Accessed from a Java EE client

Filed under: General — arungupta @ 3:00 am

The OSGi R4 compendium specification enables declaration of "Declarative Services" in configuration files. The specification says:

The service component model uses a declarative model for publishing, finding and binding to OSGi services. This model simplifies the task of authoring OSGi services by performing the work of registering the service and handling service dependencies.

There are several advantages of OSGi declarative services and they are well defined in the specification.

Neil Bartlett provided history and introduction to Declarative Services. Jerome blogged about OSGi Declarative Services in GlassFish v3 a while back. As mentioned in his post, this "curious reader" decided to experiment with adding more than one service implementation.

This Tip Of The Day shows how to use Maven Bundle Plugin and Maven SCR Plugin to create an OSGi bundle with two declarative services. Then it shows how to create a Java EE client, inject the declared services, and invoke them.

Lets get started!

For those who want want to see the results first:

  • Download service project and build as "mvn clean install". Install the service as "cp target/helloservice-1.0-SNAPSHOT.jar" to "domains/domain1/autodeploy/bundles".
  • Download client project and build as "mvn clean package"
  • Deploy the client to GlassFish v3 as "asadmin deploy target/helloclient-1.0-SNAPSHOT.war"
  • Invoke the client as "curl http://localhost:8080/helloclient-1.0-SNAPSHOT/HelloClient"

Now lets try to understand and create the projects from scratch.

First, create the service project as:

mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes
-DgroupId=org.glassfish.samples.osgi.helloservice -DartifactId=helloservice

Lets first look at the completed project structure:

pom.xml
src
src/main
src/main/java
src/main/java/org
src/main/java/org/glassfish
src/main/java/org/glassfish/samples
src/main/java/org/glassfish/samples/osgi
src/main/java/org/glassfish/samples/osgi/helloservice
src/main/java/org/glassfish/samples/osgi/helloservice/api
src/main/java/org/glassfish/samples/osgi/helloservice/api/HelloService.java
src/main/java/org/glassfish/samples/osgi/helloservice/impl
src/main/java/org/glassfish/samples/osgi/helloservice/impl/HelloImpl.java
src/main/java/org/glassfish/samples/osgi/helloservice/impl/HowdyImpl.java

The three source files are one service API and two implementations.

HelloService.java

package org.glassfish.samples.osgi.helloservice.api;
/**
* @author arungupta
*/
public interface HelloService {
  public String sayHello(String name);
}

A very simple interface with one method that takes a String parameter and returns a String response.

HelloImpl.java

package org.glassfish.samples.osgi.helloservice.impl;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.glassfish.samples.osgi.helloservice.api.HelloService;
/**
* @author arungupta
*/
@Component(name="hello-service")
@Service
public class HelloImpl implements HelloService {
  public String sayHello(String name) {
    return "Hello " + name;
  }
}

This class is an implementation of the service interface. Notice this class is in "impl" package, different from the "api" package where interface was defined.

The business method implementation appends the greeting "Hello " to name parameter and generates the response message. The @Component and @Service annotations help in generation of the component descriptors as defined by the Maven SCR Plugin. This plugin provides many other annotations to customize the generation of metadata in "OSGI-INF/servicesComponent.xml". The "name" attribute will be used later by the Java EE client to access this service.

HowdyImpl.java

package org.glassfish.samples.osgi.helloservice.impl;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.glassfish.samples.osgi.helloservice.api.HelloService;
/**
* @author arungupta
*/
@Component(name="howdy-service")
@Service
public class HowdyImpl implements HelloService {
  public String sayHello(String name) {
    return "Howdy " + name;
  }
}

Another implementation of HelloService interface and uses "Howdy " for the greeting. Notice the name attribute has a different value.

Here is the complete pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                             http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.glassfish.samples.osgi.helloservice</groupId>
  <artifactId>helloservice</artifactId>
  <packaging>bundle</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>helloservice</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.felix</groupId>
      <artifactId>org.apache.felix.scr.annotations</artifactId>
      <version>1.2.0</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>2.0.1</version>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Export-Package>${pom.groupId}.api</Export-Package>
            <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
          </instructions>
        </configuration>
      </plugin>
    <plugin>
      <groupId>org.apache.felix</groupId>
      <artifactId>maven-scr-plugin</artifactId>
      <executions>
        <execution>
          <id>generate-scr-scrdescriptor</id>
          <goals>
            <goal>scr</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>
</project>

Maven SCR Plugin generates the descriptor file using the metadata specified by the @Component and @Service annotation in service implementations. If this plugin is used with Maven Bundle Plugin then it also adds the generated descriptor (OSGI-INF/serviceComponents.xml) to the bundle and set the required "Service-Component" manifest header.

Giving "mvn clean install" generates "target/helloservice-1.0-SNAPSHOT.jar" and installs the bundle in the local repository. This JAR is used later in the client project for importing the service API definition. The generated JAR has the following manifest:

Manifest-Version: 1.0
Export-Package: org.glassfish.samples.osgi.helloservice.api
Service-Component: OSGI-INF/serviceComponents.xml
Built-By: arungupta
Tool: Bnd-0.0.357
Bundle-Name: helloservice
Created-By: Apache Maven Bundle Plugin
Build-Jdk: 1.6.0_17
Bundle-Version: 1.0.0.SNAPSHOT
Bnd-LastModified: 1268374529666
Bundle-ManifestVersion: 2
Import-Package: org.glassfish.samples.osgi.helloservice.api
Bundle-SymbolicName: helloservice

The key thing to notice is that only "api" package is exported. The generated component descriptor in "OSGI-INF/serviceComponents.xml" looks like:

<?xml version="1.0" encoding="UTF-8"?>
<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
  <scr:component enabled="true" name="hello-service">
    <implementation class="org.glassfish.samples.osgi.helloservice.impl.HelloImpl"/>
    <service servicefactory="false">
      <provide interface="org.glassfish.samples.osgi.helloservice.api.HelloService"/>
    </service>
    <property name="service.pid" value="hello-service"/>
  </scr:component>
  <scr:component enabled="true" name="howdy-service">
    <implementation class="org.glassfish.samples.osgi.helloservice.impl.HowdyImpl"/>
    <service servicefactory="false">
     <provide interface="org.glassfish.samples.osgi.helloservice.api.HelloService"/>
    </service>
    <property name="service.pid" value="howdy-service"/>
  </scr:component>
</components>

Notice that the "Service-Component" manifest header is pointing to this generated descriptor. And so the two declared services "hello-service" and "howdy-service" are available for consumption by other clients.

There are several ways to manage OSGi runtime bundle in GlassFish as described in TOTD #118. Simply copying the bundle to "glassfish/domains/domain1/autodeploy/bundles" is sufficient in this case, so lets do that.

The remote telnet shell (accessible using "telnet localhst 6666") shows status of the deployed bundle and associated service as:

-> find hello
START LEVEL 1
ID State Level Name
[ 221] [Active ] [ 1] helloservice (1.0.0.SNAPSHOT)
-> scr list 221
Id State Name
[ 2] [active ] hello-service
[ 3] [active ] howdy-service
-> scr info 2
ID: 2
Name: hello-service
Bundle: helloservice (221)
State: active
Default State: enabled
Activation: delayed
Services: org.glassfish.samples.osgi.helloservice.api.HelloService
Service Type: service
Properties:
component.id = 2
component.name = hello-service
service.pid = hello-service
-> scr info 3
ID: 3
Name: howdy-service
Bundle: helloservice (221)
State: active
Default State: enabled
Activation: delayed
Services: org.glassfish.samples.osgi.helloservice.api.HelloService
Service Type: service
Properties:
component.id = 3
component.name = howdy-service
service.pid = howdy-service

Maven SCR Plugin provides several other annotations to change the default value for each service.

Now create a Java EE client project to invoke the service as:

mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes
-DgroupId=org.glassfish.samples.osgi -DartifactId=helloclient

Lets look at the completed project structure:

pom.xml
src
src/main
src/main/java
src/main/java/org
src/main/java/org/glassfish
src/main/java/org/glassfish/samples
src/main/java/org/glassfish/samples/osgi
src/main/java/org/glassfish/samples/osgi/HelloClient.java

There is only one source file which is the Servlet client and looks like:

package org.glassfish.samples.osgi;
import java.io.IOException;
import java.io.PrintWriter;
import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.glassfish.samples.osgi.helloservice.api.HelloService;
/**
* Hello world!
*/
@WebServlet(urlPatterns={"/HelloClient"})
public class HelloClient extends HttpServlet {
  @Resource(mappedName="hello-service")
  HelloService helloService;
  @Resource(mappedName="howdy-service")
  HelloService howdyService;
  @Override
  public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {
    PrintWriter out = response.getWriter();
    out.println(helloService.sayHello("Duke"));
    out.println(howdyService.sayHello("Duke"));
  }
}

This is a Java EE 6-style Servlet, using @WebServlet annotation, and will be accessible at "/HelloClient". The two OSGi services are injected using @Resource annotation and using the name specified in the "OSGI-INF/serviceComponents.xml" descriptor earlier.

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
         http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.glassfish.samples.osgi</groupId>
  <artifactId>helloclient</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>helloclient</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
     <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.glassfish.samples.osgi.helloservice</groupId>
      <artifactId>helloservice</artifactId>
      <version>1.0-SNAPSHOT</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax</groupId>
      <artifactId>javaee-api</artifactId>
      <version>6.0</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1-beta-1</version>
        <configuration>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Note that the previously generated service bundle is added as a dependency in the "provided" scope as its already deployed to GlassFish.

"mvn clean package" generates "target/helloclient-1.0-SNAPSHOT.war" Deploy this WAR file to GlassFish as:

asadmin deploy target/helloclient-1.0-SNAPSHOT.war

And finally invoke the client as:

curl http://localhost:8080/helloclient-1.0-SNAPSHOT/HelloClient

to see the output as:

Hello Duke
Howdy Duke

This is the expected output after invoking the two services.

So there you go, this blog demonstrated how to access a OSGi declarative service from a Java EE client – both deployed on GlassFish v3.

Are you using OSGi Declarative Services ? How ?

Technorati: totd osgi glassfish javaee declarative service maven bundle bnd scr component dependencyinjection

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

March 11, 2010

DevNexus 2010 Trip Report

Filed under: General — arungupta @ 12:08 pm
As mentioned earlier, I presented on Java E 6 & GlassFish v3 at DevNexus earlier this week. This is an annual conference by Atlanta Java Users Group and had three parallel tracks.

The conference was a sold out and the attendees packed Cobb Galleria conference rooms on both the days.

Anyway, the slides from my session are available below:

Java EE 6 & GlassFish v3 @ DevNexus

The speaking slots were bigger than normal, 70 minutes as opposed to normally 45 or 50 minutes. So that allowed to spend more time on the demos and show all the simplicity and ease-of-use with Java EE 6.  Optional "web.xml" is particularly well appreciated :-) And the attendees were hopeful that other vendors will start supporting Java EE 6 soon. For the record – Caucho, Geronimo, JBoss, and WebLogic have announced plans to be Java EE 6 compliant.

If you are interested in learning about Java EE (and several other topics), then GCA.net offers several of them all over the country. You can even avail a 10% on any class by registering at gca.net/devnexus. And if you are interested in specific learning paths on Java EE 6, then Oracle University has well designed courses.

Personally, I got to meet Dan Allen, Burr Sutter, James Ward, Venkat Subramaniam and many others. Burr is always an energetic personality and was live tweeting photographs of all the speakers. I loved his opening statement that DevNexus is about people who do what needs to be done, not who thinks what needs to be done. Basically he was joking on differences between "architects" and "developers" ;-) I also had some brief discussions with Dan on how Java EE adoption is important for the enterprise. His presentation on Contexts & Dependency Injection explained the concepts in simple manner. HIs slides should be soon available on Seam Wiki. Venkat’s keynote on Tuesday morning on "Facts and Fallacies of Software Development" was quite animated and simply superb. Here are some quotes from his talk:

  • A professional who doesn’t learn to fail, fails to learn
  • If a language is more typed, you type less (e.g. Scala). If a language is less typed, you type more (e.g. Java)
  • Standardization before innovation is a bad idea, that’s why EJB 1.0 suck so bad
  • It’s the lack of clear business objective, not lack of money & time that leads to failure
  • Passion, Competency, Responsibility – 3 things that can make your company succeed

I’m certainly looking forward to his keynote at Spark IT 2010 next week.

Finally some pictures from the conference:

And the complete album is available at:

Here is a brief number summary of the 2-week conference circuit starting next week:

  • 3 conferences
  • 8 sessions + 1 hands-on workshop
  • 2 cities
  • 6 days
  • 3 Hotels
  • 3 Airlines
  • Infinite meet/greet sessions

And then of course there is another one on Java EE 6 & GlassFish in Dallas on April 5, thank you GCA :-)

Technorati: conf glassfish v3 javaee atlanta devnexus ajug gca

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

March 1, 2010

Java EE 6 & GlassFish – Spark IT 2010, Ruby Conf India 2010, Tech Days 2010

Filed under: General — arungupta @ 10:40 am

Java EE 6 & GlassFish are swimming across the globe to participate in three different conferences in March 2010.

Spark IT 2010 is an inaugural conference and a joint initiative of CIOL, India’s largest IT portal and PCQuest, India’s leading magazine for IT professionals. You’ll hear about:

  • Java EE 6 & GlassFish (12:05 – 12:50pm, Mar 18)
  • Improving engineering process through Hudson (3:30 – 4:15pm, Mar 18)
  • GlassFish Toolapalooza (2:40 – 3:25pm, Mar 19)
  • Rails on GlassFish workshop (Mar 19)

Check Spark IT 2010 website for the latest updates. See the Agenda, Speakers, Venue Layout, follow the updates on @sparkit2010 and register now!

Ruby Conf India 2010 is India’s first RubyConf and is presented by Ruby community in India (which seems to be growing) and supported by RubyCentral. There are lots of great speakers Matz, Chad, Obie, Nick, and Ola. And of course, you’ll hear about:

  • GlassFish supports multiple Ruby frameworks … really ? (2:00 – 2:45pm, Mar 21)

Check Ruby Conf 2010 website for the latest updates. See the Agenda, Venue (Royal Orchid Hotel), follow the updates on @rubyconfindia and register now!

Don’t miss out on Sambar/Dosa and Mavalli Tiffin Room while in Bangalore :-)

Tech Days 2010 at Hyderabad is biggest of all the Tech Days events. Other than Dum Biryani, Minarets, and Pearls, you’ll hear about Java EE 6 platform and toolshow, OSGi, and Java Persistence API 2. The Agenda (to be updated) has all the details and James Gosling is going to be there as well!

Check Tech Days 2010 website for the latest updates. The venue (Hyderabad International Convention Center) is indeed very impressive so don’t miss out and register now!

Check out reports from Tech Days 2009 (1, 2) and Tech Days 2008 (1, 2, 3, 4, 5, 6, 7).

Here is the current speaking schedule:

  • Mar 7-8: DevNexus, Atlanta
  • Mar 18-19: Spark IT 2010, Bangalore
  • Mar 20-21: Ruby Conf India 2010, Bangalore
  • Mar 24-25: Tech Days 2010, Hyderabad
  • Apr 5: Java EE 6 & GlassFish workshop, Dallas

And as always, feel free to join me for a run :-)

Technorati: conf glassfish javaee bangalore hyderabad sparkit2010 rubyconfindia techdays hudson

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

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