{"id":788,"date":"2012-01-30T19:17:00","date_gmt":"2012-01-30T19:17:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/introduction-to-osgi-modular-java.html"},"modified":"2012-10-21T22:38:49","modified_gmt":"2012-10-21T22:38:49","slug":"introduction-to-osgi-modular-java","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html","title":{"rendered":"Introduction to OSGi &#8211; Modular Java"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\"><a href=\"http:\/\/www.osgi.org\/\">OSGi Alliance<\/a> is the governing body of this stranded and it was started at 1999. their initial goal was create open stranded for network devices. Based on this idea this specification introduced for Java also. Eclipse was first in Java. they introduced OSGi based Eclipse IDE at 2004 June.<\/p>\n<p>OSGi is way to define dynamic module in java. There are main three OSGi container implemented for Java,such as<a href=\"http:\/\/felix.apache.org\/\"> Apache Felix<\/a>, <a href=\"http:\/\/www.eclipse.org\/equinox\/\">Eclipse Equinox <\/a>and <a href=\"http:\/\/www.knopflerfish.org\/\">Knopflefish<\/a>.<\/p>\n<p>Why OSGi? Because OSGi provide ability to divided application in to multiple module and those module easy to manage with other dependencies. other than that is very easy to install, update,stop and delete module without stop engine(Ex: Tomcat web application container). We can have multiple version of implementation with effecting to other references.<\/p>\n<p>There are main 3 layers in web based Java framework(Presentation , Business layer and  DAO layer). There we can divide it into three OSGi based module. then we can very easily fixed bug in one layer with out effecting to others and restarting our Web container. Just we need to update out module.<\/p>\n<p>in OSGi world output is bundle, it can be either Jar or War file. A bundle consists of Java classes and other resources that with some additional metadata (providing services and packages to other bundles).<\/p>\n<p>I am going to use Eclipse IDE for create my first bundle. Because Eclipse IDe has built in Equinox container(every eclipse plugins are OSGi bundles) .  <\/p>\n<p><strong>Create Eclipse Plug-In-Project<\/strong><\/p>\n<ul style=\"text-align: left\">\n<li>Go to <strong>New&#8211;&gt; Other &#8211;&gt; Plug-In-Project<\/strong> and click on <strong>Next<\/strong> then new project creation dialog will be appeared<\/li>\n<li>Provide project name and Target platform as below. and Click on <strong>Next<\/strong><\/li>\n<\/ul>\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Project name&nbsp;&nbsp;&nbsp;&nbsp; : <strong>com.chandana.Hello.HelloWorld<\/strong><br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Target platform : select <strong>Stranded OSGi<\/strong><\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/3.bp.blogspot.com\/-l9JMRtm7Fjw\/TyRU27WLouI\/AAAAAAAAAGA\/ITN3xBiBk_U\/s1600\/1.png\"><img decoding=\"async\" border=\"0\" height=\"320\" src=\"http:\/\/3.bp.blogspot.com\/-l9JMRtm7Fjw\/TyRU27WLouI\/AAAAAAAAAGA\/ITN3xBiBk_U\/s320\/1.png\" width=\"301\" \/><\/a><\/div>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><\/div>\n<ul style=\"text-align: left\">\n<li>In next screen you can change bundle information(These information available in MANIFEST.MF&nbsp; and I will give details information later) then click on Next button.<\/li>\n<\/ul>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/-GOesaZt6jCQ\/TyRVEfzO86I\/AAAAAAAAAGI\/PcATjNtGYEo\/s1600\/2.png\"><img decoding=\"async\" border=\"0\" height=\"320\" src=\"http:\/\/2.bp.blogspot.com\/-GOesaZt6jCQ\/TyRVEfzO86I\/AAAAAAAAAGI\/PcATjNtGYEo\/s320\/2.png\" width=\"301\" \/><\/a><\/div>\n<ul style=\"text-align: left\">\n<li>After that OSGi project template selection dialog will be appear.There select&nbsp; Hello OSGi Bundle and click on Finish<\/li>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><\/div>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/1.bp.blogspot.com\/-oZUu6Nq3cf4\/TyRVS2QN3YI\/AAAAAAAAAGQ\/dpZA5X9zrHw\/s1600\/3.png\"><img decoding=\"async\" border=\"0\" height=\"320\" src=\"http:\/\/1.bp.blogspot.com\/-oZUu6Nq3cf4\/TyRVS2QN3YI\/AAAAAAAAAGQ\/dpZA5X9zrHw\/s320\/3.png\" width=\"301\" \/><\/a><\/div>\n<\/ul>\n<p>After few second Eclipse will generate Hello World Plug-In-Project(I had Not responding few second :) )<\/p>\n<p>In my project structure is like this:<\/p>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/1.bp.blogspot.com\/-hIubft8u_ZU\/TyRVx41cA3I\/AAAAAAAAAGY\/bY0axnPDMGE\/s1600\/4.png\"><img decoding=\"async\" border=\"0\" height=\"320\" src=\"http:\/\/1.bp.blogspot.com\/-hIubft8u_ZU\/TyRVx41cA3I\/AAAAAAAAAGY\/bY0axnPDMGE\/s320\/4.png\" width=\"269\" \/><\/a><\/div>\n<p><strong>Activator.java<\/strong><\/p>\n<pre class=\"brush: java;\">package com.chandana.hello.helloworld;\r\n \r\nimport org.osgi.framework.BundleActivator;\r\nimport org.osgi.framework.BundleContext;\r\n \r\npublic class Activator implements BundleActivator {\r\n \r\n \/*\r\n  * (non-Javadoc)\r\n  * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)\r\n  *\/\r\n public void start(BundleContext context) throws Exception {\r\n  System.out.println(\"Hello World!!\");\r\n }\r\n  \r\n \/*\r\n  * (non-Javadoc)\r\n  * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)\r\n  *\/\r\n public void stop(BundleContext context) throws Exception {\r\n  System.out.println(\"Goodbye World!!\");\r\n }\r\n \r\n}\r\n<\/pre>\n<p>Activator is class which implement <strong><span class=\"Apple-style-span\" style=\"color: blue\">BundleActivator<\/span><span class=\"Apple-style-span\" style=\"color: purple\"> <\/span><\/strong> interface. It has <strong><span class=\"Apple-style-span\" style=\"color: blue\">stop<\/span><span class=\"Apple-style-span\" style=\"color: purple\"> <\/span><\/strong>and <strong><span class=\"Apple-style-span\" style=\"color: blue\">start<\/span><span class=\"Apple-style-span\" style=\"color: purple\"> <\/span><\/strong>methods.<span class=\"Apple-style-span\" style=\"color: purple\">&nbsp;<\/span><span class=\"Apple-style-span\" style=\"color: blue\">Those methods are called when a bundle is started or stopped<\/span>. This bundle activator class specify in <span class=\"Apple-style-span\" style=\"color: blue\"><strong>MENIFEST.MF<\/strong> file(<strong>Bundle-Activator<\/strong> entry). <\/span><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><span class=\"Apple-style-span\" style=\"color: blue\">Start Method:<\/span><br \/>\nThe OSGi container calls start method when bundle is starting. We can use this start method for initialized database connection, register a service for other bundle use.<br \/>\n<span class=\"Apple-style-span\" style=\"color: blue\">Stop Method:<\/span><br \/>\nThe OSGi container calls stop method when bundle is stopping. We can use this method for remove services form service registry like clean up process <\/p>\n<p><strong>MANIFEST.MF<\/strong><\/p>\n<pre class=\"brush: bash;\">Manifest-Version: 1.0\r\nBundle-ManifestVersion: 2\r\nBundle-Name: HelloWorld\r\nBundle-SymbolicName: com.chandana.Hello.HelloWorld\r\nBundle-Version: 1.0.0.qualifier\r\nBundle-Activator: com.chandana.hello.helloworld.Activator\r\nBundle-Vendor: CHANDANA\r\nBundle-RequiredExecutionEnvironment: JavaSE-1.6\r\nImport-Package: org.osgi.framework;version=\"1.3.0\"\r\n<\/pre>\n<p><strong>Bundle-ManifestVersion<\/strong><br \/>\nBundle-ManifestVersion header show the OSGi container that this bundle follows the rules of the OSGi specification. A value of 2 means that the bundle is compliant with OSGi specification Release 4; a value of 1 means that it is compliant with Release 3 or earlier. <\/p>\n<p><strong>Bundle-Name<\/strong><br \/>\nBundle-Name header defines a short readable name for bundle. <\/p>\n<p><strong>Bundle-SymbolicName<\/strong><br \/>\nBundle-SymbolicName header specifies a unique name for the bundle. This is the name you will use while referring a given bundle from other bundles.<\/p>\n<p><strong>Bundle-Version<\/strong><br \/>\nBundle-Version header is the version number of the bundle.<\/p>\n<p><strong>Bundle-Vendor<\/strong><br \/>\nBundle-Vendor header is description of the vendor(foe example it&#8217;s my name).<\/p>\n<p><strong>Import-Package<\/strong><br \/>\nImport-Package is indicate what are the other Java bundle(OSGi) required for this bundle. what we called dependency. <\/p>\n<p><strong>Export-Package<\/strong><br \/>\nExport-Package is indicate what are public packages in bundle and those Export-Package can import from other bundle.<\/p>\n<p><strong>Run the Bundle:<\/strong><\/p>\n<ul style=\"text-align: left\">\n<li>For Run this project click on Run &#8211;&gt; Run Configuration , In OSGi Framework  Right click and create new Run Configuration.<\/li>\n<\/ul>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/3.bp.blogspot.com\/-iw6Hn2gZ2Lk\/TyRXlOeK6iI\/AAAAAAAAAGg\/pDQXT00qVQc\/s1600\/5.png\"><img decoding=\"async\" border=\"0\" height=\"232\" src=\"http:\/\/3.bp.blogspot.com\/-iw6Hn2gZ2Lk\/TyRXlOeK6iI\/AAAAAAAAAGg\/pDQXT00qVQc\/s320\/5.png\" width=\"320\" \/><\/a><\/div>\n<div>\n<ul style=\"text-align: left\">\n<li>First unchecked the all target platform and Click on <strong>Add Required Bundles<\/strong>.<\/li>\n<li>After that Apply the changes and Run the project by click in  Run button.<\/li>\n<li>After Run the project OSGi console display like below.<\/li>\n<\/ul>\n<div class=\"separator\" style=\"clear: both;text-align: center\"><a href=\"http:\/\/2.bp.blogspot.com\/-hDdoxVL8TKY\/TyRX4Y4RMtI\/AAAAAAAAAGo\/moBaMnaIl90\/s1600\/6.png\"><img decoding=\"async\" border=\"0\" height=\"156\" src=\"http:\/\/2.bp.blogspot.com\/-hDdoxVL8TKY\/TyRX4Y4RMtI\/AAAAAAAAAGo\/moBaMnaIl90\/s320\/6.png\" width=\"320\" \/><\/a><\/div>\n<p><strong>OSGi Terminal Commands:<\/strong><\/p>\n<div style=\"text-align: left\"><span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">start &nbsp; &nbsp; &nbsp; &nbsp; &#8211; start the specified bundle(s)<\/span><\/div>\n<div style=\"text-align: left\"><span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">stop &nbsp; &nbsp; &nbsp; &nbsp; &#8211; stop the specified bundle(s)<\/span><\/div>\n<div style=\"text-align: left\"><span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">uninstall &nbsp; &nbsp;&#8211; uninstall the specified bundle(s)<\/span><\/div>\n<div style=\"text-align: left\"><span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">update &nbsp; &nbsp; &nbsp;&#8211; update the specified bundle(s)<\/span><\/div>\n<div style=\"text-align: left\"><span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">refresh &nbsp; &nbsp; &nbsp;&#8211;  refresh the packages of the specified bundles<\/span><\/div>\n<div style=\"text-align: left\"><span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">b &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&#8211; display details for the specified bundle(s)<\/span><\/div>\n<div style=\"text-align: left\"><span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">headers &nbsp; &nbsp; &#8211; print bundle headers<\/span><\/div>\n<div style=\"text-align: left\"><span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\">services &nbsp; &nbsp; &#8211;  display registered service details<\/span><br \/>\n<span class=\"Apple-style-span\" style=\"font-family: 'Courier New', Courier, monospace\"><br \/>\n<\/span><\/div>\n<\/div>\n<p><a href=\"http:\/\/osgi-world.googlecode.com\/svn\/trunk\/com.chandana.Hello.HelloWorld\/\">Source Code<\/a><\/p>\n<p>Next i will describe how to create dependency based OSGi bundle.<\/p>\n<p>An OSGi Service is a java object instance which is registered with OSGi framework with set of attributes. Services can be accessed via service registry(performed via the class BundleContext). BundleActivator is to be invoked on start and stop. When BundleActivator call start method we are going to register our service. After that any bundle can access that service.<\/p>\n<p><strong>Service Bundle:<\/strong><\/p>\n<p>In service bundle you need to export your service and need to register it via service registry. When we are exporting service we export interface package only. As usual that is to hide the implementation from the other bundles.<\/p>\n<p>I have created a sample OSGi project called HelloService<\/p>\n<p><strong>MANIFEST.MF<\/strong><\/p>\n<pre class=\"brush: bash;\">Manifest-Version: 1.0\r\nBundle-ManifestVersion: 2\r\nBundle-Name: HelloService\r\nBundle-SymbolicName: com.chandana.hello.HelloService\r\nBundle-Version: 1.0.0\r\nBundle-Activator: com.chandana.hello.helloservice.Activator\r\nBundle-Vendor: CHANDANA\r\nBundle-RequiredExecutionEnvironment: JavaSE-1.6\r\nImport-Package: org.osgi.framework;version=\"1.3.0\"\r\nExport-Package: com.chandana.hello.service\r\nBundle-ActivationPolicy: lazy\r\n<\/pre>\n<p><strong>Service Interface:<\/strong><\/p>\n<pre class=\"brush: java;\">public interface  HelloService {    \r\n    public String helloMethods();\r\n}\r\n<\/pre>\n<p><strong>Service Implementation:<\/strong><\/p>\n<pre class=\"brush: java;\">public class HelloServiceImpl implements HelloService {\r\n    @Override\r\n    public String helloMethods() {\r\n        String retValue = \"Inside Hello Service method\";\r\n        return retValue;\r\n    }\r\n}\r\n<\/pre>\n<p><strong>Boundle Activator:<\/strong><\/p>\n<pre class=\"brush: java;\">public class Activator implements BundleActivator {\r\n    ServiceRegistration serviceRegistration;\r\n    \/*\r\n     * (non-Javadoc)\r\n     * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)\r\n     *\/\r\n    public void start(BundleContext context) throws Exception {\r\n        System.out.println(\"Bundle Started.....!!!!!\");\r\n        HelloService service = new HelloServiceImpl();\r\n        serviceRegistration = context.registerService(HelloService.class.getName(), service,null);\r\n    }\r\n     \r\n    \/*\r\n     * (non-Javadoc)\r\n     * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)\r\n     *\/\r\n    public void stop(BundleContext context) throws Exception {\r\n        System.out.println(\"Bundle Stoped.....!!!!!\");\r\n        serviceRegistration.unregister();\r\n    }\r\n}\r\n<\/pre>\n<p>When we are using published services, we can import it from another Bundle. So need to create another <strong>Plug-In-Project <\/strong>for HelloClient<\/p>\n<p><strong>Bundle Context<\/strong><\/p>\n<p>Bundle context is the context of a single bundle within the OSGi runtime and it is created when Bundle get started. Bundle context can be used to Install new bundles, Obtain registered services by other bundles and Register services in the framework.<\/p>\n<p><strong>MANIFEST.MF<\/strong><\/p>\n<pre class=\"brush: java;\">Import-Package: org.osgi.framework;version=\"1.3.0\",com.chandana.hello.service\r\n<\/pre>\n<p>After importing the bundle, you can access the service. Important thing is service can be accessed only through bundle context. You can get actual service object via BundleContext.getService() method .<\/p>\n<p><strong>Activator class: <\/strong><\/p>\n<pre class=\"brush: java;\">public class Activator implements BundleActivator {\r\n     ServiceReference serviceReference;     \r\n    \/*\r\n     * (non-Javadoc)\r\n     * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)\r\n     *\/\r\n    public void start(BundleContext context) throws Exception {\r\n        serviceReference= context.getServiceReference(HelloService.class.getName());\r\n        HelloService helloService =(HelloService)context.getService(serviceReference);\r\n        System.out.println(helloService.helloMethods());\r\n    }\r\n     \r\n    \/*\r\n     * (non-Javadoc)\r\n     * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)\r\n     *\/\r\n    public void stop(BundleContext context) throws Exception {\r\n        context.ungetService(serviceReference);\r\n    }\r\n}\r\n<\/pre>\n<p>context.getServiceReference() method return the HelloService OSGi service reference  and Using that service reference can access the actual service object.<\/p>\n<p>For Run this project click on <strong>Run &#8211;&gt; Run Configuration<\/strong> , In <strong>OSGi Framework<\/strong>  Right click and create <strong>new Run Configuration<\/strong>. Make sure <strong>HelloService <\/strong>and <strong>HelloClient <\/strong>. <\/p>\n<p><strong>Issues<\/strong>:<br \/>\nWhat happened if the service is not started when client is accessing the service?<br \/>\nWhat happened if you have stopped the service bundle?<\/p>\n<p><strong>Code Repo<\/strong>:<br \/>\n<a href=\"http:\/\/code.google.com\/p\/osgi-world\/source\/browse\/#svn\/trunk\/com.chandana.hello.HelloService\">http:\/\/code.google.com\/p\/osgi-world\/source\/browse\/#svn\/trunk\/com.chandana.hello.HelloService<\/a><br \/>\n<a href=\"http:\/\/code.google.com\/p\/osgi-world\/source\/browse\/#svn\/trunk\/com.chandana.hello.HelloClient\">http:\/\/code.google.com\/p\/osgi-world\/source\/browse\/#svn\/trunk\/com.chandana.hello.HelloClient<\/a><\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/cnapagoda.blogspot.com\/2011\/09\/introduction-to-osgijava-modular.html\">Introduction to OSGi(Java Modular)<\/a>&nbsp;&amp;&nbsp;<a href=\"http:\/\/cnapagoda.blogspot.com\/2012\/01\/introduction-to-osgi-2-osgi-services.html\">Introduction to OSGi &#8211; 2 (OSGi Services)<\/a>&nbsp;from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a><span class=\"Apple-style-span\" style=\"font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif\"><span class=\"Apple-style-span\" style=\"font-size: 14px;line-height: 18px\"><strong>&nbsp;<\/strong><\/span><\/span>Chandana Napagoda at the&nbsp;<a href=\"http:\/\/cnapagoda.blogspot.com\/\">Chandana Napagoda blog<\/a>.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>OSGi Alliance is the governing body of this stranded and it was started at 1999. their initial goal was create open stranded for network devices. Based on this idea this specification introduced for Java also. Eclipse was first in Java. they introduced OSGi based Eclipse IDE at 2004 June. OSGi is way to define dynamic &hellip;<\/p>\n","protected":false},"author":140,"featured_media":211,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[190],"class_list":["post-788","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-osgi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Introduction to OSGi - Modular Java - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"OSGi Alliance is the governing body of this stranded and it was started at 1999. their initial goal was create open stranded for network devices. Based on\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Introduction to OSGi - Modular Java - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"OSGi Alliance is the governing body of this stranded and it was started at 1999. their initial goal was create open stranded for network devices. Based on\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2012-01-30T19:17:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T22:38:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/osgi-alliance-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Chandana Napagoda\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Chandana Napagoda\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/introduction-to-osgi-modular-java.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/introduction-to-osgi-modular-java.html\"},\"author\":{\"name\":\"Chandana Napagoda\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/e9e7d8566a00e5b94b46c214c9818195\"},\"headline\":\"Introduction to OSGi &#8211; Modular Java\",\"datePublished\":\"2012-01-30T19:17:00+00:00\",\"dateModified\":\"2012-10-21T22:38:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/introduction-to-osgi-modular-java.html\"},\"wordCount\":1122,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/introduction-to-osgi-modular-java.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/osgi-alliance-logo.jpg\",\"keywords\":[\"OSGi\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/introduction-to-osgi-modular-java.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/introduction-to-osgi-modular-java.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/introduction-to-osgi-modular-java.html\",\"name\":\"Introduction to OSGi - Modular Java - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/introduction-to-osgi-modular-java.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/introduction-to-osgi-modular-java.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/osgi-alliance-logo.jpg\",\"datePublished\":\"2012-01-30T19:17:00+00:00\",\"dateModified\":\"2012-10-21T22:38:49+00:00\",\"description\":\"OSGi Alliance is the governing body of this stranded and it was started at 1999. their initial goal was create open stranded for network devices. Based on\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/introduction-to-osgi-modular-java.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/introduction-to-osgi-modular-java.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/introduction-to-osgi-modular-java.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/osgi-alliance-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/osgi-alliance-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/01\\\/introduction-to-osgi-modular-java.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Introduction to OSGi &#8211; Modular Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/e9e7d8566a00e5b94b46c214c9818195\",\"name\":\"Chandana Napagoda\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1d677363d39d454177f0e9595ded61d7f01226256cb031435e58a09569204bb1?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1d677363d39d454177f0e9595ded61d7f01226256cb031435e58a09569204bb1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/1d677363d39d454177f0e9595ded61d7f01226256cb031435e58a09569204bb1?s=96&d=mm&r=g\",\"caption\":\"Chandana Napagoda\"},\"sameAs\":[\"http:\\\/\\\/cnapagoda.blogspot.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/chandana-napagoda\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Introduction to OSGi - Modular Java - Java Code Geeks","description":"OSGi Alliance is the governing body of this stranded and it was started at 1999. their initial goal was create open stranded for network devices. Based on","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":"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html","og_locale":"en_US","og_type":"article","og_title":"Introduction to OSGi - Modular Java - Java Code Geeks","og_description":"OSGi Alliance is the governing body of this stranded and it was started at 1999. their initial goal was create open stranded for network devices. Based on","og_url":"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-01-30T19:17:00+00:00","article_modified_time":"2012-10-21T22:38:49+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/osgi-alliance-logo.jpg","type":"image\/jpeg"}],"author":"Chandana Napagoda","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Chandana Napagoda","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html"},"author":{"name":"Chandana Napagoda","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/e9e7d8566a00e5b94b46c214c9818195"},"headline":"Introduction to OSGi &#8211; Modular Java","datePublished":"2012-01-30T19:17:00+00:00","dateModified":"2012-10-21T22:38:49+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html"},"wordCount":1122,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/osgi-alliance-logo.jpg","keywords":["OSGi"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html","url":"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html","name":"Introduction to OSGi - Modular Java - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/osgi-alliance-logo.jpg","datePublished":"2012-01-30T19:17:00+00:00","dateModified":"2012-10-21T22:38:49+00:00","description":"OSGi Alliance is the governing body of this stranded and it was started at 1999. their initial goal was create open stranded for network devices. Based on","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/osgi-alliance-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/osgi-alliance-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2012\/01\/introduction-to-osgi-modular-java.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Introduction to OSGi &#8211; Modular Java"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/e9e7d8566a00e5b94b46c214c9818195","name":"Chandana Napagoda","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/1d677363d39d454177f0e9595ded61d7f01226256cb031435e58a09569204bb1?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/1d677363d39d454177f0e9595ded61d7f01226256cb031435e58a09569204bb1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1d677363d39d454177f0e9595ded61d7f01226256cb031435e58a09569204bb1?s=96&d=mm&r=g","caption":"Chandana Napagoda"},"sameAs":["http:\/\/cnapagoda.blogspot.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/chandana-napagoda"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/788","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/140"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=788"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/788\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/211"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=788"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=788"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=788"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}