Package org.apache.tuscany.sca.core.invocation.impl

Examples of org.apache.tuscany.sca.core.invocation.impl.MessageImpl


    }

    public void invokeAsync(WebsocketBindingMessage request, TuscanyWebsocket channel) {
        String jsonParams = request.getPayload();
        Object[] args = JSONUtil.decodePayloadForOperation(jsonParams, operation);
        Message msg = new MessageImpl();
        msg.getHeaders().put(Constants.MESSAGE_ID, channel.getId());
        msg.setBody(args);
        EndpointReference re = new RuntimeEndpointReferenceImpl();
        RuntimeEndpointImpl callbackEndpoint = new RuntimeEndpointImpl();
        callbackEndpoint.setURI(request.getOperation());
        re.setCallbackEndpoint(callbackEndpoint);
        msg.setFrom(re);
        endpoint.invoke(operation, msg);
    }
View Full Code Here


     */
    @Override
    public Message invoke(final Message msg) {
        String sessionId = (String) msg.getHeaders().get(Constants.RELATES_TO);
        Broadcaster broadcaster = CometSessionManager.get(sessionId);
        Message response = new MessageImpl();
        if (broadcaster == null) {
            response.setBody(Status.CLIENT_DISCONNECTED);
        } else {
            String callbackMethod = msg.getTo().getURI();
            Object[] body = msg.getBody();
            broadcaster.broadcast(callbackMethod + "($.secureEvalJSON('" + JSONUtil.encodeResponse(body[0]) + "'))");
            response.setBody(Status.OK);
        }
        return response;
    }
View Full Code Here

     * @param callbackMethod
     *            method to call once a response is available
     * @return an invocation message
     */
    private Message createMessageWithMockedCometReference(Object[] args, String sessionId, String callbackMethod) {
        Message msg = new MessageImpl();
        msg.getHeaders().put(Constants.MESSAGE_ID, sessionId);
        msg.setBody(args);
        EndpointReference re = new RuntimeEndpointReferenceImpl();
        RuntimeEndpointImpl callbackEndpoint = new RuntimeEndpointImpl();
        callbackEndpoint.setURI(callbackMethod);
        re.setCallbackEndpoint(callbackEndpoint);
        msg.setFrom(re);
        return msg;
    }
View Full Code Here

    }

    public void invokeAsync(WebsocketBindingMessage request, TuscanyWebsocket channel) {
        String jsonParams = request.getPayload();
        Object[] args = JSONUtil.decodePayloadForOperation(jsonParams, operation);
        Message msg = new MessageImpl();
        msg.getHeaders().put(Constants.MESSAGE_ID, channel.getId());
        msg.setBody(args);
        EndpointReference re = assemblyFactory.createEndpointReference(); //new RuntimeEndpointReferenceImpl();
        Endpoint callbackEndpoint = assemblyFactory.createEndpoint(); //new RuntimeEndpointImpl();
        callbackEndpoint.setURI(request.getOperation());
        re.setCallbackEndpoint(callbackEndpoint);
        msg.setFrom(re);
        endpoint.invoke(operation, msg);
    }
View Full Code Here

    }

    public Message invoke(Message msg) {
        String channelId = (String) msg.getHeaders().get(Constants.RELATES_TO);
        TuscanyWebsocket websocket = WebsocketConnectionManager.getConnection(channelId);
        Message response = new MessageImpl();
        if (websocket == null) {
            response.setBody(WebsocketStatus.CLOSED);
        } else {
            Object[] body = msg.getBody();
            String payload = JSONUtil.encodePayload(body[0]);
            String operation = msg.getTo().getURI();
            WebsocketBindingMessage message = new WebsocketBindingMessage(operation, payload);
            websocket.send(message);
            response.setBody(WebsocketStatus.OPEN);
        }
        return response;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.core.invocation.impl.MessageImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.