{"id":1443,"date":"2016-09-24T09:06:28","date_gmt":"2016-09-24T09:06:28","guid":{"rendered":"http:\/\/enprowess.com\/?p=1443"},"modified":"2016-09-24T09:06:28","modified_gmt":"2016-09-24T09:06:28","slug":"core-osgi","status":"publish","type":"post","link":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/","title":{"rendered":"OSGI Groundwork !!"},"content":{"rendered":"<p>The Open Services Gateway Initiative (OSGi) defines an architecture for developing and deploying modular applications and libraries. It is also known as the <strong>Dynamic Module System<\/strong> for Java, defines an architecture for modular application development. It is proven to help build, <strong>package and maintain robust API\u2019s<\/strong> for Java based Enterprise software components running in the Cloud or On Premise.<\/p>\n<p>It is a specification having various implementations like Eclipse Equinox, Apache Felix, Knopflerfish, ProSyst. There are 5 specifications versions released so far and Latest version 1.8.<\/p>\n<p>Why OSGi:<\/p>\n<ul>\n<li>Adhoc development: Many a times, there are cases where development team, knowingly\/unknowingly, uses the implementation to strengthen the ground rules of development by not exposing implementation.<\/li>\n<li>Architects are unaware of ground realities: Above mentioned point is most of the times unknown to architects and they don\u2019t look in to each of the implementations.<\/li>\n<li>Deadlines: Most of the times there are short deadlines on development which don\u2019t allow for structured document.<\/li>\n<\/ul>\n<p>How it helps:<\/p>\n<p>Considering all of the above points, OSGi enables implementation to be modularised, structured, and loosely coupled. Also, OSGi benefits faster deliverable considering \u201c<strong>Semantic versioning<\/strong>\u201d- which in simple words: Various versions of packages should reflect the evolution of these packages. For this reason, a change in the first (major) part of the version signals backward incompatible changes to the artifacts. That is, going from version 1.5 to version 2 signals that another artifact compiled against 1.5 up to (but not including) version 2 of that initial artifact is not compatible with the new version of the initial artifact.<\/p>\n<p>Let\u2019s go through an example of how OGSi services to manage and consumer concept demonstration.<\/p>\n<p>And before we proceed, here are the list of prerequisites:<\/p>\n<ul>\n<li>Java<\/li>\n<li>Eclipse<\/li>\n<\/ul>\n<p>Here are the steps.<\/p>\n<ol>\n<li>Create 3 new project as \u201c<em>plug-in project<\/em>\u201d name it as listed below.<\/li>\n<\/ol>\n<ul>\n<li>Summation Service. (Service and Implementation exposure)<\/li>\n<li>Subtraction Service. (Service and Implementation exposure)<\/li>\n<li>Calculator. (Consumer of above mentioned services)<\/li>\n<\/ul>\n<ol start=\"2\">\n<li>In Summation service, let\u2019s create \u201c<em>SummationService<\/em>\u201d which is an Interface and \u201c<em>SummationServiceImpl<\/em>\u201d which is an implementation class to perform sum activity.<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-1444  alignnone\" src=\"http:\/\/www.enprowess.com\/blogs\/wp-content\/uploads\/2016\/09\/1.png\" alt=\"1\" width=\"637\" height=\"367\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-1445 alignnone\" src=\"http:\/\/www.enprowess.com\/blogs\/wp-content\/uploads\/2016\/09\/2.png\" alt=\"2\" width=\"602\" height=\"299\" \/><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"3\">\n<li>Modify Activator Class of \u201c<em>SummationService<\/em>\u201d and Register \u201c<em>SumService<\/em>\u201d in start method.<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-1446 alignnone\" src=\"http:\/\/www.enprowess.com\/blogs\/wp-content\/uploads\/2016\/09\/3.png\" alt=\"3\" width=\"674\" height=\"313\" \/><\/p>\n<p><\/p>\n<p><strong><u>Activator class<\/u><\/strong>:- Activator class which implements the BundleActivator\u00a0interface. An instance of this class is created when the plug-in gets activated. Its\u00a0start()\u00a0and stop()\u00a0methods are called whenever the plug-in is started or stopped.<\/p>\n<p><\/p>\n<ol start=\"4\">\n<li>Add service Packages which consumer needs to access. Here we used \u201c<em>enprowess.s<\/em>ummation.<em>service<\/em>\u201d for SummationService.<\/li>\n<\/ol>\n<p>Go to META-INF -&gt; MANIFEST.MF -&gt; Runtime -&gt; Add -&gt; \u201c<em>com.enprowess.s<\/em>ummation<em>.service<\/em>\u201d<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-1447 alignnone\" src=\"http:\/\/www.enprowess.com\/blogs\/wp-content\/uploads\/2016\/09\/4.png\" alt=\"4\" width=\"710\" height=\"382\" \/><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"5\">\n<li>In SubtrationService plug-in project, let\u2019s an interface \u201c<em>SubtrationService<\/em>\u201d and \u201c<em>SubtractionServicesImpl<\/em>\u201d class to perform subtraction activity. Follow same as step 2<\/li>\n<\/ol>\n<ol start=\"6\">\n<li>Modify \u201c<em>Activator<\/em>\u201d Class -&gt; SubtractionServices and perform subtraction. Register \u201c<em>SubtractionService<\/em>\u201d in start method.<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-1445 alignnone\" src=\"http:\/\/www.enprowess.com\/blogs\/wp-content\/uploads\/2016\/09\/5.png\" alt=\"2\" width=\"691\" height=\"334\" \/><\/p>\n<ol start=\"7\">\n<li>For \u201c<em>SubtractionServices<\/em>\u201d project, Add services Package \u201c<em>com.enprowess.subtraction<\/em><em>.service<\/em>\u201d which we want to allow consumer to access.<\/li>\n<\/ol>\n<p>Same as step 4.<\/p>\n<ol start=\"8\">\n<li>In Calculator project, modify default activator class.<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-1449 alignnone\" src=\"http:\/\/www.enprowess.com\/blogs\/wp-content\/uploads\/2016\/09\/6.png\" alt=\"6\" width=\"691\" height=\"334\" \/><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"9\">\n<li>Now let\u2019s add all the plug-ins required for project.<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-1450 alignnone\" src=\"http:\/\/www.enprowess.com\/blogs\/wp-content\/uploads\/2016\/09\/7.png\" alt=\"7\" width=\"758\" height=\"409\" \/><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"10\">\n<li>Set up the Run Configurations. Here we are using GOGO command shell dependencies.<\/li>\n<\/ol>\n<p>Right click on \u201cCalculator\u201d module and click on \u201c<em>Run As -&gt; Run Configurations<\/em>\u201d<\/p>\n<p>Click on \u201c<em>OSGi Framwork<\/em>\u201d \u2013 \u201c<em>New<\/em>\u201d.<\/p>\n<p>Provide appropriate name for this configuration. Here it is given as \u201c<em>Calculator<\/em>\u201d.<\/p>\n<p>Uncheck \u201c<em>Target Platform<\/em>\u201d and click on \u201c<em>Add Required Bundles<\/em>\u201d which should automatically add the required references. You may click on \u201c<em>Only show selected<\/em>\u201d just to view final list of dependencies.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-1451 alignnone\" src=\"http:\/\/www.enprowess.com\/blogs\/wp-content\/uploads\/2016\/09\/8.png\" alt=\"8\" width=\"711\" height=\"478\" \/><\/p>\n<p>&nbsp;<\/p>\n<ol start=\"11\">\n<li>Upon execution, the Output looks like below:<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-1452 alignnone\" src=\"http:\/\/www.enprowess.com\/blogs\/wp-content\/uploads\/2016\/09\/9.png\" alt=\"9\" width=\"715\" height=\"324\" \/><br \/>\n<br \/>\nImportant commands:<br \/>\n<br \/>\nss: list of services.<br \/>\n<br \/>\nStart &lt;id&gt;: It starts the service\/module mentioned by id from \u2018ss\u2019 command.<br \/>\n<br \/>\nStop &lt;id&gt;: It stop the service\/module mentioned by id from \u2018ss\u2019 command.<br \/>\n<br \/>\n&nbsp;<br \/>\n<br \/>\nTo summarize, we have seen in above example, how do we use osgi modularization. Decoupling of modules gives faster turnaround time and ultimately helps business to release features and fixes at faster pace.<br \/>\n<br \/>\nBlog By,<br \/>\n<br \/>\nSejal Patel<br \/>\nSoftware Engineer<\/p>\n<p><em><span style=\"text-decoration: underline;\"><a href=\"http:\/\/www.enprowess.com\/blogs\/service-builder-liferay-dxp\/\" target=\"_blank\" rel=\"noopener\">Click here for OSGi + Liferay\u00a0example<\/a><\/span><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Open Services Gateway Initiative (OSGi) defines an architecture for developing and deploying modular applications and libraries. It is also known as the Dynamic Module System for Java, defines an architecture for modular application development. It is proven to help build, package and maintain robust API\u2019s for Java based Enterprise software components running in the&hellip; <a class=\"more-link\" href=\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/\">Continue reading <span class=\"screen-reader-text\">OSGI Groundwork !!<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1736,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,18],"tags":[22,28,29],"class_list":["post-1443","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-liferay","category-liferay-dxp","tag-liferay","tag-osgi","tag-osgi-activator","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>OSGI Groundwork !! - EnProwess<\/title>\n<meta name=\"description\" content=\"Get started with Liferay modularity using OSGI.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get start with OSGI in Liferay DXP\" \/>\n<meta property=\"og:description\" content=\"Thinking to start learning Liferay 7\/DXP? Here is good kick start for OSGI Modularity in Liferay 7\/DXP.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/\" \/>\n<meta property=\"og:site_name\" content=\"EnProwess\" \/>\n<meta property=\"article:published_time\" content=\"2016-09-24T09:06:28+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.enprowess.com\/blogs\/wp-content\/uploads\/2016\/09\/howto.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Get start with OSGI in Liferay DXP\" \/>\n<meta name=\"twitter:description\" content=\"Thinking to start learning Liferay 7\/DXP? Here is good kick start for OSGI Modularity in Liferay 7\/DXP.\" \/>\n<meta name=\"twitter:image\" content=\"http:\/\/www.enprowess.com\/blogs\/wp-content\/uploads\/2016\/09\/howto.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"dev_admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/#website\",\"url\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/\",\"name\":\"EnProwess\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"\",\"contentUrl\":\"\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/#webpage\",\"url\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/\",\"name\":\"OSGI Groundwork !! - EnProwess\",\"isPartOf\":{\"@id\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/#primaryimage\"},\"datePublished\":\"2016-09-24T09:06:28+00:00\",\"dateModified\":\"2016-09-24T09:06:28+00:00\",\"author\":{\"@id\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/#\/schema\/person\/0bf4f9fb6538f60f497377ecceb54f55\"},\"description\":\"Get started with Liferay modularity using OSGI.\",\"breadcrumb\":{\"@id\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"OSGI Groundwork !!\"}]},{\"@type\":\"Person\",\"@id\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/#\/schema\/person\/0bf4f9fb6538f60f497377ecceb54f55\",\"name\":\"dev_admin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/wp-content\/uploads\/2021\/05\/p3.png\",\"contentUrl\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/wp-content\/uploads\/2021\/05\/p3.png\",\"caption\":\"dev_admin\"},\"sameAs\":[\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\"],\"url\":\"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/author\/dev_admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"OSGI Groundwork !! - EnProwess","description":"Get started with Liferay modularity using OSGI.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/","og_locale":"en_US","og_type":"article","og_title":"Get start with OSGI in Liferay DXP","og_description":"Thinking to start learning Liferay 7\/DXP? Here is good kick start for OSGI Modularity in Liferay 7\/DXP.","og_url":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/","og_site_name":"EnProwess","article_published_time":"2016-09-24T09:06:28+00:00","og_image":[{"url":"http:\/\/www.enprowess.com\/blogs\/wp-content\/uploads\/2016\/09\/howto.jpg"}],"twitter_card":"summary_large_image","twitter_title":"Get start with OSGI in Liferay DXP","twitter_description":"Thinking to start learning Liferay 7\/DXP? Here is good kick start for OSGI Modularity in Liferay 7\/DXP.","twitter_image":"http:\/\/www.enprowess.com\/blogs\/wp-content\/uploads\/2016\/09\/howto.jpg","twitter_misc":{"Written by":"dev_admin","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/#website","url":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/","name":"EnProwess","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/#primaryimage","inLanguage":"en-US","url":"","contentUrl":""},{"@type":"WebPage","@id":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/#webpage","url":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/","name":"OSGI Groundwork !! - EnProwess","isPartOf":{"@id":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/#website"},"primaryImageOfPage":{"@id":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/#primaryimage"},"datePublished":"2016-09-24T09:06:28+00:00","dateModified":"2016-09-24T09:06:28+00:00","author":{"@id":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/#\/schema\/person\/0bf4f9fb6538f60f497377ecceb54f55"},"description":"Get started with Liferay modularity using OSGI.","breadcrumb":{"@id":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/core-osgi\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/"},{"@type":"ListItem","position":2,"name":"OSGI Groundwork !!"}]},{"@type":"Person","@id":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/#\/schema\/person\/0bf4f9fb6538f60f497377ecceb54f55","name":"dev_admin","image":{"@type":"ImageObject","@id":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/#personlogo","inLanguage":"en-US","url":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/wp-content\/uploads\/2021\/05\/p3.png","contentUrl":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/wp-content\/uploads\/2021\/05\/p3.png","caption":"dev_admin"},"sameAs":["http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com"],"url":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/author\/dev_admin\/"}]}},"_links":{"self":[{"href":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/wp-json\/wp\/v2\/posts\/1443","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/wp-json\/wp\/v2\/comments?post=1443"}],"version-history":[{"count":0,"href":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/wp-json\/wp\/v2\/posts\/1443\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/wp-json\/"}],"wp:attachment":[{"href":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/wp-json\/wp\/v2\/media?parent=1443"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/wp-json\/wp\/v2\/categories?post=1443"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ws-srv-php72.in.webmyne.com\/enprowess.com\/wp-json\/wp\/v2\/tags?post=1443"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}