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

Quick Search    Search Deep

com.fetish.directory
Class FadaProxy  view FadaProxy download FadaProxy.java

java.lang.Object
  extended bycom.fetish.directory.FadaProxy
All Implemented Interfaces:
Directory, FadaInterface, LUSManager, java.rmi.Remote, java.io.Serializable

public class FadaProxy
extends java.lang.Object
implements java.io.Serializable, FadaInterface, LUSManager, Directory

The proxy class for the FADA node.


Field Summary
(package private)  Directory dir
           
(package private)  ServiceID id
           
(package private)  LUSManager lusm
           
(package private)  java.rmi.Remote ref
           
(package private)  java.lang.String url
           
 
Constructor Summary
FadaProxy()
           
FadaProxy(java.rmi.Remote ref, java.lang.String url)
           
 
Method Summary
 void addLookupResult(SearchIDInterface id, ServiceMatches sm)
          Adds results obtained from a remote FADA.
 boolean connect(LUSManager node)
          Add a new neighbor to the node.
 boolean disconnect(LUSManager node)
          Remove a neighbor from the list of neighbors.
 boolean disconnect(java.lang.String node)
          Remove a neighbor from the list of neighbors.
 LookupLocator getLocator()
          Get the Jini LookupLocator.
 int getMaxTime()
          Get the maximum time allowed for lookups in milliseconds
 LUSManager[] getNeighbors()
          Get the neighbors of the node
 ServiceID getServiceID()
          Get the LUSManager identifier.
 ServiceMatches getServices()
          Returns all services registered in this node.
 java.lang.String getUrl()
          Get the URL from this node.
 boolean isAlone()
          Check if the node is alone in the FADA architecture.
 void isolate()
          Isolate the node from the rest of the directory.
 boolean justConnect(LUSManager node)
          Add a new neighbor to the node.
 boolean justDisconnect(LUSManager node)
          Remove a neighbor from the list of neighbors.
 boolean justDisconnect(java.lang.String node)
          Remove a neighbor from the list of neighbors.
 ServiceMatches lookup(SearchCriteriaInterface criteria, int nHops, long timeout, int maxResponses)
          Returns at most maxMatches items matching the template, plus the total number of items that match the template.
 boolean lookup(SearchCriteriaInterface criteria, SearchIDInterface searchID, java.lang.String target, java.lang.String excluded, int nHops, long timeout, int maxResponses)
          Extends the lookup process to all nodes connected to one (except that from which the lookup request came from).
 EventRegistration notify(ServiceTemplate tmpl, int transitions, RemoteEventListener listener, java.rmi.MarshalledObject handback, long leaseDuration)
           
private  void readObject(java.io.ObjectInputStream i)
           
 ServiceRegistration register(ServiceItem item, long leaseDuration)
           Register a new service or re-register an existing service.
 void setLease(Lease lease)
           
 void setMaxTime(int maxTime)
          Set the maximum time allowed for lookups in milliseconds
 void setRegistrar(java.lang.String registrar)
           
 void setServiceID(ServiceID id)
           
 void startedSearches(SearchIDInterface id, int numSearches)
          Increases the number of started searches.
 void stop(java.lang.String passwd)
          Stop and deregister the node as a Jini service.
 void unregister(ServiceID sid)
          Deletes a registration from the node.
private  void writeObject(java.io.ObjectOutputStream o)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ref

java.rmi.Remote ref

url

java.lang.String url

id

transient ServiceID id

dir

transient Directory dir

lusm

transient LUSManager lusm
Constructor Detail

FadaProxy

public FadaProxy()

FadaProxy

public FadaProxy(java.rmi.Remote ref,
                 java.lang.String url)
          throws java.rmi.RemoteException
Method Detail

writeObject

private void writeObject(java.io.ObjectOutputStream o)
                  throws java.io.IOException

readObject

private void readObject(java.io.ObjectInputStream i)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException

lookup

public ServiceMatches lookup(SearchCriteriaInterface criteria,
                             int nHops,
                             long timeout,
                             int maxResponses)
                      throws java.rmi.RemoteException
Description copied from interface: Directory
Returns at most maxMatches items matching the template, plus the total number of items that match the template. The return value is never null, and the returned items array is only null if maxMatches is zero. For each returned item, if the service object cannot be deserialized, the service field of the item is set to null and no exception is thrown. Similarly, if an attribute set cannot be deserialized, that element of the attributeSets array is set to null and no exception is thrown.

Specified by:
lookup in interface Directory

getServices

public ServiceMatches getServices()
                           throws java.rmi.RemoteException
Returns all services registered in this node.

Specified by:
getServices in interface Directory

getUrl

public java.lang.String getUrl()
                        throws java.rmi.RemoteException
Description copied from interface: LUSManager
Get the URL from this node.
Returns the Jini URL for this node, in the form jini://<ip/hostname>:<port>

Specified by:
getUrl in interface LUSManager

lookup

public boolean lookup(SearchCriteriaInterface criteria,
                      SearchIDInterface searchID,
                      java.lang.String target,
                      java.lang.String excluded,
                      int nHops,
                      long timeout,
                      int maxResponses)
               throws java.rmi.RemoteException
Description copied from interface: Directory
Extends the lookup process to all nodes connected to one (except that from which the lookup request came from). Takes account of the search id, to avoid cycles. If the search request has an id that is already in the list of search ids, the request is rejected, and the call returns inmediately.

Specified by:
lookup in interface Directory

addLookupResult

public void addLookupResult(SearchIDInterface id,
                            ServiceMatches sm)
                     throws java.rmi.RemoteException
Description copied from interface: Directory
Adds results obtained from a remote FADA. This method is called from a FADA node that wants to return the results of a local search to a FADA node that has asked for them.

Specified by:
addLookupResult in interface Directory

startedSearches

public void startedSearches(SearchIDInterface id,
                            int numSearches)
                     throws java.rmi.RemoteException
Description copied from interface: Directory
Increases the number of started searches. Adds numSearches to the number of searches to expect results from. THIS METHOD IS ACTUALLY NOT BEING USED

Specified by:
startedSearches in interface Directory

register

public ServiceRegistration register(ServiceItem item,
                                    long leaseDuration)
                             throws java.rmi.RemoteException
Description copied from interface: Directory
Register a new service or re-register an existing service. The method is defined so that it can be used in an idempotent fashion. Specifically, if a call to register results in a RemoteException (in which case the item might or might not have been registered), the caller can simply repeat the call to register with the same parameters, until it succeeds.

To register a new service, item.serviceID should be null. In that case, if item.service does not equal (using MarshalledObject.equals) any existing item's service object, then a new service ID will be assigned and included in the returned ServiceRegistration. The service ID is unique over time and space with respect to all other service IDs generated by all lookup services. If item.service does equal an existing item's service object, the existing item is first deleted from the lookup service (even if it has different attributes) and its lease is cancelled, but that item's service ID is reused for the newly registered item.

To re-register an existing service, or to register the service in any other lookup service, item.serviceID should be set to the same service ID that was returned by the initial registration. If an item is already registered under the same service ID, the existing item is first deleted (even if it has different attributes or a different service instance) and its lease is cancelled. Note that service object equality is not checked in this case, to allow for reasonable evolution of the service (e.g., the serialized form of the stub changes, or the service implements a new interface).

Any duplicate attribute sets included in a service item are eliminated in the stored representation of the item. The lease duration request is not exact; the returned lease is allowed to have a shorter (but not longer) duration than what was requested.

Specified by:
register in interface Directory

unregister

public void unregister(ServiceID sid)
                throws java.rmi.RemoteException
Description copied from interface: Directory
Deletes a registration from the node.

Specified by:
unregister in interface Directory

notify

public EventRegistration notify(ServiceTemplate tmpl,
                                int transitions,
                                RemoteEventListener listener,
                                java.rmi.MarshalledObject handback,
                                long leaseDuration)
                         throws java.rmi.RemoteException

setMaxTime

public void setMaxTime(int maxTime)
                throws java.rmi.RemoteException
Description copied from interface: LUSManager
Set the maximum time allowed for lookups in milliseconds

Specified by:
setMaxTime in interface LUSManager

getMaxTime

public int getMaxTime()
               throws java.rmi.RemoteException
Description copied from interface: LUSManager
Get the maximum time allowed for lookups in milliseconds

Specified by:
getMaxTime in interface LUSManager

getServiceID

public ServiceID getServiceID()
                       throws java.rmi.RemoteException
Description copied from interface: LUSManager
Get the LUSManager identifier.
This identifier is provided by Jini when the LUSManager is registered as a Jini service.

Specified by:
getServiceID in interface LUSManager

getLocator

public LookupLocator getLocator()
                         throws java.rmi.RemoteException
Description copied from interface: LUSManager
Get the Jini LookupLocator.
Obtains a reference to the class that performs Unicast discovery.

Specified by:
getLocator in interface LUSManager

isolate

public void isolate()
             throws java.rmi.RemoteException
Description copied from interface: LUSManager
Isolate the node from the rest of the directory.

Specified by:
isolate in interface LUSManager

isAlone

public boolean isAlone()
                throws java.rmi.RemoteException
Description copied from interface: LUSManager
Check if the node is alone in the FADA architecture.

Specified by:
isAlone in interface LUSManager

connect

public boolean connect(LUSManager node)
                throws java.rmi.RemoteException
Description copied from interface: LUSManager
Add a new neighbor to the node. This method calls the method connect on the node to obtain a bidirectional connection.

Specified by:
connect in interface LUSManager

justConnect

public boolean justConnect(LUSManager node)
                    throws java.rmi.RemoteException
Description copied from interface: LUSManager
Add a new neighbor to the node. Adds the specified node to the list of neighbors, after checking if it's reachable.
This method does NOT call the node to perform a bidirectional connection. It is intended to be called by the method connect() on the remote node.

Specified by:
justConnect in interface LUSManager

disconnect

public boolean disconnect(LUSManager node)
                   throws java.rmi.RemoteException
Description copied from interface: LUSManager
Remove a neighbor from the list of neighbors. It also removes the reference on neighbor node to this node

Specified by:
disconnect in interface LUSManager

justDisconnect

public boolean justDisconnect(LUSManager node)
                       throws java.rmi.RemoteException
Description copied from interface: LUSManager
Remove a neighbor from the list of neighbors.

Specified by:
justDisconnect in interface LUSManager

disconnect

public boolean disconnect(java.lang.String node)
                   throws java.rmi.RemoteException
Description copied from interface: LUSManager
Remove a neighbor from the list of neighbors. It also removes the reference on neighbor node to this node

Specified by:
disconnect in interface LUSManager

justDisconnect

public boolean justDisconnect(java.lang.String node)
                       throws java.rmi.RemoteException
Description copied from interface: LUSManager
Remove a neighbor from the list of neighbors.

Specified by:
justDisconnect in interface LUSManager

getNeighbors

public LUSManager[] getNeighbors()
                          throws java.rmi.RemoteException
Description copied from interface: LUSManager
Get the neighbors of the node

Specified by:
getNeighbors in interface LUSManager

setLease

public void setLease(Lease lease)
              throws java.rmi.RemoteException
Specified by:
setLease in interface FadaInterface

setServiceID

public void setServiceID(ServiceID id)
                  throws java.rmi.RemoteException
Specified by:
setServiceID in interface FadaInterface

setRegistrar

public void setRegistrar(java.lang.String registrar)
                  throws java.rmi.RemoteException
Specified by:
setRegistrar in interface FadaInterface

stop

public void stop(java.lang.String passwd)
Description copied from interface: LUSManager
Stop and deregister the node as a Jini service.
It first deletes all service registrations by cancelling their leases and destroying the structure that holds them. Then it cancels the Jini lease for this FADA.

Specified by:
stop in interface LUSManager