Example usage for com.vaadin.server ClientConnector getRpcManager

List of usage examples for com.vaadin.server ClientConnector getRpcManager

Introduction

In this page you can find the example usage for com.vaadin.server ClientConnector getRpcManager.

Prototype

public ServerRpcManager<?> getRpcManager(String rpcInterfaceName);

Source Link

Document

Returns the RPC manager instance to use when receiving calls for an RPC interface.

Usage

From source file:org.semanticsoft.vaaclipse.app.servlet.VaaclipseServerRpcHandler.java

License:Open Source License

private ServerRpcMethodInvocation parseServerRpcInvocation(String connectorId, String interfaceName,
        String methodName, JSONArray parametersJson, ConnectorTracker connectorTracker) throws JSONException {
    ClientConnector connector = connectorTracker.getConnector(connectorId);

    ServerRpcManager<?> rpcManager = connector.getRpcManager(interfaceName);
    if (rpcManager == null) {
        /*//from ww  w  .  j  a  v a 2s  .c o m
         * Security: Don't even decode the json parameters if no RpcManager
         * corresponding to the received method invocation has been
         * registered.
         */
        getLogger().warning("Ignoring RPC call to " + interfaceName + "." + methodName + " in connector "
                + connector.getClass().getName() + "(" + connectorId
                + ") as no RPC implementation is registered");
        return null;
    }

    // Use interface from RpcManager instead of loading the class based on
    // the string name to avoid problems with OSGi
    Class<? extends ServerRpc> rpcInterface = rpcManager.getRpcInterface();

    ServerRpcMethodInvocation invocation = new ServerRpcMethodInvocation(connectorId, rpcInterface, methodName,
            parametersJson.length());

    Object[] parameters = new Object[parametersJson.length()];
    Type[] declaredRpcMethodParameterTypes = invocation.getMethod().getGenericParameterTypes();

    for (int j = 0; j < parametersJson.length(); ++j) {
        Object parameterValue = parametersJson.get(j);
        Type parameterType = declaredRpcMethodParameterTypes[j];
        parameters[j] = JsonCodec.decodeInternalOrCustomType(parameterType, parameterValue, connectorTracker);
    }
    invocation.setParameters(parameters);
    return invocation;
}