This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes Modular Java: Pax tools Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Modular Java: Pax tools" Watch "Modular Java: Pax tools" New topic
Author

Modular Java: Pax tools

Cristina Gutiu
Greenhorn

Joined: Jul 21, 2009
Posts: 1
Hi Craig,

I assume your latest book is covering this experience in details, but could you please make a briefing here on how do you use Pax tools while working with OSGi, and which are your favorite ones?

Thanks,
Cristina
Craig Walls
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 301
Cristina Gutiu wrote:I assume your latest book is covering this experience in details, but could you please make a briefing here on how do you use Pax tools while working with OSGi, and which are your favorite ones?


I became familiar with the Pax tools via Pax Runner. I was looking for a way to launch an OSGi container with a given set of bundles pre-installed and started. Trying to do that with Equinox or Felix by themselves proved to be cumbersome and the technique varied between the different framework implementations. Pax Runner unifies all of the OSGi framework implementations so that you can start them up with a set of bundles all the same way. It was exactly what I was looking for.

Once hooked on Pax Runner, I came into contact with Pax Construct. Hands down, this is my favorite Pax tool. Basically, Pax Construct brings a script/template-driven development model (ala, Rails or Grails) for OSGi. It takes a lot of the work out of developing the boilerplate pieces of OSGi bundles and leaves it to me to implement the most interesting stuff.

Then, there are other Pax goodies such as Pax Exam that lets me create a JUnit 4 test that loads up OSGi with a selection of bundles and perform assertions against that installation and the services exposed by those bundles.

I could catalog the entire Pax toolchest here, but those three are my favorites, by far.


Spring in Action - Unleash POJO power in your applications!
Modular Java - Discover the secret weapon to modularity on the Java platform!
XDoclet in Action - Your complete guide to code generation with XDoclet.
Ivano Pagano
Ranch Hand

Joined: Dec 16, 2006
Posts: 47

Craig Walls wrote:
Then, there are other Pax goodies such as Pax Exam that lets me create a JUnit 4 test that loads up OSGi with a selection of bundles and perform assertions against that installation and the services exposed by those bundles.


Could you give us a little more in-depth about Unit testing in the OSGi container?
Like, can I do "integration testing" with Pax Exam? I mean can I test features that depend on the services of bundles other than the one I'm testing?

Thank you,
Ivano.
Craig Walls
author
Ranch Hand

Joined: Sep 19, 2003
Posts: 301
Ivano Pagano wrote:Could you give us a little more in-depth about Unit testing in the OSGi container?
Like, can I do "integration testing" with Pax Exam? I mean can I test features that depend on the services of bundles other than the one I'm testing?


Actually, that's precisely what Pax Exam is for. Here's roughly how it works:

You write a JUnit test that uses a special exam test runner. When that runner starts up, the first thing it does is start an OSGi runtime (of your choosing...it uses Pax Runner under the covers and so it can start any version of any OSGi runtime you want it to start). Then it installs a selection of bundles you specify in the test. At this point, you have a ready-to-test OSGi runtime, so the last thing it does is make an on-the-fly bundle that contains your JUnit test and installs that on-the-fly bundle into the OSGi runtime. From within the OSGi runtime, your test has access to the BundleContext and can do pretty much anything it wants. This includes consuming services published by other bundles and making assertions on what those services do.

FWIW, Spring-DM also has very similar testing support that follows an almost identical pattern. The only downside of Spring-DM's testing support is that currently it's based on JUnit 3. I much prefer Pax Exam's JUnit 4 style.
Ivano Pagano
Ranch Hand

Joined: Dec 16, 2006
Posts: 47

Got it, sound just perfect!
Thanks so much, Craig

Ivano
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Modular Java: Pax tools
 
Similar Threads
Central repository for OSGi bundles
JFileChooser and network share
Sweet spot of Spring-DM compared to other implementations?
Javadoc failed: java.io.IOException: CreateProcess
OSGi: How to add a 3rd party jar as a bundle?