Example usage for java.lang Runtime.RemoteObject Runtime.RemoteObject

List of usage examples for java.lang Runtime.RemoteObject Runtime.RemoteObject

Introduction

In this page you can find the example usage for java.lang Runtime.RemoteObject Runtime.RemoteObject.

Prototype

Runtime.RemoteObject

Source Link

Usage

From source file:com.facebook.stetho.inspector.protocol.module.DOM.java

@ChromeDevtoolsMethod
public ResolveNodeResponse resolveNode(JsonRpcPeer peer, JSONObject params) throws JsonRpcException {
    ResolveNodeRequest request = mObjectMapper.convertValue(params, ResolveNodeRequest.class);
    Object object = mObjectIdMapper.getObjectForId(request.nodeId);

    int mappedObjectId = Runtime.mapObject(peer, object);

    Runtime.RemoteObject remoteObject = new Runtime.RemoteObject();
    remoteObject.type = Runtime.ObjectType.OBJECT;
    remoteObject.subtype = Runtime.ObjectSubType.NODE;
    remoteObject.className = remoteObject.getClass().getName();
    remoteObject.value = null; // not a primitive
    remoteObject.description = null; // not sure what this does...
    remoteObject.objectId = String.valueOf(mappedObjectId);
    ResolveNodeResponse response = new ResolveNodeResponse();
    response.object = remoteObject;// w  w  w  .  j  a  v  a 2s. c o m

    return response;
}

From source file:com.taobao.weex.devtools.inspector.protocol.module.DOM.java

@ChromeDevtoolsMethod
public ResolveNodeResponse resolveNode(JsonRpcPeer peer, JSONObject params) throws JsonRpcException {
    final ResolveNodeRequest request = mObjectMapper.convertValue(params, ResolveNodeRequest.class);

    final Object element = mDocument.postAndWait(new UncheckedCallable<Object>() {
        @Override/*from   w w  w.j  av a2s  .  c  o m*/
        public Object call() {
            return mDocument.getElementForNodeId(request.nodeId);
        }
    });

    if (element == null) {
        throw new JsonRpcException(new JsonRpcError(JsonRpcError.ErrorCode.INVALID_PARAMS,
                "No known nodeId=" + request.nodeId, null /* data */));
    }

    int mappedObjectId = Runtime.mapObject(peer, element);

    Runtime.RemoteObject remoteObject = new Runtime.RemoteObject();
    remoteObject.type = Runtime.ObjectType.OBJECT;
    remoteObject.subtype = Runtime.ObjectSubType.NODE;
    remoteObject.className = element.getClass().getName();
    remoteObject.value = null; // not a primitive
    remoteObject.description = null; // not sure what this does...
    remoteObject.objectId = String.valueOf(mappedObjectId);
    ResolveNodeResponse response = new ResolveNodeResponse();
    response.object = remoteObject;

    return response;
}