org.PingOO.DLAI.lib.net
Class UpperProtocol

java.lang.Object
  |
  +--org.PingOO.DLAI.lib.net.UpperProtocol
Direct Known Subclasses:
MasterProtocol

public class UpperProtocol
extends java.lang.Object

The class which describes the upper protocol used by an appli and its driver.
The upper protocol does not interract with the network level.
It's basically just an automaton which desbribs how the connection work.

Since:
PingOO 2.0
Version:
2.0
Author:
Fabrice Bouyé (bouye@cur-archamps.fr)

Field Summary
protected  ConnectionManager connectionManager
          Send datas to the server.
protected  MessageFormatter formatter
          Formats messages in the server's language.
 
Constructor Summary
UpperProtocol(ConnectionManager connectionManager, MessageFormatter formatter)
          Creates a new UpperProtocol instance.
 
Method Summary
 ConnectionManager getConnectionManager()
          Returns le ConnectionManager used by this protocol.
 MessageFormatter getMessageFormatter()
          Returns le MessageFormatter used by this protocol.
protected  MessageHashtable makeByeMessage(java.lang.String slaveName)
          Creates the message sent to the server for closing the connection.
 MessageHashtable request(MessageHashtable message)
          Sends a request to the server and give back the server's answer.
 MessageHashtable request(MessageHashtable message, java.lang.String server)
          Sends a request to the server and give back the server's answer.
 MessageHashtable request(MessageHashtable message, java.lang.String server, java.lang.String port)
          Sends a request to the server and give back the server's answer.
 MessageHashtable requestCrypted(MessageHashtable message)
          Sends a request to the server and give back the server's answer.
 MessageHashtable requestCrypted(MessageHashtable message, java.lang.String server)
          Sends a request to the server and give back the server's answer.
 MessageHashtable requestCrypted(MessageHashtable message, java.lang.String server, java.lang.String port)
          Sends a request to the server and give back the server's answer.
 void terminate(java.lang.String slaveName)
          Disconnect from the server, close the socket and return in initial mode.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

connectionManager

protected ConnectionManager connectionManager
Send datas to the server.

formatter

protected MessageFormatter formatter
Formats messages in the server's language.
Constructor Detail

UpperProtocol

public UpperProtocol(ConnectionManager connectionManager,
                     MessageFormatter formatter)
              throws java.lang.NullPointerException
Creates a new UpperProtocol instance.
The provided ConnectionManager and MessageFormatter allow this object to send correctly formatted datas to the server.
Parameters:
connectionManager - Provides a ConnectionManager to this protocol.
formatter - Provides a MessageFormatter to this protocol.
Throws:
java.lang.NullPointerException - If connectionManager or formatter is null.
Method Detail

request

public MessageHashtable request(MessageHashtable message)
                         throws java.lang.NullPointerException,
                                RequestFailedException,
                                NotConnectedException,
                                ConnectionLostException
Sends a request to the server and give back the server's answer.
This method sends signed but uncrypted datas.
Parameters:
message - The message to send to the server.
Returns:
The request's answer to the request.
Throws:
java.lang.NullPointerException - If message is null.
RequestFailedException - If the UpperProtocol can't get the server's answer.

request

public MessageHashtable request(MessageHashtable message,
                                java.lang.String server)
                         throws java.lang.NullPointerException,
                                RequestFailedException,
                                NotConnectedException,
                                ConnectionLostException
Sends a request to the server and give back the server's answer.
This method sends signed but uncrypted datas.
Parameters:
message - The message to send to the server.
server - The targeted server.
Returns:
The request's answer to the request.
Throws:
java.lang.NullPointerException - If message is null.
RequestFailedException - If the UpperProtocol can't get the server's answer.

request

public MessageHashtable request(MessageHashtable message,
                                java.lang.String server,
                                java.lang.String port)
                         throws java.lang.NullPointerException,
                                RequestFailedException,
                                NotConnectedException,
                                ConnectionLostException
Sends a request to the server and give back the server's answer.
This method sends signed but uncrypted datas.
Parameters:
message - The message to send to the server.
server - The targeted server.
port - The targeted port.
Returns:
The request's answer to the request.
Throws:
java.lang.NullPointerException - If message is null.
RequestFailedException - If the UpperProtocol can't get the server's answer.

requestCrypted

public MessageHashtable requestCrypted(MessageHashtable message)
                                throws java.lang.NullPointerException,
                                       RequestFailedException,
                                       NotConnectedException,
                                       ConnectionLostException
Sends a request to the server and give back the server's answer.
This method sends signed and crypted datas.
Parameters:
message - The message to send to the server.
Returns:
The request's answer.
Throws:
java.lang.NullPointerException - If message is null.
RequestFailedException - If the UpperProtocol can't get the server's answer.

requestCrypted

public MessageHashtable requestCrypted(MessageHashtable message,
                                       java.lang.String server)
                                throws java.lang.NullPointerException,
                                       RequestFailedException,
                                       NotConnectedException,
                                       ConnectionLostException
Sends a request to the server and give back the server's answer.
This method sends signed and crypted datas.
Parameters:
message - The message to send to the server.
server - The targeted server.
Returns:
The request's answer.
Throws:
java.lang.NullPointerException - If message is null.
RequestFailedException - If the UpperProtocol can't get the server's answer.

requestCrypted

public MessageHashtable requestCrypted(MessageHashtable message,
                                       java.lang.String server,
                                       java.lang.String port)
                                throws java.lang.NullPointerException,
                                       RequestFailedException,
                                       NotConnectedException,
                                       ConnectionLostException
Sends a request to the server and give back the server's answer.
This method sends signed and crypted datas.
Parameters:
message - The message to send to the server.
server - The targeted server.
port - The targeted port.
Returns:
The request's answer.
Throws:
java.lang.NullPointerException - If message is null.
RequestFailedException - If the UpperProtocol can't get the server's answer.

getConnectionManager

public final ConnectionManager getConnectionManager()
Returns le ConnectionManager used by this protocol.
Returns:
The ConnectionManager used by this protocol.

getMessageFormatter

public final MessageFormatter getMessageFormatter()
Returns le MessageFormatter used by this protocol.
Returns:
The MessageFormatter used by this protocol.

terminate

public void terminate(java.lang.String slaveName)
Disconnect from the server, close the socket and return in initial mode.

makeByeMessage

protected MessageHashtable makeByeMessage(java.lang.String slaveName)
Creates the message sent to the server for closing the connection.
Returns:
A MessageHashtable which is the message from the kernel module.