Difference between revisions of "OSGi : Develop Simple Apps"

From CDOT Wiki
Jump to: navigation, search
(step 1)
Line 1: Line 1:
 
{{Ecl_activities|type=OSGi|type-repo=osgi}}
 
{{Ecl_activities|type=OSGi|type-repo=osgi}}
  
<h2>Important Interfaces</h2>
+
# Check out the [https://guest:1673852@zenit.senecac.on.ca/svn/ecl500/Lectures/trunk/w11-osgi-simple-interface/ Service Interface]
[http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html Bundle]
+
# Check out the [https://guest:1673852@zenit.senecac.on.ca/svn/ecl500/Lectures/trunk/w11-osgi-simple-serviceprovider/ Service Provider]
[http://www.osgi.org/javadoc/r4v42/org/osgi/framework/BundleContext.html BundleContext]
+
# Check out the [https://guest:1673852@zenit.senecac.on.ca/svn/ecl500/Lectures/trunk/w11-osgi-simple-serviceconsumer/ Service Consumer]
[http://www.osgi.org/javadoc/r4v42/org/osgi/framework/BundleActivator.html BundleActivator]
 
 
 
 
 
  
 +
<strong>Steps for Building Bundels</strong>
  
 +
<h4>1. Study the Interfaces</h4>
  
 +
* [http://www.osgi.org/javadoc/r4v42/org/osgi/framework/Bundle.html Bundle]
 +
* [http://www.osgi.org/javadoc/r4v42/org/osgi/framework/BundleContext.html BundleContext]
 +
* [http://www.osgi.org/javadoc/r4v42/org/osgi/framework/BundleActivator.html BundleActivator]
  
 +
<h4>2. Define the Bundle that provide the service (Provider Bundle)</h4>
 +
<h5>2.1 Define the Java Interface that exposes the services</h5>
 +
Let us suppose that you want to define a service that allows the user to find a book from the book isbn. Then the interface should look similare with this one:
 +
<source lang="java">
 +
package cs.ecl.osgi.simple.bookfinder;
  
# Check out the [https://guest:1673852@zenit.senecac.on.ca/svn/ecl500/Lectures/trunk/w11-osgi-simple-interface/ Service Interface]
+
public interface BookFinder {
# Check out the [https://guest:1673852@zenit.senecac.on.ca/svn/ecl500/Lectures/trunk/w11-osgi-simple-serviceprovider/ Service Provider]
+
Book findBook(int isbn) throws BookNotFoundException;
# Check out the [https://guest:1673852@zenit.senecac.on.ca/svn/ecl500/Lectures/trunk/w11-osgi-simple-serviceconsumer/ Service Consumer]
+
}
 +
</source>

Revision as of 14:27, 22 January 2011


OSGi Activities



Start the lab activities in the order defined below:

  1. Check out the Service Interface
  2. Check out the Service Provider
  3. Check out the Service Consumer

Steps for Building Bundels

1. Study the Interfaces

2. Define the Bundle that provide the service (Provider Bundle)

2.1 Define the Java Interface that exposes the services

Let us suppose that you want to define a service that allows the user to find a book from the book isbn. Then the interface should look similare with this one:

package cs.ecl.osgi.simple.bookfinder;

public interface BookFinder {
	Book findBook(int isbn) throws BookNotFoundException;
}