2
edits
Changes
First bundle
[[Category:OSGi]]{{Ecl_menu}}__NOTOC__
== Example of OSGi service system ==
Let us suppose that you were asked to implement a '''voting system as an OSGi service system'''.
The system should be generic enough so that it could be used for any election. Therefore you will not be using specific candidate names, as they can change for different elections.
As a proof of concept, you will be given three candidates and as the election takes place you have to print the number of votes for each candidate.
== Design and implementation ==
<h4> 1. Define the Bundle Service Interface</h4>
Create the bundle ''cs.ecl.osgi.voting_1.0.1.qualifier''
<h6> 1.1 Create the VotingSystem.java </h6>
<source lang="java">
package cs.ecl.osgi.voting;
public interface VotingSystem {
int[] countVotesFor(String code);
}
</source>
<h6> 1.2 Define the MANIFEST.MF for the bundle interface </h6>
<source lang="xml">
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Voting System
Bundle-SymbolicName: cs.ecl.osgi.voting
Bundle-Version: 1.0.1.qualifier
Bundle-Vendor: Seneca College - Eclipse Course
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: cs.ecl.osgi.voting
</source>
Note: The bundle does not need an activator.
== Example of OSGi service system ==
Let us suppose that you were asked to implement a '''voting system as an OSGi service system'''.
The system should be generic enough so that it could be used for any election. Therefore you will not be using specific candidate names, as they can change for different elections.
As a proof of concept, you will be given three candidates and as the election takes place you have to print the number of votes for each candidate.
== Design and implementation ==
<h4> 1. Define the Bundle Service Interface</h4>
Create the bundle ''cs.ecl.osgi.voting_1.0.1.qualifier''
<h6> 1.1 Create the VotingSystem.java </h6>
<source lang="java">
package cs.ecl.osgi.voting;
public interface VotingSystem {
int[] countVotesFor(String code);
}
</source>
<h6> 1.2 Define the MANIFEST.MF for the bundle interface </h6>
<source lang="xml">
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Voting System
Bundle-SymbolicName: cs.ecl.osgi.voting
Bundle-Version: 1.0.1.qualifier
Bundle-Vendor: Seneca College - Eclipse Course
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: cs.ecl.osgi.voting
</source>
Note: The bundle does not need an activator.