server
Class Server

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by server.Server
All Implemented Interfaces:
Client2Server, Computer2Server, java.io.Serializable, java.rmi.Remote

public class Server
extends java.rmi.server.UnicastRemoteObject
implements Client2Server, Computer2Server

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Fields inherited from interface api.Client2Server
NAME
 
Fields inherited from interface api.Computer2Server
NAME
 
Constructor Summary
Server(boolean animate)
           
 
Method Summary
 LoginContainer login(Server2Computer computer)
          Logs a computer in to a server.
static void main(java.lang.String[] args)
           
 void putResult(Server2Computer computer, Result result)
          puts a result on the server
 void putTask(Task task)
          Remote method for submitting a task to the server.
 void registerListener(RemoteListener remoteListener)
          Registers an event listener on a server
 void startThreads()
           
 void stop()
          Stops the server and all of its connected computers.
 java.lang.Object takeResult()
          Gets a result from the server.
 Task takeTask(Server2Computer computer)
          Blocking call to take a task from the server
 Task[] takeTasks(Server2Computer computer, int count)
          Non-blocking request for multiple tasks
 void updateShared(Server2Computer computer, Shared shared)
          send a shared update to the server
 
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
 

Constructor Detail

Server

public Server(boolean animate)
       throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException
Method Detail

stop

public void stop()
          throws java.rmi.RemoteException
Description copied from interface: Client2Server
Stops the server and all of its connected computers.

Specified by:
stop in interface Client2Server
Throws:
java.rmi.RemoteException - RMI Exception

startThreads

public void startThreads()

login

public LoginContainer login(Server2Computer computer)
                     throws java.rmi.RemoteException
Description copied from interface: Computer2Server
Logs a computer in to a server.

Specified by:
login in interface Computer2Server
Parameters:
computer - A reference to the remote computer object that is logging in. This allows the server to make calls to the computer.
Returns:
a container with some initial values for the compuer
Throws:
java.rmi.RemoteException - RMI Exception

putResult

public void putResult(Server2Computer computer,
                      Result result)
               throws java.rmi.RemoteException
Description copied from interface: Computer2Server
puts a result on the server

Specified by:
putResult in interface Computer2Server
Parameters:
computer - the computer issuing the result
result - the result object
Throws:
java.rmi.RemoteException - RMI Exception

putTask

public void putTask(Task task)
             throws java.rmi.RemoteException
Description copied from interface: Client2Server
Remote method for submitting a task to the server.

Specified by:
putTask in interface Client2Server
Parameters:
task - The task to be executed on a client's behalf
Throws:
java.rmi.RemoteException - RMI exception

registerListener

public void registerListener(RemoteListener remoteListener)
                      throws java.rmi.RemoteException
Description copied from interface: Client2Server
Registers an event listener on a server

Specified by:
registerListener in interface Client2Server
Parameters:
remoteListener - the listener to register
Throws:
java.rmi.RemoteException - RMI Exception

takeResult

public java.lang.Object takeResult()
                            throws java.rmi.RemoteException
Description copied from interface: Client2Server
Gets a result from the server. This remote method will block until a result is available.

Specified by:
takeResult in interface Client2Server
Returns:
The result
Throws:
java.rmi.RemoteException - RMI exception

takeTask

public Task takeTask(Server2Computer computer)
              throws java.rmi.RemoteException
Description copied from interface: Computer2Server
Blocking call to take a task from the server

Specified by:
takeTask in interface Computer2Server
Parameters:
computer - the computer requesting the task
Returns:
a new task for the computer to execute
Throws:
java.rmi.RemoteException - RMI Exception

takeTasks

public Task[] takeTasks(Server2Computer computer,
                        int count)
                 throws java.rmi.RemoteException
Description copied from interface: Computer2Server
Non-blocking request for multiple tasks

Specified by:
takeTasks in interface Computer2Server
Parameters:
computer - The requesting computer
count - The number of desired tasks
Returns:
an array of tasks of some length between 0 and count
Throws:
java.rmi.RemoteException - RMI Exception

updateShared

public void updateShared(Server2Computer computer,
                         Shared shared)
                  throws java.rmi.RemoteException
Description copied from interface: Computer2Server
send a shared update to the server

Specified by:
updateShared in interface Computer2Server
Parameters:
computer - the computer issuing the update
shared - the new shared object
Throws:
java.rmi.RemoteException - RMI Exception

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception