Invoking ICN services from within another service (ICNPluginBridge.jar)

When creating IBM Content Navigator plugins (or Case Manager Widgets), it may be a good idea to bundle generic services into a single plugin. The problem however is, that there is no straightforward way to invoke these services from within another plugin, as each plugin is loaded with its own classloader.

In order to overcome this architectural issue, i ‘hacked’  together a plugin-bridge allowing exactly that. (feel free to contribute improvements, as this is only a work in progress)

Simply add this jar to your plugin (or even better, as a shared library for your navigator.war), and you’re ready to do stuff such as:

/** Some service within some plugin */
public void execute(PluginServiceCallbacks callbacks, HttpServletRequest request, HttpServletResponse response) throws Exception {
	JSONObject result = new JSONObject();

	PluginBridge response=new PluginBridge().invoke("OtherPluginID","OtherServiceID", [optional params]);
       
	result.put("response","The other response was: "+response.getResponseAsString()); 

	response.getWriter().write(result.toString());
}

Useful, right? 🙂

Download the jar here (including source/javadoc licensed under MPL-2.0).

 

edit april 14:

I actually just recently discovered 2.0.3. introcued the com.ibm.ecm.extension.PluginAPI which is, by design a better solution to share functionality amonst different plugins. Check it out!

 

Leave a Reply

Your email address will not be published. Required fields are marked *