org.caleigo.service
Class ServiceProvider

java.lang.Object
  extended byorg.caleigo.service.ServiceProvider

public class ServiceProvider
extends java.lang.Object

ServiceProvider is a singleton class that provides a single point of access for IServices. Local services are added to the ServiceProvider by using the addService method. The addTunnel method is used to add connections to remote ServiceProviderServers that are used to connect to remote services.

Version:
1.00
Author:
Mattias Hagstrand

Nested Class Summary
protected static class ServiceProvider.GetServiceMessage
           
static interface ServiceProvider.IServiceProviderMessage
           
 
Field Summary
protected  java.util.Hashtable mProxyHandlers
           
protected  java.util.List mServices
           
protected  java.util.List mTunnels
           
protected static ServiceProvider sInstance
           
 
Constructor Summary
protected ServiceProvider()
           
 
Method Summary
 void addService(IService service)
          Adds a local service to this ServiceProvider.
 void addTunnel(ITunnel tunnel)
          Adds a tunnel that can be used by this ServiceProvider to access remote service providers.
static ServiceProvider getInstance()
           
 IService getService(java.lang.Class serviceInterfaceClass, java.lang.Object serviceType, java.lang.Object serviceIdentity)
          Returns a service that is identified by the provided parameters, or null if no service was found.
 void removeService(IService service)
          Removes a local service from this ServiceProvider.
 void removeTunnel(ITunnel tunnel)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sInstance

protected static ServiceProvider sInstance

mServices

protected java.util.List mServices

mTunnels

protected java.util.List mTunnels

mProxyHandlers

protected java.util.Hashtable mProxyHandlers
Constructor Detail

ServiceProvider

protected ServiceProvider()
Method Detail

getInstance

public static ServiceProvider getInstance()

addService

public void addService(IService service)
Adds a local service to this ServiceProvider.


removeService

public void removeService(IService service)
Removes a local service from this ServiceProvider.


addTunnel

public void addTunnel(ITunnel tunnel)
Adds a tunnel that can be used by this ServiceProvider to access remote service providers.


removeTunnel

public void removeTunnel(ITunnel tunnel)

getService

public IService getService(java.lang.Class serviceInterfaceClass,
                           java.lang.Object serviceType,
                           java.lang.Object serviceIdentity)
Returns a service that is identified by the provided parameters, or null if no service was found. First the ServiceProvider tries to find a local service. If that fails it tries to locate a remote service by sending out a request for the service on the tunnels. The request is sent to the tunnels in the order that they were added.

Parameters:
serviceInterfaceClass - the interface class of the service
serviceType - the type of the service.
serviceIdentity - the identity of the service.
Returns:
the requested service if found, otherwise null.


Copyright © 2005 Caleigo. All Rights Reserved.