Class Portal

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--Portal
All Implemented Interfaces:
LocalPortal, java.rmi.Remote, RemotePortal, java.io.Serializable

public final class Portal
extends java.rmi.server.UnicastRemoteObject
implements RemotePortal, LocalPortal

See Also:
Serialized Form

Nested Class Summary
 class Portal.Peer
           
 
Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
Portal(int port, java.lang.String wellKnownPortalAddress)
           
 
Method Summary
 void forward(Message m)
          Forward this message to all of our peers, excluding the peer we received this message from.
 java.lang.String getAddress()
          Gives the RMI address of the portal
 boolean initiatePeering(java.lang.String portalAddress)
          Initiate a peering relationship.
 RemotePeer peerWithMe(java.lang.String portalAddress, RemotePeer other, int maxPeers)
          Initiate a peer relationship, in response to a request
 void shutdown()
          Should call logoff on all of the peers we are connected to
 void somebodyPeerWithMe(java.lang.String portalAddress)
          Create a PeerWithMe message and then process it
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface LocalPortal
addService, getService, println
 

Constructor Detail

Portal

public Portal(int port,
              java.lang.String wellKnownPortalAddress)
       throws java.rmi.RemoteException
Method Detail

getAddress

public java.lang.String getAddress()
Description copied from interface: LocalPortal
Gives the RMI address of the portal

Specified by:
getAddress in interface LocalPortal

peerWithMe

public RemotePeer peerWithMe(java.lang.String portalAddress,
                             RemotePeer other,
                             int maxPeers)
                      throws java.rmi.RemoteException
Description copied from interface: RemotePortal
Initiate a peer relationship, in response to a request

Specified by:
peerWithMe in interface RemotePortal
java.rmi.RemoteException

shutdown

public void shutdown()
Should call logoff on all of the peers we are connected to

Specified by:
shutdown in interface LocalPortal

somebodyPeerWithMe

public void somebodyPeerWithMe(java.lang.String portalAddress)
                        throws java.rmi.RemoteException
Create a PeerWithMe message and then process it

Specified by:
somebodyPeerWithMe in interface RemotePortal
java.rmi.RemoteException

forward

public void forward(Message m)
Forward this message to all of our peers, excluding the peer we received this message from.

Specified by:
forward in interface LocalPortal

initiatePeering

public boolean initiatePeering(java.lang.String portalAddress)
                        throws java.rmi.RemoteException
Initiate a peering relationship. This method can only be invoked locally, and is typically invoked by the process method of a PeerWithMe message. The portal can elect to not initiate a peering relationship if it already have 5 peers. Otherwise, it should perform an rmi lookup of portalAddress to get a remote reference, and invoke the peerWithMe method on that remote reference.

Specified by:
initiatePeering in interface LocalPortal
java.rmi.RemoteException