{"id":509,"date":"2016-12-31T18:29:37","date_gmt":"2016-12-31T17:29:37","guid":{"rendered":"http:\/\/h2916922.stratoserver.net:8084\/?p=509"},"modified":"2017-04-14T16:46:25","modified_gmt":"2017-04-14T14:46:25","slug":"invoking-icn-services-from-within-a-service-icnpluginbridge-jar","status":"publish","type":"post","link":"https:\/\/www.ivojonker.nl\/?p=509","title":{"rendered":"Invoking ICN services from within another service (ICNPluginBridge.jar)"},"content":{"rendered":"<p>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.<\/p>\n<p>In order to overcome this architectural issue, i &#8216;hacked&#8217; \u00a0together a plugin-bridge allowing exactly that. (feel free to contribute improvements, as this is only a work in progress)<\/p>\n<p>Simply add this jar to your plugin (or even better, as a shared library for your navigator.war), and you&#8217;re ready to do stuff such as:<\/p>\n<pre class=\"lang:default decode:true \">\/** Some service within some plugin *\/\r\npublic void execute(PluginServiceCallbacks callbacks, HttpServletRequest request, HttpServletResponse response) throws Exception {\r\n\tJSONObject result = new JSONObject();\r\n\r\n\tPluginBridge response=new PluginBridge().invoke(\"OtherPluginID\",\"OtherServiceID\", [optional params]);\r\n       \r\n\tresult.put(\"response\",\"The other response was: \"+response.getResponseAsString()); \r\n\r\n\tresponse.getWriter().write(result.toString());\r\n}\r\n<\/pre>\n<p>Useful, right? \ud83d\ude42<\/p>\n<p>Download the jar <a href=\".\/ivo\/wp-attachments\/ICNPluginBridge.jar\">here<\/a> (including source\/javadoc licensed under MPL-2.0).<\/p>\n<p>&nbsp;<\/p>\n<p>edit april 14:<\/p>\n<p>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!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-509","post","type-post","status-publish","format-standard","hentry","category-geen-categorie"],"_links":{"self":[{"href":"https:\/\/www.ivojonker.nl\/index.php?rest_route=\/wp\/v2\/posts\/509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ivojonker.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ivojonker.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ivojonker.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ivojonker.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=509"}],"version-history":[{"count":8,"href":"https:\/\/www.ivojonker.nl\/index.php?rest_route=\/wp\/v2\/posts\/509\/revisions"}],"predecessor-version":[{"id":545,"href":"https:\/\/www.ivojonker.nl\/index.php?rest_route=\/wp\/v2\/posts\/509\/revisions\/545"}],"wp:attachment":[{"href":"https:\/\/www.ivojonker.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=509"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ivojonker.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=509"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ivojonker.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}