|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.funambol.client.ipc.rpc.RPCManager
public class RPCManager
This class represents the main entry point to access Remote Procedure Call services. There are two basic functionalities:
RPCManager manager = RPCManager.getInstance(); // Invoke TestMethod with no arguments RPCParam res = manager.invoke("TestMethod", null); // We expect a string in return String retState = res.getStringValue();It is also possible to publish a method that can be invoked from remote parties. The following example shows an example:
private class GetStateInfoMethod extends RPCMethod { public GetStateInfoMethod() { super("getStateInfo"); } public RPCParam execute(RPCParam[] params) throws Exception { // We expect one parameter (the state name) if (params.length != 1) { throw new IllegalArgumentException("Expected one parameter"); } RPCParam param = params[0]; if (param.getType() != RPCParam.TYPE_STRING) { throw new IllegalArgumentException("Expected a string parameter"); } // Perform the operation String res = "No info available"; RPCParam ret = new RPCParam(); ret.setStringValue(res); return ret; } } RPCManager manager = RPCManager.getInstance(); GetStateInfoMethod method1 = new GetStateInfoMethod(this); manager.register(method1);The class GetStateInfoMethod is an extension of
RPCMethod
and it is used
to represent the method getStateInfo which is the method being
published. Its method execute is invoked on remote invokation. The
list of input parameters is in the params parameter and the method can return
one value (or null if its type is void).
The rest of the example shows the mechanism in the RPCManager to register (or
publish) a method).
Method Summary | |
---|---|
static RPCManager |
getInstance()
Default singleton instance access method |
RPCParam |
invoke(java.lang.String methodName,
RPCParam[] params)
Invoke a remote method. |
void |
messageReceived(java.lang.String msg)
This method is called by the RPCServer on incoming messages. |
void |
messageSent()
This method is called by the RPCServer on outgoing messages that are sent. |
void |
register(RPCMethod method)
Register a method so that is is made available externally. |
void |
serviceConnected()
This method is called by the RPCServer on service connection. |
void |
serviceDisconnected()
This method is called by the RPCServer on service disconnection. |
void |
serviceListening()
This method is called by the RPCServer when the service starts listening for incoming messages (after the connection phase). |
void |
serviceStopped()
This method is called by the RPCServer on service connection termination. |
void |
setRPCServer(com.funambol.client.ipc.rpc.RPCServer service)
This method allows the user to set its own RPCServer. |
void |
start()
Start the service if it is not running already. |
void |
stop()
Stops the service. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static RPCManager getInstance()
public void setRPCServer(com.funambol.client.ipc.rpc.RPCServer service)
service
- the RPCServerpublic RPCParam invoke(java.lang.String methodName, RPCParam[] params) throws RPCException
methodName
- the name of the methodparams
- the list of parameters (can be null if no parameters are
given)
RPCException
- if an exception occurs during the remote invokationpublic void register(RPCMethod method)
method
- the method descriptor (@see RPCMethod)public void stop()
public void start()
public void messageReceived(java.lang.String msg)
msg
- the received messagepublic void messageSent()
public void serviceConnected()
public void serviceDisconnected()
public void serviceListening()
public void serviceStopped()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |