JAX-RS or THE way to do REST in Domino Part 1

The IBM Domino community has had servlets on its mind lately, and XAgents, and Rest Services.  These are all great advances to using IBM Domino in a modern world.  However to bring IBM Domino into a more modern age of Java Development we must go beyond just writing servlets like it was 1999.  The next few blog posts will show you how to setup a REST Service that uses JAX-RS and runs on Domino.  This will require creating an OSGi plugin.  I am going to assume you have never written such and will try to explain all of the pieces that need to be done and why.

Below are the first few steps to create the plugin.

1.  Download Vanilla Eclipse.  Any version should work, but I would recommend getting the latest, which is Eclispe Luna SR2.  Specifically the one for Java EE Developers.  Its available here:

http://eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/lunasr2

After its downloaded unzip it somewhere, There isn’t an install just a bunch of files that need to be on your hard drive somewhere.

Once that done you can go about running it by executing “eclipse.exe” There are a few welcome screens that you can skip to get to the screen that is somewhat similar to Domino Designer Workspace.

2a.  I’m making an assumption here that you are either running a local full Domino Server or you have File Access to an install.  If you don’t have either of these, you really should consider it as it will make all of your development work a lot easier, even your normal XPages work.

To give you a little more understanding of how OSGi works, it helps to know that you are creating a bundle (plugin) and that it will interact with other bundles all within a container.  When dealing with Java in our XPages context we tend to think of Java as either source “.java” or libraries “.jar” files.  We need to add a third category of a bundle to create a plugin that does much.  So with that said we have to create whats called a “Target Platform”  inside of eclipse.  This is a profile of what environment will your bundle run in.  For our limited example all we need to add is the directories of where the Domino Bundles live.  There is a couple of them and its really just so our new Bundle can see those.

From the Eclipse menu go to Window-> Preferences.  This will open a dialog.  On the left side of the Dialog you should see Plug-in Development

prefpane1

Expand that section and you will see a new area called “Target Platform” Click on it and you should see a single platform called “Running Platform”, we will be creating a new one, so click “Add”

prefpane2

From there it will prompt if you want to start from an old one or from scratch.   We will be creating one from scratch. So leave it on

“Nothing: Start with an empty target definition”

targetdef1

In the Locations Tab you will Add 4 Directories

target1

C:\Program Files\IBM\Domino\data\domino\workspace\applications\eclipse\plugins\

C:\Program Files\IBM\Domino\jvm\lib\ext\

C:\Program Files\IBM\Domino\osgi\rcp\eclipse\plugins\

C:\Program Files\IBM\Domino\osgi\shared\eclipse\plugins\

Once you have completed these steps you now have setup Eclipse to be able to develop OSGi Bundles for Domino.  In the next part we will create the bundle and discuss each part of the plugin.xml that needs to be setup to create a JAX-RS Service.

Advertisements

Obligatory egocentric First Post

OK, so I’ve thought about doing this for awhile, tried it once or twice, however I never really kept it up.  So I have a new philosophy.  This blog will be for my thoughts on Xpages Development, Java Development, Domino, OSGi, Websphere, .net, other random technical stuff and maybe some personal life stuff.  But it will be a blog that I will occasionally write on.  I have been prodded and inspired by many in the IBM Notes and Domino community, but while typing this a couple come to mind that I’d like to mention.  First of all Marky Roden made a heck of a case for blogging even if you are like me and can’t put together two words in his blog post.  Also Kathy Brown described kind of how I feel when I go to community events and when I interact with others in the community at her spark ideas session.  So Hopefully I will feel like blogging again and this blog will not just be abandoned like so many before it.  I also have plans to put up a dev/demo box that I have so I can run some of the things I’m talking about online, but all in good time I guess.  So in conclusion I hope that I don’t bore you too much with my ramblings and odd discussion of some rather obscure technology.