wt.method
Class RemoteMethodServer

java.lang.Object
  extended by wt.method.RemoteMethodServer

public class RemoteMethodServer
extends Object

Class that provides access to a remote method server. Instances of this class are local (non-remote) objects that encapsulate the communication with a remote method server object. This encapsulation includes object location, and automatic recovery from communication errors.

The local object represents the "concept" of a remote method server, not a particular instance of the remote server object. This allows the local object to manage connecting to a server object, and reconnecting to new server objects during error recovery.

Error recovery consists of automatically retrying calls that fail due to communication failures. Argument classes that are consumed by serialization should throw a NotSerializableException to abort retries if re-serialization is not valid.

If the calling thread is an instance of wt.util.WTThread, interrupting the thread while it is invoking a remote method will cause the corresponding remote thread in the method server to be interrupted. This allows the client to abort long running server operations by interrupting the calling thread.

Supported API: true
Extendable: false


Method Summary
 MethodAuthenticator getAuthenticator()
          Get the MethodAuthenticator to use for the current thread.
static RemoteMethodServer getDefault()
          Get default instance of RemoteMethodServer.
static boolean getDefaultPrivateAffinity()
          Get default value of whether or not calls from different contexts will use private server affinity or share server affinity with other contexts accessing the same server.
static boolean getDefaultPrivateAuthentication()
          Return default value of whether or not calls from will use a private method authenticator or share authentication with other contexts accessing the same server.
static RemoteMethodServer getInstance(URL server_codebase)
          Get instance of RemoteMethodServer corresponding to the given server codebase URL.
static RemoteMethodServer getInstance(URL server_codebase, String service_name)
          Get instance of RemoteMethodServer corresponding to the given server codebase URL.
 String getPassword()
          Get the password set for this instance by the setPassword method.
static boolean getPrivateAffinity()
          Return whether or not calls from the current context will use private server affinity or share server affinity with other contexts accessing the same server.
static boolean getPrivateAuthentication()
          Return whether or not calls from the current context will use a private method authenticator or share authentication with other contexts accessing the same server.
 String getUserName()
          Get the user name set for this instance by the setUserName method.
 Object invoke(String target_method, String target_class, Object target_object, Class[] arg_types, Object[] args)
          Invoke the specified target method with the remote method server.
static void main(String[] args)
          Simple tester Displays info from the default server.
static void ping()
          Simple ping tester.
 void setAuthenticator(MethodAuthenticator authenticator)
          Set the MethodAuthenticator to use for the current thread.
static void setDefaultPrivateAffinity(boolean private_affinity)
          Set default value of whether or not calls from different contexts will use private server affinity or share server affinity with other contexts accessing the same server.
static void setDefaultPrivateAuthentication(boolean private_auth)
          Set default value of whether or not calls will use a private method authenticator or share authentication with other contexts accessing the same server.
 void setPassword(String password)
          Set the password that will be made available to a method authenticator capable of password based authentication.
static void setPrivateAffinity(boolean private_affinity)
          Set whether or not calls from the current context will maintain server affinity separately from other contexts or share server affinity with other contexts accessing the same remote method server.
static void setPrivateAuthentication(boolean private_auth)
          Set whether or not calls from the current context will use a private method authenticator or share authentication with other contexts accessing the same server.
 void setUserName(String user_name)
          Set the user name that will be made available to a method authenticator capable of user name based authentication.
 boolean streamingSupported()
          Determine if streaming calls are supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static RemoteMethodServer getInstance(URL server_codebase)
Get instance of RemoteMethodServer corresponding to the given server codebase URL.

Supported API: true

Parameters:
server_codebase - the server codebase URL

getInstance

public static RemoteMethodServer getInstance(URL server_codebase,
                                             String service_name)
Get instance of RemoteMethodServer corresponding to the given server codebase URL.

Supported API: true

Parameters:
server_codebase - the server codebase URL
service_name - the service name registered by the server

getDefault

public static RemoteMethodServer getDefault()
Get default instance of RemoteMethodServer. The default instance is the one corresponding to the server codebase of the current thread as returned by the WTProperties class.

Supported API: true

See Also:
WTProperties

getPrivateAuthentication

public static boolean getPrivateAuthentication()
Return whether or not calls from the current context will use a private method authenticator or share authentication with other contexts accessing the same server.

Supported API: true

Returns:
private authentication setting

setPrivateAuthentication

public static void setPrivateAuthentication(boolean private_auth)
Set whether or not calls from the current context will use a private method authenticator or share authentication with other contexts accessing the same server. Normally, all contexts that share access to a remote method server will use the same security context. This method allows multi-user applications to establish separate security contexts for different calling contexts.

The setting affects calls originating in threads that share the current thread's WTContext. The default for a WTContext is to use shared authentication.

Supported API: true

Parameters:
private_auth - true indicates private, false indicates shared

getDefaultPrivateAuthentication

public static boolean getDefaultPrivateAuthentication()
Return default value of whether or not calls from will use a private method authenticator or share authentication with other contexts accessing the same server.

Supported API: true

Returns:
private authentication setting

setDefaultPrivateAuthentication

public static void setDefaultPrivateAuthentication(boolean private_auth)
Set default value of whether or not calls will use a private method authenticator or share authentication with other contexts accessing the same server.

Supported API: true

Parameters:
private_auth - true indicates private, false indicates shared

getPrivateAffinity

public static boolean getPrivateAffinity()
Return whether or not calls from the current context will use private server affinity or share server affinity with other contexts accessing the same server.

Supported API: true

Returns:
private authentication setting

setPrivateAffinity

public static void setPrivateAffinity(boolean private_affinity)
Set whether or not calls from the current context will maintain server affinity separately from other contexts or share server affinity with other contexts accessing the same remote method server. Normally, all contexts that share access to a remote method server will use the same server instance. This method allows multi-user applications to establish separate server affinity for different calling contexts.

The setting affects calls originating in threads that share the current thread's WTContext. The default for a WTContext is to use shared server affinity.

Supported API: true

Parameters:
private_affinity - true indicates private, false indicates shared

getDefaultPrivateAffinity

public static boolean getDefaultPrivateAffinity()
Get default value of whether or not calls from different contexts will use private server affinity or share server affinity with other contexts accessing the same server.

Supported API: true

Returns:
private authentication setting

setDefaultPrivateAffinity

public static void setDefaultPrivateAffinity(boolean private_affinity)
Set default value of whether or not calls from different contexts will use private server affinity or share server affinity with other contexts accessing the same server.

Supported API: true

Parameters:
private_affinity - true indicates private, false indicates shared

setUserName

public void setUserName(String user_name)
Set the user name that will be made available to a method authenticator capable of user name based authentication. This information is managed by the RemoteMethodServer object because it manages the use of method authenticators. If private authentication is set for the current thread's WTContext, this user name will not be shared with other contexts.

Supported API: true

Parameters:
user_name - User name, or null to remove setting.

getUserName

public String getUserName()
Get the user name set for this instance by the setUserName method.

Supported API: true

Returns:
User name, or null if not set.

setPassword

public void setPassword(String password)
Set the password that will be made available to a method authenticator capable of password based authentication. This information is managed by the RemoteMethodServer object because it manages the use of method authenticators. If private authentication is set for the current thread's WTContext, this password will not be shared with other contexts. The password is encoded in memory so it does not remain in clear text.

Supported API: true

Parameters:
password - Password, or null to remove setting.

getPassword

public String getPassword()
Get the password set for this instance by the setPassword method.

Supported API: true

Returns:
User name, or null if not set.

invoke

public Object invoke(String target_method,
                     String target_class,
                     Object target_object,
                     Class[] arg_types,
                     Object[] args)
              throws RemoteException,
                     InvocationTargetException
Invoke the specified target method with the remote method server. The method is dynamically invoked within the server and any uncaught exceptions thrown by the remote method are thrown here wrapped in a InvocationTargetException.

Supported API: true

Parameters:
target_method - the target method name
target_class - the target class (for static methods only)
target_object - the target object (for instance methods only)
arg_types - an array of argument types used when looking up the method
args - an array of argument objects for the method
Throws:
RemoteException - any exception trying to call the target method
InvocationTargetException - any exception thrown by the target method
See Also:
Method.invoke(java.lang.Object, java.lang.Object...)

getAuthenticator

public MethodAuthenticator getAuthenticator()
Get the MethodAuthenticator to use for the current thread. If the current context uses a private authenticator, that one will be returned, otherwise the shared authenticator will be returned.

Supported API: true


setAuthenticator

public void setAuthenticator(MethodAuthenticator authenticator)
Set the MethodAuthenticator to use for the current thread. If the current context does not use a private authenticator, this will set the shared authenticator. Setting to null removes the current authenticator.

Supported API: true


streamingSupported

public boolean streamingSupported()
                           throws RemoteException
Determine if streaming calls are supported. Streaming is not be supported when RMI is tunneled over HTTP or HTTPS requests since the argument and response objects are buffered in memory when building HTTP request and response bodies.

Supported API: true

Throws:
RemoteException

ping

public static void ping()
                 throws RemoteException
Simple ping tester. Invokes a ping method that is built into the remote method server.

Supported API: true

Throws:
RemoteException

main

public static void main(String[] args)
                 throws RemoteException
Simple tester Displays info from the default server. If an integer argument is supplied, it pings the server that many times.

Supported API: true

Throws:
RemoteException