<< Fixing IBM Connections help for IE users | Home | Setting up LDAP failover for Websphere Application Server >>

Looking up a datasource from an IBM Connections event handler

For a customer project I'm working on these days I'm writing an event handler for IBM Connections Profiles to integrate two profile systems in real-time using the IBM Connections 4.0 Event SPI. Pretty powerful stuff in case you've never looked into it.

In IBM Connections an event handler is basically just a Java bean which you register in events-config.xml to be called when certain events occur such as a profile being updated, the photo set, the photo removed etc. In this event handler I needed to contact the Profiles database which should be easy as it's registered in JNDI in Websphere Application Server. I couldn't however use the usual java:comp/env/jdbc/profiles resource reference as there's no J2EE deployment description for the event handler and hence the naming context hasn't been mapped for me.

But with Websphere Application Server being the all-purpose application server that it is, I was able to find a way to make it work anyway. It turns out that all resources are mapped into a JNDI namespace using their cell and cluster prefix as well (I was able to deduce it from the "Example: Looking up an EJB home or business interface with JNDI" page).

So to look up the jdbc/profiles data source from the Cluster1-cluster scope I simply use the following. Sweet.

try {
   InitialContext ctx = new InitialContext();
   DataSource ds = (DataSource)ctx.lookup("cell/clusters/Cluster1/jdbc/profiles");
} catch (NamingException e) {
   // unable to lookup data source
}




Add a comment Send a TrackBack