Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.fetish.toolkit
Class FetishImpl  view FetishImpl download FetishImpl.java

java.lang.Object
  extended bycom.fetish.toolkit.FetishImpl

public class FetishImpl
extends java.lang.Object

The Fetish Toolkit helper class. This class provides with methods that allow an easy use of the Fetish features, such as registering and deregistering a service and lookup of Fetish services by ServiceID, attributes and/or interface/s implemented.


Nested Class Summary
private  class FetishImpl.RegistrationItem
           
 
Field Summary
private  FetishLeaseRenewalManager lrm
           
private  java.util.Hashtable registry
           
 
Constructor Summary
FetishImpl()
          Simple constructor.
 
Method Summary
static boolean connect(java.lang.String url1, java.lang.String url2)
          Makes a logical connection between any two FADA nodes.
private static com.fetish.directory.Directory getDirectory(java.lang.String url)
          Obtains a reference to the Fada node given its url.
 Lease getFetishLease(ServiceID sid)
          Obtains the Jini Lease of the service identified by sid.
private  FetishLeaseRenewalManager getLrm()
          Obtains the FetishLeaseRenewalManager for the current toolkit class.
private static com.fetish.directory.LUSManager getLUSManager(java.lang.String url)
          Obtains a reference to the Fada node given its url.
private  java.util.Hashtable getRegistry()
          Gets the Fetish Toolkit registry of ServiceIDs and leases.
static ServiceID getSID(ServiceRegistration sr)
          Obtains the Jini ServiceID for a registered service.
static java.lang.Object[] lookup(java.lang.String url, java.lang.Class service, Entry[] entries, ServiceID sid)
          Returns an array with the service proxies that match the search criteria.
private static long parseChar(char c)
           
static ServiceID parseSid(java.lang.String sid)
          Converts a string representing a ServiceID into an instance of ServiceID.
 ServiceID register(java.lang.String url, ServiceID sid, java.lang.Object service, Entry[] entries)
          Registers a service in the FADA architecture.
 void reregister(ServiceID sid)
          Registers a service whose lease has expired.
 boolean unregister(java.lang.String url, ServiceID sid)
          Deletes the service identified by the ServiceID sid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

registry

private java.util.Hashtable registry

lrm

private FetishLeaseRenewalManager lrm
Constructor Detail

FetishImpl

public FetishImpl()
Simple constructor. Sets up the internal registry and the lease renewal manager.

Method Detail

getLrm

private FetishLeaseRenewalManager getLrm()
Obtains the FetishLeaseRenewalManager for the current toolkit class. The FetishLeaseRenewalManager is a class that allows renewing of Fetish leases, a feature that gives Fetish the power of being self-healing.

A class on the service side must renew the lease for the registered service. If the lease expires the service will be removed from the Fetish registry.

If a service crashes it will eventually fail to renew the lease; when it expires the service will be removed, so nobody can retrieve a reference to it. One or more listeners can be set to listen for lease expiration events, so when a service crashes and fails to renew its lease the listener can trigger the suitable mechanisms to solve the situation (for example, reload the service with the same ServiceID, notify the administrator, etc.)


getRegistry

private java.util.Hashtable getRegistry()
Gets the Fetish Toolkit registry of ServiceIDs and leases. The Fetish Toolkit registry holds the leases for all services registered using this instance of the toolkit.
Such leases must be in the same JVM the service executes in, so if the whole JVM crashes the leases will eventually expire.


getLUSManager

private static com.fetish.directory.LUSManager getLUSManager(java.lang.String url)
                                                      throws java.rmi.RemoteException
Obtains a reference to the Fada node given its url. This reference can the be used to cancel a lease, thus deleting the service it belongs to.


getDirectory

private static com.fetish.directory.Directory getDirectory(java.lang.String url)
                                                    throws java.rmi.RemoteException
Obtains a reference to the Fada node given its url. This reference can the be used to cancel a lease, thus deleting the service it belongs to.


register

public ServiceID register(java.lang.String url,
                          ServiceID sid,
                          java.lang.Object service,
                          Entry[] entries)
                   throws java.rmi.RemoteException
Registers a service in the FADA architecture. This method registers the service as a Jini service in the LUS the FADA node is registered into, and keeps the Jini lease in the registry for renewal or user retrieval.


reregister

public void reregister(ServiceID sid)
                throws java.rmi.RemoteException
Registers a service whose lease has expired.
This method is provided in case the lease object can't be renewed in time. The main cause for this situation is that network delay has suddenly become very long, and the Kalman filter hasn't been able to estimate this very low probable situation. The reregister method will register the service again, keeping all data as if has never been deregistered.


unregister

public boolean unregister(java.lang.String url,
                          ServiceID sid)
                   throws java.rmi.RemoteException
Deletes the service identified by the ServiceID sid. This method cancels the Jini lease for the service identified by the ServiceID sid, thus deleting its entry in the Jini registry. It also deletes the entry in the Fetish registry.


lookup

public static java.lang.Object[] lookup(java.lang.String url,
                                        java.lang.Class service,
                                        Entry[] entries,
                                        ServiceID sid)
                                 throws java.rmi.RemoteException
Returns an array with the service proxies that match the search criteria. The FADA node will return an array with all services that match the search criteria. A service matches the criteria if:
  • It implements the interface service and
  • It has at least one matching entry for all specified entries and
  • Its service id matches sid
Any of the above search criteria may be null, meaning match all (serves as a wildcard).


connect

public static boolean connect(java.lang.String url1,
                              java.lang.String url2)
                       throws java.rmi.RemoteException
Makes a logical connection between any two FADA nodes. Lookup processes will span through all the graph of FADA nodes. This method provides with a mechanism to connect FADA nodes to create a graph.
After execution of this method, all searches started from this node will also search the rest of the graph, and all services registered into this node will be accessible from any point in the graph.


getFetishLease

public Lease getFetishLease(ServiceID sid)
                     throws java.rmi.RemoteException
Obtains the Jini Lease of the service identified by sid. This Lease can then be administered by some other party, or be cancelled. Warning: cancelling a lease obtained by this method removes the service the lease belongs to from the Jini registry, but NOT from the Fetish registry. This practice is dangerous and therefore discouraged.


getSID

public static ServiceID getSID(ServiceRegistration sr)
Obtains the Jini ServiceID for a registered service. This ServiceID should be stored by the service for future registrations, in order to maintain a consistency.


parseChar

private static long parseChar(char c)

parseSid

public static ServiceID parseSid(java.lang.String sid)
Converts a string representing a ServiceID into an instance of ServiceID.
Takes a string representing a valid ServiceID and constructs a ServiceID instance with it. It won't check the string is a real ServiceID, so errors may occur.