br.shob.server
Class Server

java.lang.Object
  |
  +--br.shob.server.Server

public class Server
extends Object

This class represents a global space.

Author:
crolmos, dukejeffrie
Created:
September 1, 2002

Field Summary
static String configurationFile
          Description of the Field
 
Constructor Summary
Server(String hostname, int plainPort, int signedPort)
          Creates new Server
 
Method Summary
protected  TimeStamp beginTrans(URL client, String globalName)
          Begins a transaction on a shared object.
protected  TimeStamp commit(URL client, String globalName)
          Description of the Method
protected  KeyPair generateKeyPair()
          Description of the Method
 Set getClients()
          This method returns a set with the clients logged in.
 ServerCommLayer getCommLayer()
          Gets the commLayer attribute of the Server object
 HostId getHostId()
          Gets the hostId attribute of the Server object
 HostId getHostId(URL clientURL)
          Gets the hostId attribute of the Server object
 List getObjects()
          This method returns a list of all the objects shared in this global space.
 Set getOwners()
          Gets a Set with all clients who shared at least one object.
 URL getPlainSocketURL()
          Gets the plainSocketURL attribute of the Server object
 PrivateKey getPrivateKey()
          Gets the privateKey attribute of the Server object
 Set getWriters()
          Gets a set of all the clients who currently have at least one lock
 boolean isDebugging()
          Gets the debugging attribute of the Server object
protected  boolean login(HostId client)
          Description of the Method
protected  boolean logout(URL client)
          Performs a client's logout.
static void main(String[] args)
          For testing
protected  boolean ping(URL client)
          Description of the Method
protected  HostId request(String globalName)
          Description of the Method
protected  void rollback(URL client, String globalName)
          Description of the Method
 void setDebugging(boolean flag)
          Sets the debugging attribute of the Server object
 void setPlainSocketURL(URL plainSocketURL)
          This method should not be called.
protected  TimeStamp share(URL client, String globalName, boolean lockable)
          Description of the Method
protected  void unlock(URL client, String globalName, TimeStamp stamp)
          Description of the Method
protected  void unshare(URL client, String globalName)
          Description of the Method
protected  HostId validate(String globalName, TimeStamp stamp)
          Description of the Method
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

configurationFile

public static String configurationFile
Description of the Field

Constructor Detail

Server

public Server(String hostname,
              int plainPort,
              int signedPort)
       throws CommLayerException,
              InsecureObjectException
Creates new Server

Parameters:
hostname - the host where this server will be listening.
plainPort - the port in wich this server will be listening for logins.
signedPort - the port in wich this server will be listening for other operations.
Throws:
CommLayerException - Description of the Exception
InsecureObjectException - Description of the Exception
Method Detail

getClients

public Set getClients()
This method returns a set with the clients logged in.

Returns:
The clients value

getCommLayer

public ServerCommLayer getCommLayer()
Gets the commLayer attribute of the Server object

Returns:
The commLayer value

getHostId

public HostId getHostId()
Gets the hostId attribute of the Server object

Returns:
The hostId value

getHostId

public HostId getHostId(URL clientURL)
                 throws HostNotFoundException
Gets the hostId attribute of the Server object

Parameters:
clientURL - Description of the Parameter
Returns:
The hostId value
Throws:
HostNotFoundException - Description of the Exception

getObjects

public List getObjects()
This method returns a list of all the objects shared in this global space.

Returns:
The objects value

getOwners

public Set getOwners()
Gets a Set with all clients who shared at least one object. A shallow copy of the objects map (created by a clone() call) is used for this.

Returns:
The owners set

getPlainSocketURL

public URL getPlainSocketURL()
Gets the plainSocketURL attribute of the Server object

Returns:
The plainSocketURL value

getPrivateKey

public PrivateKey getPrivateKey()
Gets the privateKey attribute of the Server object

Returns:
The privateKey value

getWriters

public Set getWriters()
Gets a set of all the clients who currently have at least one lock

Returns:
The writers set

isDebugging

public boolean isDebugging()
Gets the debugging attribute of the Server object

Returns:
The debugging value

main

public static void main(String[] args)
For testing

Parameters:
args - Description of the Parameter

setDebugging

public void setDebugging(boolean flag)
Sets the debugging attribute of the Server object

Parameters:
flag - The new debugging value

setPlainSocketURL

public void setPlainSocketURL(URL plainSocketURL)
This method should not be called.

Parameters:
plainSocketURL - The new plainSocketURL value

beginTrans

protected TimeStamp beginTrans(URL client,
                               String globalName)
                        throws NotSharedException,
                               AlreadyLockedException,
                               ObjectNotLockableException
Begins a transaction on a shared object.

Parameters:
client - Description of the Parameter
globalName - Description of the Parameter
Returns:
Description of the Return Value
Throws:
NotSharedException - If an entry for the globalName parameter is not found
AlreadyLockedException - If the object is already locked
ObjectNotLockableException - If the object is not lockable

commit

protected TimeStamp commit(URL client,
                           String globalName)
                    throws NotSharedException,
                           IllegalOperationException,
                           InsecureObjectException
Description of the Method

Parameters:
client - Description of the Parameter
globalName - Description of the Parameter
Returns:
Description of the Return Value
Throws:
NotSharedException - Description of the Exception
IllegalOperationException - Description of the Exception
InsecureObjectException - Description of the Exception

generateKeyPair

protected KeyPair generateKeyPair()
                           throws InsecureObjectException
Description of the Method

Returns:
Description of the Return Value
Throws:
InsecureObjectException - Description of the Exception

login

protected boolean login(HostId client)
Description of the Method

Parameters:
client - Description of the Parameter
Returns:
Description of the Return Value

logout

protected boolean logout(URL client)
Performs a client's logout. All objects owned by him are unshared.

Parameters:
client - The client who's logging out
Returns:
true if the client was logged in when this method was called.

ping

protected boolean ping(URL client)
Description of the Method

Parameters:
client - Description of the Parameter
Returns:
Description of the Return Value

request

protected HostId request(String globalName)
                  throws NotSharedException
Description of the Method

Parameters:
globalName - Description of the Parameter
Returns:
Description of the Return Value
Throws:
NotSharedException - Description of the Exception

rollback

protected void rollback(URL client,
                        String globalName)
                 throws NotSharedException,
                        NotLockedException
Description of the Method

Parameters:
client - Description of the Parameter
globalName - Description of the Parameter
Throws:
NotSharedException - Description of the Exception
NotLockedException - Description of the Exception

share

protected TimeStamp share(URL client,
                          String globalName,
                          boolean lockable)
                   throws AlreadySharedException,
                          InsecureObjectException
Description of the Method

Parameters:
client - Description of the Parameter
globalName - Description of the Parameter
lockable - Description of the Parameter
Returns:
Description of the Return Value
Throws:
AlreadySharedException - Description of the Exception
InsecureObjectException - Description of the Exception

unlock

protected void unlock(URL client,
                      String globalName,
                      TimeStamp stamp)
               throws NotSharedException,
                      InsecureObjectException,
                      NotLockedException
Description of the Method

Parameters:
client - Description of the Parameter
globalName - Description of the Parameter
stamp - Description of the Parameter
Throws:
NotSharedException - Description of the Exception
InsecureObjectException - Description of the Exception
NotLockedException - Description of the Exception

unshare

protected void unshare(URL client,
                       String globalName)
                throws NotSharedException,
                       IllegalOperationException
Description of the Method

Parameters:
client - Description of the Parameter
globalName - Description of the Parameter
Throws:
NotSharedException - Description of the Exception
IllegalOperationException - Description of the Exception

validate

protected HostId validate(String globalName,
                          TimeStamp stamp)
                   throws NotSharedException,
                          InsecureObjectException
Description of the Method

Parameters:
globalName - Description of the Parameter
stamp - Description of the Parameter
Returns:
Description of the Return Value
Throws:
NotSharedException - Description of the Exception
InsecureObjectException - Description of the Exception