|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--br.shob.AbstractCommLayer | +--br.shob.client.ClientCommLayer
This class is the client-side CommLayer used by a SharedSpace instance. It
inherits the comunication protocol form the AbstractCommLayer
and provides client-side facilities to the SharedSpace
.
As of SharedObjects 0.5, this class is capable of dinamically loading classes from remote hosts. This means that real implementation of shared objects is not required to be accessible to the client machines, so objects can be manipulated through known interfaces. In addition, different implementations of the same SharedReference can be used simultaneously on client machines without interfering with one another.
Field Summary | |
protected Map |
classLoadersMap
A mapping of class loaders by peer. |
protected HostId |
serverId
The server's host id. |
protected SharedSpace |
shob
The SharedSpace instance that uses this CommLayer |
protected ServerSocket |
signedSocket
The listening socket for this CommLayer |
Fields inherited from class br.shob.AbstractCommLayer |
keyPairGeneratorAlgorithm, logger, myId, signatureAlgorithm |
Constructor Summary | |
ClientCommLayer(SharedSpace shob,
String hostname,
int port)
Constructor for the ClientCommLayer object |
Method Summary | |
TimeStamp |
beginTrans(String globalName)
Asks the server to begin a transaction on a shared object |
protected void |
checkMessage(Message m,
int type,
String errorMsg)
Checks a message for errors. |
HostId |
commit(SharedObject obj)
Asks the server to commit a transaction on a shared object |
SharedObject |
get(String globalName,
HostId owner)
this method is called when the owner needs to update the original object. |
protected ShobClassLoader |
getClassLoader(String globalName)
Gets a class loader who can load classes for the given global name |
long |
getCurrentTime()
Gets the currentTime attribute of the ClientCommLayer object |
byte[] |
getRemoteClassArray(String globalName,
String className,
HostId owner)
Gets the bytes representing a class to be defined. |
HostId |
identify(URL remoteURL)
Gets the HostId for a peer URL. |
boolean |
isLoggedIn()
Checks if this CommLayer is logged to the global server. |
void |
login(String hostname,
int port)
Connects to the global server |
void |
logout()
Logs out from the global server, releasing any global resources (such as transaction locks) that this CommLayer might be using. |
SharedObject |
reload(String globalName)
Reloads a shard object from its owner. |
SharedObject |
reload(String globalName,
HostId owner)
Reloads a shared object from its owner. |
HostId |
request(String globalName)
Asks the server for the owner of a shared object |
HostId |
rollback(String globalName)
Asks the server to rollback a transaction. |
void |
send(Socket s,
String globalName)
Sends an object in the owned list through the socket. |
void |
sendCached(Socket s,
String globalName)
Sends an object in the cached list through the socket. |
void |
sendClass(Socket s,
String globalName,
String className)
Sends a class file through the socket. |
void |
share(SharedObject obj)
Registers an object at the global server. |
void |
start()
Starts this CommLayer |
void |
unlock(String globalName,
HostId writer,
TimeStamp stamp)
Asks the server to unlock an object and finish a transaction (after commit or reload) |
void |
unshare(String globalName)
Unregisters an object at the server. |
void |
update(String globalName,
HostId writer)
Updates the owned object list with the object taken from the writer's cache and finishes a commit process |
HostId |
validate(String globalName,
TimeStamp stamp)
Validates a time stamp. |
Methods inherited from class br.shob.AbstractCommLayer |
connect, connect, getLogger, isOnline, recvMessage, recvMessage, sendMessage, setLogger |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Map classLoadersMap
protected HostId serverId
protected SharedSpace shob
protected ServerSocket signedSocket
Constructor Detail |
public ClientCommLayer(SharedSpace shob, String hostname, int port) throws CommLayerException
shob
- The SharedSpace that will use this CommLayerhostname
- The global space server's hostnameport
- The global space server's listening port
CommLayerException
- if a communication error occurs.Method Detail |
public TimeStamp beginTrans(String globalName) throws ShobException
globalName
- the global name of the shared object
ShobException
- if a communication error occurspublic HostId commit(SharedObject obj) throws ShobException
obj
- The shared object's new value
ShobException
- wrapping a lower level exception.public SharedObject get(String globalName, HostId owner) throws ShobException
globalName
- the global name of the shared objectowner
- the object owner's HostId
ShobException
- wrapping a lower level exception.public long getCurrentTime()
public byte[] getRemoteClassArray(String globalName, String className, HostId owner) throws ShobException
globalName
- The global name of the object which needs that
class to be correctly loaded. Used in security checkingclassName
- the fully qualified name of the class to loadowner
- HostId of the owner of the object which needs the
class.
ShobException
- wrapping a lower level exception.public HostId identify(URL remoteURL) throws ShobException
remoteURL
- The URL of a SharedSpace (only hostname and port
are used)
ShobException
- wrapping a lower level exception.public boolean isLoggedIn()
public void login(String hostname, int port) throws ShobException
hostname
- the hostname of the serverport
- the port number the server listens to
ShobException
- wrapping a lower level exception.public void logout() throws ShobException
ShobException
- wrapping a lower level exception.public SharedObject reload(String globalName, HostId owner) throws ShobException
globalName
- The global name of the objectowner
- the owner of the object
ShobException
- wrapping a lower level exception.public SharedObject reload(String globalName) throws ShobException
reload(glogalName, owner)
globalName
- a global name
ShobException
- wrapping a lower level exception.reload(String,HostId)
public HostId request(String globalName) throws ShobException
globalName
- global name of the object
ShobException
- wrapping a lower level exception.public HostId rollback(String globalName) throws ShobException
globalName
- the object where a transaction is taking place
ShobException
- wrapping a lower level exception.public void send(Socket s, String globalName) throws CommLayerException
s
- the socket to send it throughglobalName
- the global name of the object
CommLayerException
- if a communication error occurspublic void sendCached(Socket s, String globalName) throws CommLayerException
s
- the socket to send it throughglobalName
- the global name of the object
CommLayerException
- if a communication error occurspublic void sendClass(Socket s, String globalName, String className) throws CommLayerException
s
- the socket to send it throughglobalName
- the global name of the objectclassName
- the name of the class to send
CommLayerException
- if a communication error occurs or the class
is not foundpublic void share(SharedObject obj) throws ShobException
obj
- the shared object to share
ShobException
- Description of the Exceptionpublic void start() throws CommLayerException
CommLayerException
- wrapping a lower level exception.public void unlock(String globalName, HostId writer, TimeStamp stamp) throws ShobException
globalName
- the objectwriter
- the transaction lockerstamp
- the timestamp to use as last modified time
ShobException
- wrapping a lower level exception.public void unshare(String globalName) throws ShobException
globalName
- the global name of the object
ShobException
- wrapping a lower level exception.public void update(String globalName, HostId writer) throws ShobException
globalName
- the global name of the objectwriter
- the object's current writer
ShobException
- wrapping a lower level exception.public HostId validate(String globalName, TimeStamp stamp) throws ShobException
globalName
- global name of the objectstamp
- currently known last modification value
ShobException
- wrapping a lower level exception.protected void checkMessage(Message m, int type, String errorMsg) throws ShobException
m
- the message to be checkedtype
- the expected type for the messageerrorMsg
- a prefix for the eventual error message
ShobException
- if the message is not valid or informs that a
remote error occurred.protected ShobClassLoader getClassLoader(String globalName)
globalName
- Description of the Parameter
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |