There is a public GIT, with all of the application work available for cloning at: git://github.com/GUSCRAWFORD/ECL-Assignment1.git
Our sample project is to create a declarative service with Java, and have a client-end 'Hotel Room Booking Software' use these services.
Resources
EclipseZoneThis guy never actually finished his tutorial, still some interesting setup there and comments. [http://www.eclipsezone.com/eclipse/forums/t96740.html]
An article on declarative services.- A blog by Lars Vogel [http://www.vogella.de/articles/OSGi/article.html]
A more complete overview and explanation of OSGi and DS.
Setting Up
For my purposes, I've chosen Eclipse to perform my work with. Eclipse itself is based on OSGi, and I'm also using Equinox OSGi implementation.
To get started, we're going to create a new bundle in Eclipse.
This bundle is going to get defined as a service in XML. The service in this case offers the capability to book a hotel room on a central computer.
Defining Hotel Service
The first thing I'm doing is creating a class and implementing java.lang.Runnable.
This runnable class is my service as I understand it. It should get defined as a service. Business logic and centralized transactions happen in here. So we've got a source file HotelService.java in a package org.ecl_assignment1.ds that looks like this;
Observe HotelService.xml in project-root/META-INF
This bundle is going to get defined as a service in XML. The service in this case offers the capability to book a hotel room on a central computer.
Defining Hotel Service
The first thing I'm doing is creating a class and implementing java.lang.Runnable.
// HotelService.java
package org.ecl_assignment1.ds;
public class HotelService implements java.lang.Runnable {
@Override
public void run() {
// TODO : SOME WORK
}
}
The next step is declaring my service which I do within an xml. The tutorial I'm initially going by says to create a folder OSGI-INF in the project root; to create a *.xml file there with a filename matching that of the class-service I'm declaring. I'm going to use the already created META-INF folder for the time being.package org.ecl_assignment1.ds;
public class HotelService implements java.lang.Runnable {
@Override
public void run() {
// TODO : SOME WORK
}
}
Observe HotelService.xml in project-root/META-INF
<?xml version="1.0" ?>
<component name="hotelservice">
<implementation class="org.ecl_assignment1.ds" />
<service>
<provide interface="java.lang.Runnable" />
</service>
</component>
<component name="hotelservice">
<implementation class="org.ecl_assignment1.ds" />
<service>
<provide interface="java.lang.Runnable" />
</service>
</component>
No comments:
Post a Comment