|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.sys.Handle
ewe.io.RemoteCall
A RemoteCall with a RemoteCallHandler can be used to invoke methods on an object running in one ewe application by a different remote application. The remote call handles marshalling the data into text streams which are then sent and reassembled into local data and invoked on the target object. A result is sent back indicating success or failure along with any return value. This is very useful when synchronizing ewe applications since you do not need to come up with any protocols or message passing system. All you need to do is invoke methods remotely.
See the EweSyncDemo application for an example of how to do this.
Please note the following restrictions when using remote calls.
A RemoteCall represents a single method which is specified in its constructor. Once you have a RemoteCall object you set parameters for a call by calling the add() methods in sequence. The RemoteCall knows the exact type of each parameter so the data specified in each add() method is cast to the correct parameter type. Each add() method returns the RemoteCall object itself so it is easy to concatenate add() calls together.
| Nested Class Summary | |
static class |
RemoteCall.UnknownException
|
| Field Summary | |
Class |
classCreator
Deprecated. - this is not needed. |
String |
id
|
Throwable |
invocationError
This will hold any exception generated by the remote object when the method was invoked. |
String |
method
|
RemoteCallHandler |
myHandler
This is initially null but can be set before calling call. |
boolean |
replied
This is set true once a reply has been received. |
String |
retType
|
int |
timeOut
This is the timeout for the call. |
| Fields inherited from class ewe.sys.Handle |
Aborted, Changed, doing, error, errorCode, errorObject, Failed, Failure, nativeResult, progress, progressResolution, returnValue, Running, shouldStop, startTime, state, Stopped, stopReason, Succeeded, Success, task |
| Constructor Summary | |
RemoteCall(byte[] source,
int offset,
int length)
This is used to create a RemoteCall from a sequence of bytes. |
|
RemoteCall(String method)
Create a new RemoteCall targeted at the specified method. |
|
| Method Summary | |
RemoteCall |
add(boolean value)
Use this to add a parameter of type boolean. |
RemoteCall |
add(char value)
Use this to add a char parameter. |
RemoteCall |
add(double value)
Use this to add a parameter of type float or double. |
RemoteCall |
add(long value)
Use this to add a parameter of type byte, short, int and long. |
RemoteCall |
add(Object value)
Use this to add an object or array parameter (including null). |
RemoteCall |
addParameter(Wrapper w)
This is used to add a parameter. |
Wrapper |
call()
Invokes the remote call using the myHandler value as the transport mechanism and specifying a null (default) target object. |
Wrapper |
call(RemoteCallHandler handler,
String targetCode)
Invokes the remote call using the specified handler as the transport mechanism. |
Wrapper |
call(String targetCode)
Invokes the remote call using the myHandler value as the transport mechanism. |
RemoteCall |
callAsync()
|
RemoteCall |
callAsync(RemoteCallHandler handler,
String targetCode)
|
int |
encodeBytes(ByteArray dest)
This requests the Object to encode itself as a stream of bytes which is appended to the destination ByteArray. |
RemoteCall |
getCopy()
Get a copy of a RemoteCall that you can use for another invocation. |
Throwable |
getException()
|
Wrapper |
getReturnValue()
|
ByteArray |
invokeOn(Object dest,
Reflect r)
Invoke the remote call on a target object of the specified class. |
protected boolean |
invokeOn(Object dest,
Reflect r,
ByteArray ba)
|
void |
reply(ByteArray reply)
This is used to provide a reply to the remote call. |
void |
sent()
This is used to tell the RemoteCall that it is in the process of transmission to the remote object. |
RemoteCall |
set(Wrapper[] parameters)
|
RemoteCall |
setClassCreator(Class creator)
This is used to set a special class creator. |
RemoteCall |
setTimeout(int milliseconds)
This sets the timeout time for this RemoteCall. |
void |
timeout()
This is used to tell the RemoteCall that no reply has been received past a timeout period and it should conisider itself timed out. |
String |
toString()
Create a remote call from a received encoded call. |
| Methods inherited from class ewe.sys.Handle |
callBackOnAnyFlag, callBackOnFlags, callWhenStopped, callWhenStopped, cancelCallBack, changed, check, check, checkAny, clearTag, doCallBackOnFlags, fail, failed, getErrorText, getHandle, getSubHandle, getSubHandle, getTag, getTask, hasStopped, resetProgress, resetTime, set, setFlags, setProgress, setTag, start, startDoing, startTask, stop, stopAlsoIfStopped, stopTask, ticked, waitOn, waitOn, waitOn, waitOn, waitOnAny, waitOnAny, waitOnAny, waitOnAny, waitOnAnyFlag, waitOnFlags, waitOnFlags, waitUntilStopped, waitUntilStopped |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode |
| Field Detail |
public String method
public String retType
public String id
public Class classCreator
public Throwable invocationError
public int timeOut
public RemoteCallHandler myHandler
public boolean replied
| Constructor Detail |
public RemoteCall(String method)
Standard Java type specifiers are used, specifically.
B - byte, C - char, S - short, I - int, J - long, F - float, D - Double
Z - boolean, V - void (for method types only)
[type-specifier - for an array.
LclassName; - for object (NOTE the ending semi-colon).
For object (L) you should use / instead of . as the package separator.
The format for a method is: method_name(concatenated parameter type specifiers)return_type
There are no separators between the parameter type specifiers. If the the method is void you should use V as the return type.
public RemoteCall(byte[] source,
int offset,
int length)
throws StreamCorruptedException,
ClassNotFoundException
| Method Detail |
public RemoteCall getCopy()
public RemoteCall setClassCreator(Class creator)
creator - A Class object that was loaded from the same class loader.
public RemoteCall addParameter(Wrapper w)
w - a Wrapper with the parameter value. It must be of the correct type.
public RemoteCall add(char value)
value - The character parameter
public RemoteCall add(long value)
value - The long value to add.
public RemoteCall add(double value)
value - The double or float value to add.
public RemoteCall add(boolean value)
value - The boolean value to add.
public RemoteCall add(Object value)
value - The object or array value to add.
public RemoteCall set(Wrapper[] parameters)
public int encodeBytes(ByteArray dest)
throws IllegalStateException
ByteEncodable
encodeBytes in interface ByteEncodabledest - The destination ByteArray, or null to determine the number of bytes needed to encode.
IllegalStateException
public ByteArray invokeOn(Object dest,
Reflect r)
dest - The destination Object to invoke the method on - can ber - The Reflect object for the destination Object.
protected boolean invokeOn(Object dest,
Reflect r,
ByteArray ba)
public void sent()
public RemoteCall setTimeout(int milliseconds)
milliseconds - the timeout in milliseconds. Setting it to zero will cause the
remote call handler timeout to be used instead.
public void timeout()
public void reply(ByteArray reply)
public Wrapper call(RemoteCallHandler handler,
String targetCode)
throws RemoteCallException
handler - the RemoteCallHandler handling the call.targetCode - the target object.
RemoteCallException - if an error occured during the RemoteCall.
public RemoteCall callAsync(RemoteCallHandler handler,
String targetCode)
public RemoteCall callAsync()
public Wrapper getReturnValue()
public Throwable getException()
public Wrapper call(String targetCode)
throws RemoteCallException
targetCode - the target object.
RemoteCallException - if an error occured during the RemoteCall.
public Wrapper call()
throws RemoteCallException
RemoteCallException - if an error occured during the RemoteCall.public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||