messageServerP
Class SafeMSForMSInterface

java.lang.Object
  extended by messageServerP.SafeMSForMSInterface
All Implemented Interfaces:
MSForMSInterface, java.rmi.Remote

public class SafeMSForMSInterface
extends java.lang.Object
implements MSForMSInterface

A Safe Message server to Message server interface. Normally, when a Message Server losts its RMI reference to another Message Server, for example for a MS shutdown, any call to the message server interface throws a RemoteException, even if the server got back on-line. Using this class, any method calls the interface method, but when the interface is down, it tries to bring it up once again.

Author:
Marco Cornolti

Field Summary
(package private)  MSForMSInterface interf
           
private  java.net.InetAddress ip
           
private  int port
           
 
Constructor Summary
SafeMSForMSInterface(java.net.InetAddress ip, int port)
          Safe MS for MS Interface constructor.
 
Method Summary
 void assignMovedUser(ManagedUser user)
          Assigns a user management (sending all its datas) to the message server.
 void forwardMessage(Message msg)
          Forwards a message from a Message Server to this one.
 User getManagedUserContact(User user)
          Gets a User IP address and TCP port to directely connect to its servlet.
 boolean inListOfUserContains(User listUser, User user)
          Checks whether or not a user (U1) accepts messages sent from another user (U2)
private  void refreshInterface()
          Refreshes the interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ip

private java.net.InetAddress ip

port

private int port

interf

MSForMSInterface interf
Constructor Detail

SafeMSForMSInterface

public SafeMSForMSInterface(java.net.InetAddress ip,
                            int port)
                     throws java.rmi.RemoteException
Safe MS for MS Interface constructor.

Parameters:
ip - the MS ip address.
port - the MS port.
Throws:
java.rmi.RemoteException
Method Detail

assignMovedUser

public void assignMovedUser(ManagedUser user)
                     throws java.rmi.RemoteException,
                            AssignationNotAcceptedException
Description copied from interface: MSForMSInterface
Assigns a user management (sending all its datas) to the message server.

Specified by:
assignMovedUser in interface MSForMSInterface
Parameters:
user - the user to assign.
Throws:
java.rmi.RemoteException - if a communication problem occurred.
AssignationNotAcceptedException - if the assignation was not accepted.

forwardMessage

public void forwardMessage(Message msg)
                    throws java.rmi.RemoteException,
                           NotAllowedException,
                           UserNotManagedException,
                           GenericErrorException,
                           UserNotExistsException,
                           SystemErrorException
Description copied from interface: MSForMSInterface
Forwards a message from a Message Server to this one.

Specified by:
forwardMessage in interface MSForMSInterface
Parameters:
msg - the message to forward.
Throws:
java.rmi.RemoteException - if a communication problem occurs.
NotAllowedException - if the recipint does not accept messages from the sender.
UserNotManagedException - id the recipient user is not assigned to this MS.
GenericErrorException - if a generic error occurred.
UserNotExistsException - if the user does not exist in the whole system.
SystemErrorException - if a system error occurred.

getManagedUserContact

public User getManagedUserContact(User user)
                           throws java.rmi.RemoteException,
                                  UserNotManagedException
Description copied from interface: MSForMSInterface
Gets a User IP address and TCP port to directely connect to its servlet. The User is managed by this MS.

Specified by:
getManagedUserContact in interface MSForMSInterface
Parameters:
user - the user whose connection datas is wanted. Only the nickname is considered.
Returns:
the user with the correctly obtained IP address and TCP port.
Throws:
java.rmi.RemoteException - if a communication problem occurs.
UserNotManagedException - if the user is not locally managed.

inListOfUserContains

public boolean inListOfUserContains(User listUser,
                                    User user)
                             throws java.rmi.RemoteException,
                                    UserNotManagedException
Description copied from interface: MSForMSInterface
Checks whether or not a user (U1) accepts messages sent from another user (U2)

Specified by:
inListOfUserContains in interface MSForMSInterface
Parameters:
listUser - the receiver user (U1)
user - the sender user (U2)
Returns:
true if, and only if, listUser (U1) accepts messages from user (U2).
Throws:
java.rmi.RemoteException - if a communication problem occurred.
UserNotManagedException - if the listUser (U1) is not managed by the server.

refreshInterface

private void refreshInterface()
                       throws java.rmi.RemoteException
Refreshes the interface.

Throws:
java.rmi.RemoteException - if the interface could not be refreshed.