Example usage for com.vaadin.server ServerRpcManager getRpcInterface

List of usage examples for com.vaadin.server ServerRpcManager getRpcInterface

Introduction

In this page you can find the example usage for com.vaadin.server ServerRpcManager getRpcInterface.

Prototype

public Class<T> getRpcInterface() 

Source Link

Document

Returns the RPC interface type managed by this RPC manager instance.

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) {
        /*//w  ww.ja  va2  s  .  com
         * 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;
}