|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.lightdev.app.trec.client.Client
public class Client
A class that can be used by arbitrary applications to turn them into a client in the context of the Light Development Transparent Remote Computing (TREC) platform.
A Client encapsulates the communication model of
TREC and provides basic functionality for calling remote methods, login/logout and for
changes to the own password of a currently logged in user.
| Field Summary | |
|---|---|
static String |
DEFAULT_AUTHORIZER
default name of TREC authorizer agent |
static String |
DEFAULT_METHOD_CHG_PW
default name of change own password method of TREC authorizer agent |
static String |
DEFAULT_METHOD_LOGIN
default name of login method of TREC authorizer agent |
static String |
DEFAULT_METHOD_LOGOUT
default name of logout method of TREC authorizer agent |
static String |
DEFAULT_SAM_ADMIN
default name of TREC SAM administrator agent |
static String |
DEFAULT_SERVER_ADMIN
default name of TREC server administrator agent |
static int |
STORE_TYPE_EMBEDDED
|
static int |
STORE_TYPE_ROOT
|
static int |
STORE_TYPE_SHARED_JDBC
|
static int |
UDSS_CONNECT_STR
|
static int |
UDSS_DRIVER
|
static int |
UDSS_TYPE
|
| Constructor Summary | |
|---|---|
Client(ServerAddress sa)
create a new instance of a Client object |
|
| Method Summary | |
|---|---|
boolean |
changeOwnPassword(String agentName,
String currentPw,
String newPw)
change the password of the user of a given session id |
Object |
deserialize(byte[] bytes)
deserialize a given byte array back to an object The JaCS platform uses Apache XML-RPC for all communication between clients and servers. |
Object |
executeRequest(Request request)
execute a client reqeust as an XML-RPC remote procedure call |
void |
executeRequest(Request request,
AsyncCallback listener)
Execute a client request asynchronously as an XML-RPC remote procedure call. |
ServerAddress |
getServerAddress()
get the server address this client is created for |
String |
getUserId()
|
boolean |
isLoggedIn()
|
String |
login(String agentName,
String userId,
String pw)
login using a given authorizer address |
boolean |
logout(String agentName)
logout the user with a given session id using the authorizer at a given address |
byte[] |
serialize(Object obj)
serialize a given object for transport to a remote agent. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_AUTHORIZER
public static final String DEFAULT_SERVER_ADMIN
public static final String DEFAULT_SAM_ADMIN
public static final String DEFAULT_METHOD_LOGIN
public static final String DEFAULT_METHOD_LOGOUT
public static final String DEFAULT_METHOD_CHG_PW
public static final int UDSS_TYPE
public static final int UDSS_DRIVER
public static final int UDSS_CONNECT_STR
public static final int STORE_TYPE_ROOT
public static final int STORE_TYPE_EMBEDDED
public static final int STORE_TYPE_SHARED_JDBC
| Constructor Detail |
|---|
public Client(ServerAddress sa)
Client object
sa - address of the server this client should communicate with| Method Detail |
|---|
public ServerAddress getServerAddress()
public Object executeRequest(Request request)
throws Throwable
request - request to send
Throwable - could be many errors such as MalformedURLException, AccessException,
XmlRpcException partly with nested causes such as SQLException, etc. Caller need to analyze
exception for appropriate handling
public void executeRequest(Request request,
AsyncCallback listener)
throws Throwable
Execute a client request asynchronously as an XML-RPC remote procedure call. This method returns immediately. The caller needs to provide a listener that handles the result.
request - request to sendlistener - listener that handles the result once the method returns
Throwable - could be many errors such as MalformedURLException, AccessException,
XmlRpcException partly with nested causes such as SQLException, etc. Caller need to analyze
exception for appropriate handling
public String login(String agentName,
String userId,
String pw)
throws MalformedURLException,
Throwable
agentName - name of agent to use for loginuserId - id of user to loginpw - password of user to login
Throwable
MalformedURLException
public boolean logout(String agentName)
throws MalformedURLException,
Throwable
agentName - name of agent to call for logout, normally Client.DEFAULT_AUTHORIZER
Throwable
MalformedURLExceptionpublic boolean isLoggedIn()
public String getUserId()
public boolean changeOwnPassword(String agentName,
String currentPw,
String newPw)
throws MalformedURLException,
Throwable
agentName - name of agent to use for pw chgcurrentPw - current password of usernewPw - new password of user
Throwable
MalformedURLExceptionpublic byte[] serialize(Object obj)
serialize a given object for transport to a remote agent.
The TREC platform uses Apache XML-RPC for all communication between clients and servers. When a data type is not supported by XML-RPC this method can be used to serialize the object to a byte array using interface java.io.Serializable (the object that is to be serialized needs to implement that interface).
For a listing of types supported by XML-RPC see http://ws.apache.org/xmlrpc/types.html
Subclasses of class Client can override this method to implement
another serialization method such as XStream at
http://xstream.codehaus.org/
With XStream a serialization/deserialization could look as follows:
Point p = new Point( 120, 32 ); XStream xstream = new XStream(); String xml = xstream.toXML( p ); System.out.println( xml ); Point q = (Point) xstream.fromXML( xml );
obj - the object to serialize
public Object deserialize(byte[] bytes)
throws IOException,
ClassNotFoundException
The JaCS platform uses Apache XML-RPC for all communication between clients and servers. When a data type is not supported by XML-RPC this method can be used to deserialize a byte array back to an object using interface java.io.Serializable (the object that is to be deserialized needs to implement that interface).
For a listing of types supported by XML-RPC see http://ws.apache.org/xmlrpc/types.html
Subclasses of class Client can override this method to implement
another serialization method such as XStream at
http://xstream.codehaus.org/
With XStream a serialization/deserialization could look as follows:
Point p = new Point( 120, 32 ); XStream xstream = new XStream(); String xml = xstream.toXML( p ); System.out.println( xml ); Point q = (Point) xstream.fromXML( xml );
bytes -
IOException
ClassNotFoundException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||