Skip to main content
Jump to: navigation, search

Difference between revisions of "Tutorial: Building your first OSGi Remote Service"

(Created page with "==Introduction== The OSGi specification defines a very simple model to expose Services within a local runtime. With recent versions of the Enterprise Specification, a distri...")
 
(Define a Service Interface)
Line 12: Line 12:
  
 
<source lang="java">
 
<source lang="java">
/**
 
* Example OSGi service for retrieving current time in milliseconds from January
 
* 1, 1970.
 
*
 
*/
 
 
public interface ITimeService {
 
public interface ITimeService {
 
/**
 
* Get current time.
 
*
 
* @return Long current time in milliseconds since Jan 1, 1970. Will not
 
*        return <code>null</code>.
 
*/
 
 
public Long getCurrentTime();
 
public Long getCurrentTime();
  
 
}
 
}
 
</source>
 
</source>

Revision as of 21:16, 5 December 2013

Introduction

The OSGi specification defines a very simple model to expose Services within a local runtime. With recent versions of the Enterprise Specification, a distribution provider may be used to export Services and make them available for remote access. ECF provides an implementation of this Remote Services specification.

This tutorial will show how to define a simple OSGi service and expose that service for remote access via ECF's implementation of the OSGi Remote Services standard.

Define a Service Interface

The key to building a system with low coupling and high cohesion is to define clear and coherent boundaries between different parts of your system. Central to this is defining a simple Service Interface...to allow one subsystem to interact with another subsystem, but only in clearly defined ways.

For this example, we are going to define a simple Time Service. This service will initially allow clients to get the current time:

public interface ITimeService {
	public Long getCurrentTime();
 
}

Back to the top