|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecttw.net.ocs.OCSClient
public final class OCSClient
OCSClient manages communication of client-side proxies with their server-side subjects via an associated OCSServer. Several OCSClient instances can be maintained in the class. If none has been created explicitely, one OCSClient instance exists which links directly with an OCSServer instance for local use. There are methods to create and retrieve instances, set the passwords required for users and administrators, set the key to use for encrypted data transmission, get proxies allowing access to OCSServer methods, and miscellaneous.
OCSServerAdminInterface
,
OCSServerUserInterface
Method Summary | |
---|---|
static OCSClient |
createInstance()
Creates and returns an OCSClient instance with default parameters. |
static OCSClient |
createInstance(OCSServer server,
java.lang.String name,
boolean standard)
Creates and returns an OCSClient instance which communicates with an OCSServer identified by object. |
static OCSClient |
createInstance(java.lang.String host,
int port,
java.lang.String name,
boolean standard)
Creates and returns an OCSClient instance. |
void |
detachProxy(java.lang.Class c,
java.lang.String subjectID)
Detaches a proxy from its subject. |
void |
disconnect()
Disconnects the OCSClient from the server. |
static OCSClient |
getInstance(OCSServer server)
Returns an instance connected to a server specified by instance. |
static OCSClient |
getInstance(java.lang.String name)
Returns an OCSClient instance identified by name |
static OCSClient |
getInstance(java.lang.String host,
int port)
Returns an instance connected to a server specified by host and port. |
static java.util.Collection<OCSClient> |
getInstances()
Returns all instances. |
java.lang.String |
getName()
Returns the name of the instance. |
java.lang.String |
getServerAddress()
Returns the address of the server connected to this OCSClient. |
OCSServerAdminInterface |
getServerAdminProxy()
Returns an object that allows to call admin methods on the server. |
java.lang.String |
getServerHost()
Returns the host address of the server. |
int |
getServerPort()
Returns the port of the server. |
OCSServerUserInterface |
getServerUserProxy()
Returns an object that allows to call methods on the server that are open to all users. |
static OCSClient |
getStandardInstance()
Returns the currently standard OCSClient instance |
boolean |
isLocal()
Tells whether the client is working in local mode, referencing the server directly |
boolean |
isStandardInstance()
Tells whether this instance is the current standard instance. |
static void |
main(java.lang.String[] args)
Allows to stop and ping a server, also to retrieve version information. |
java.lang.Object |
send(int request,
java.lang.Class c,
java.lang.String subjectID,
java.lang.String method,
java.lang.Class[] parameterTypes,
java.lang.Object[] parameters)
Sends a proxy's request to the server |
void |
setAdminPassword(java.lang.String pw)
Sets a password used to authorize the client for administrative functions. |
void |
setAsStandardInstance()
Makes this instance the new standard. |
void |
setEncryptionKey(java.lang.String key)
Sets the key for encrypted data transmission. |
void |
setUserPassword(java.lang.String pw)
Sets a password used to authorize the client for normal user operations. |
void |
setVerbose(boolean value)
Tells the client to print some accompanying messages to the console. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public static OCSClient createInstance(java.lang.String host, int port, java.lang.String name, boolean standard)
Creates and returns an OCSClient instance. The new instance attaches to a server running at a certain host and listening at a certain port, it carries a name and may be made the new standard OCSClient instance. If no name is specified, "[host]:[port]" is assumed. If an instance of the specified name exists already, the new name is made unique by appending "/[number]".
host
- host of the server to communicate withport
- port of the servername
- name of the new OCSClient instancestandard
- make it the new standard instance?
public static OCSClient createInstance()
Creates and returns an OCSClient instance with default parameters. The new instance attaches to a server on localhost listening at the default port 23229, is named accordingly "localhost:23229", and made the standard OCSClient instance.
public static OCSClient createInstance(OCSServer server, java.lang.String name, boolean standard)
Creates and returns an OCSClient instance which communicates with an OCSServer identified by object. If the OCSServer is configured for local use, the new OCSClient instance will link directly to the server and exchange data with it without networking. Otherwise, client and server will communicate over the network. In this case client and server may reside on the same host and live in the same virtual machine, but not necessarily so: The client may itself subsequently get transmitted to a remote server and then be used to communicate with another server hosted locally (where it had been created).
server
- the OCSServer which the new OCSClient shall attach toname
- the name of the OCSClientstandard
- make this instance the new standard instance?
public static OCSClient getStandardInstance()
public void setAsStandardInstance()
Makes this instance the new standard.
public boolean isStandardInstance()
Tells whether this instance is the current standard instance.
public java.lang.String getName()
public static OCSClient getInstance(OCSServer server)
Returns an instance connected to a server specified by instance. The server may or may not be directly linked to the client, client and server must reside on the same host, however. If there is more than one client connecting with this server, the method returns an arbitrary instance.
server
- the server that the client is associated with
getInstance(java.lang.String)
public static OCSClient getInstance(java.lang.String host, int port)
Returns an instance connected to a server specified by host and port. If there is more than one client connecting with this server, the method returns an arbitrary instance. Note that clients directly linked to local servers cannot be retrieved with this method.
host
- the host address of the serverport
- the port of the server
getInstance(java.lang.String)
public static OCSClient getInstance(java.lang.String name)
name
- name of the OCSClient instance
public static java.util.Collection<OCSClient> getInstances()
public boolean isLocal()
public void setUserPassword(java.lang.String pw)
Sets a password used to authorize the client for normal user operations. Note: If no password has been set in the OCSServer, access to user operations on the server is unrestricted.
pw
- the passwordpublic void setAdminPassword(java.lang.String pw)
Sets a password used to authorize the client for administrative functions. Note: If no password has been set in the OCSServer, access to admin operations on the server is forbidden.
pw
- the passwordpublic void setEncryptionKey(java.lang.String key)
Sets the key for encrypted data transmission. Setting a key means that encryption begins. Specifying null stops encryption. (Encryption is inactive if the client is used locally.)
key
- the encryption key or nullpublic void detachProxy(java.lang.Class c, java.lang.String subjectID)
c
- the class of the subjectsubjectID
- the ID of the subjectpublic java.lang.Object send(int request, java.lang.Class c, java.lang.String subjectID, java.lang.String method, java.lang.Class[] parameterTypes, java.lang.Object[] parameters)
public void disconnect()
Disconnects the OCSClient from the server. Note that this call does not disable the OCSClient in any way! If the OCSClient is used next time, another connection will be established automatically and transparently. The sole purpose of this method is to free up resources on the server, concretely: it finishes the thread which is dedicated to serving the connection to this OCSClient. Calling disconnect() from time to time, e.g. when some substantial unit of work is done or, of course, when this OCSClient will not be used anymore, may be called a good and sound idea. Note that disconnect() gets called automatically when the process is about to terminate.
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getServerAddress()
Returns the address of the server connected to this OCSClient. The address has either the form {host}:{port} or it is the string "LOCAL" (if an OCSServer instance is directly linked to this OCSClient).
public java.lang.String getServerHost()
Returns the host address of the server. If the client references an OCSServer directly it returns "LOCAL" .
public int getServerPort()
Returns the port of the server. If the client references an OCSServer instance directly, the value is Server.LOCAL (=-1).
public void setVerbose(boolean value)
Tells the client to print some accompanying messages to the console. Default is off.
value
- verbose on or offpublic OCSServerAdminInterface getServerAdminProxy()
Returns an object that allows to call admin methods on the server. The returned object implements all the methods declared in the OCSServerAdminInterface interface, and delegates their invocation to the OCSServer instance associated with this OCSClient. Note that the execution of administrative methods requires a valid admin password.
setAdminPassword(java.lang.String)
,
getServerUserProxy()
public OCSServerUserInterface getServerUserProxy()
Returns an object that allows to call methods on the server that are open to all users. The returned object implements all the methods declared in the OCSServerUserInterface interface, and delegates their invocation to the OCSServer instance associated with this OCSClient. Note that the execution of user methods may require a valid user password.
setUserPassword(java.lang.String)
,
getServerAdminProxy()
public static void main(java.lang.String[] args)
Allows to stop and ping a server, also to retrieve version information. Stopping and pinging require an admin password for authorization. Connecting to the server may also require that a key for data encryption is set. Usage: tw.net.ocs.OCSClient {parameters...} -ping Checks the connection to a server -stop Stops a server -host Host of the server (opt., default is localhost) -port Port of the server (opt., default is 23229) -adminPassword Password required for admin functions -encryptionKey Encrypt data using this key -version Show OCSelot version info -licensee Show licensee name
getServerAdminProxy()
,
getServerUserProxy()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |