Changes

Jump to: navigation, search

Teams Winter 2011/team1/OSGI/Create the Service Interface

1,528 bytes added, 13:07, 16 February 2011
1. Create the Service Interface
===1. Create the Service Interface===
'''1.1. Define the interface bundle'''<br/>
:[[Image: 1_CreateNewPlugInProject.JPG| 700px]]
:[[ImageFirst thing to do in building an OSGI application is to define the service interface so that the developer who creates the GUI part of application knows what services will be available, and what are their requirements and outcome.In order to do this please follow these steps: 2_CreateNewPlugInProject'''1.1.jpg | 700px]]Create the interface bundle'''<br/> :Create a new Plug-in project in eclipse using File>New> Plug-in Project::[[Image: 3_CreateNewPlugInProject1CreateNewPlugInProject.jpg JPG| 700px400px]]:Give it a proper name and Choose the target platform to be an OSGI platform::[[Image: 4_CreateNewPlugInProject2CreateNewPlugInProject.jpg | 700px400px]]:Make sure you check off the , so that no Activator class is created in the project (this bundel is just interfaces so it does not run).:[[Image: 5_CreateNewPlugInProject3CreateNewPlugInProject.jpg | 700px400px]]:[[Image: 6_CreateNewClass4CreateNewPlugInProject.jpg | 700px800px]] '''1.2. Create Interfaces'''<br/>Add a package to the src folder in your project.Then Add following items to your package:# A Java class named BusRoute.# A Java class named BusRouteNotFoundException which extends java.lang.Exceptions class.# A Java class named InvalidNumberOfSeatsException which extends java.lang.Exception class.# An Interface named Ticketing :[[Image: 75CreateInterfaces.jpg | 700px800px]] :Enter the code for the classes and the interface as per the following screen-shots::'''BusRout Class:''':[[Image: 8_CreateNewClass6CreateNewClass.jpg | 700px]]:'''BusRoutNotFoundException Class:''':[[Image: 9_CreateNewClass7CreateNewClass.jpg | 700px]]:'''InvalidNumberOfSeatsException Class:''':[[Image: 10_ExceptionClass71CreateNewClass.jpg | 700px]]:'''Ticketing Interface:''':[[Image: 118CreateInterface.jpg | 700px]] '''1.3. Export Package'''<br/>:[[Image: 12_ExportPackageIn order to be able to register our service we need to export our package in the interface bundle. To do so, select MANIFEST.MF in the package explored and then brows to the Runtime tab.Click on "Add" in Exported Packages section.JPG | 700px]] :[[Image: 139ExportPackge.jpg | 700px]] :Select the Ticketing package and press Ok button.:[[Image: 1410ExportPackage.jpg | 700px400px]]:[[Image: 1512ExportPackage.jpg | 700px400px]] :The Interface is Exported and now it'''1.2. Create s time to build the service implementation project where you add all the bundle with implementations of the interface'''and register it at run time.
1
edit

Navigation menu