Friday, July 9, 2010

RAD Tooling for OSGi Applications

RAD V8 Beta 2 is now available with updated support for developing, deploying and testing OSGi Applications using the WAS V7 Feature Pack for OSGi Applications and JPA 2.0. I'll describe some of the new OSGi capabilities of RAD in this post.

Built on top of the latest version of Eclipse (Helios), the RAD V8 Beta provides OSGi tools for enterprise Java developers. While most of the development activities, and hence development tools, for enterprise OSGi applications are common with Java EE there are some new considerations. Primarily, these are around the compile-time classpaths, the authoring of new metadata (the OSGi bundle and application manifests) and, optionally, Blueprint bean definition files. RAD introduces new project types for OSGi Bundle projects and OSGi application projects and a variety of new editors and tools for developing components in these types of projects. OSGi modularity semantics are honored in the project build paths to actively encourage modular design: each project has the scope of a single bundle, with Java package visibility between projects restricted to those packages explicitly imported/exported by the project's bundle manifest. This supports the careful and deliberate exposure of only those Java packages that are intended to be used external to a project . RAD's facet-based configuration enables OSGi projects to be configured as OSGi Web projects or OSGi JPA projects and integrates tools for authoring web.xml, persistence.xml and blueprint.xml. OSGi application projects - representing a complete enterprise application consisting of multiple bundles - can be imported from or exported to enterprise bundle archives, and can be tested and debugged on WAS V7 from the RAD workspace. RAD's SCA development tools are also extended to support "OSGi Applications" as a new implementation type for SCA components. The SCA tools accelerate the assembly of SCA composites; these can include OSGi application components which may selectively expose OSGi services outside the OSGi application and define remote bindings for these services. There's more about the relationship between OSGi services and SCA services here.

One of the quickest ways to explore the new OSGi features in RAD is to import one of the sample applications provided with the WAS V7 feature pack into a RAD workspace. The feature pack's Blog Sample, was described in an earlier post so I'll use that as my example. Start RAD and run the File->Import->OSGi Application (EBA) wizard, enterng the location of the com.ibm.ws.eba.example.blog.eba file (found in the WAS_INSTALL/feature_packs/aries/installableApps directory). Since one of the features this sample is designed to show is the deployment of an application which includes content provisioned from a bundle repository, you also need to make the com.ibm.json.java_1.0.0.jar available in the workspace - which you can do through File->Import->OSGi Bundle. The result is 4 OSGi bundle projects and an OSGi application project in the workspace, with everything correctly resolved.

You can see the relationships between the bundles in this application using RAD's new Bundle Explorer. The figure on the left shows the Bundle Explorer view of the Blog sample application project. Click on the image to enlarge it.

RAD gives you all the syntax assist, refactoring support, and problem quick-fixes you expect as well as new editors for bundle manifests, application manifests and blueprint bean definitions. By encapsulating business logic in POJO Blueprint beans and accessing persistent data through JPA entities, unit testing can be performed with simple frameworks like JUnit without requiring an application server to be running. And, of course, RAD includes integrated support for running and debugging entire OSGi applications on a WAS server, straight from the workspace.

7 comments:

WebSphere RAD said...

Nice and Informative one.

Bankruptcy papers said...
This comment has been removed by a blog administrator.
Unknown said...

Hi!

You says:

"By encapsulating business logic in POJO Blueprint beans and accessing persistent data through JPA entities, unit testing can be performed with simple frameworks like JUnit without requiring an application server to be running."

Actually I'm using RAD to develop an application, and all works fine, except for the unit testing. I can't see the way to integrate Junit + Blueprint + OSGI + JPA without running the application server.
I've been looking for some documentation, but I have found nothing.
Any idea?

Thanks

Ian Robinson said...

For unit testing a bundle project, make sure the Junit plugin (org.junit4) is included in your PDE target platform (RAD/Eclipse preferences->plug-in development->target platform). For example in RAD, use a target platform whose location includes the Eclipse SDK (which includes the junit plugin).
In your bundle project, make sure your manifest imports org.junit;version="4.8.1"

Vivek M Anandaramu said...

Not sure if this is relevant here, but I am facing some trouble using SCA on RAD. My RAD wizard doesn't seem to recognize Java/JEE implementation types, which means i cannot write any references/interfaces. Am i missing something in my setup?
Thanks, any help is appreciated.

Anonymous said...

Hi Vivek,
depending on which wizard you're using and the configuration of the project you're working on, there could be a couple reasons why the Java or JEE implementation kinds aren't appearing.

First, make sure the project in which you want to develop SCA components is configured for SCA development. The easiest way to check is to right-click on the project and look for one of these two context menu actions depending upon the version of RAD you are using:
1. In RAD v7.5.x: Service Component Architecture > Add SCA Support...
2. In RAD v7.8: Configure > Add SCA Support...

If you see the action, it means your project is not configured for SCA development. Choose the action to configure it. In the resulting Add SCA Support to Project wizard, make sure you select the WebSphere 7.0 Feature Pack for SCA 1.0.1 (not 1.0*) or WebSphere 8.0 SCA facet.

If you don't see the action, chances are your project is already configured to support SCA. In this case, right-click on the project, choose Properties, then click on Project Facets in the resulting properties dialog. In the list of project facets, either "WebSphere 7.0 Feature Pack for SCA" version "1.0.1" (not 1.0*) or "WebSphere 8.0 Beta SCA" version "8.0" should be checked.

* The JEE implementation kind is not supported by the WebSphere 7.0 Feature Pack for SCA version 1.0. The tools know this and will prevent you from using the JEE implementation kind for a project so configured.

Provided your project is configured correctly, you should be able to pick the Java or JEE implementation kinds for components in the composite editor.

Hope that helps.

Cheers - Chris Brealey

Neteller Casino said...

Prompt reply)))