Package org.directwebremoting.extend

Examples of org.directwebremoting.extend.ScriptConduit


        {
            out = response.getWriter();
        }

        // The conduit to pass on reverse ajax scripts
        ScriptConduit conduit = new CallScriptConduit(out);

        // Setup a debugging prefix
        if (out instanceof DebuggingPrintWriter)
        {
            DebuggingPrintWriter dpw = (DebuggingPrintWriter) out;
            dpw.setPrefix("out(" + conduit.hashCode() + "): ");
        }

        // Send the script prefix (if any)
        sendOutboundScriptPrefix(out, replies.getCalls().getInstanceId(), replies.getCalls().getBatchId());

        out.println(ProtocolConstants.SCRIPT_CALL_INSERT);
        scriptSession.writeScripts(conduit);
        out.println(ProtocolConstants.SCRIPT_CALL_REPLY);

        String batchId = replies.getCalls().getBatchId();
        for (int i = 0; i < replies.getReplyCount(); i++)
        {
            Reply reply = replies.getReply(i);
            String callId = reply.getCallId();

            try
            {
                // The existence of a throwable indicates that something went wrong
                if (reply.getThrowable() != null)
                {
                    Throwable ex = reply.getThrowable();
                    ScriptBuffer script = EnginePrivate.getRemoteHandleExceptionScript(batchId, callId, ex);
                    conduit.addScript(script);
                    // TODO: Are there any reasons why we should be logging here (and in the ConversionException handler)
                    //log.warn("--Erroring: batchId[" + batchId + "] message[" + ex.toString() + ']'), ex;
                }
                else
                {
                    Object data = reply.getReply();
                    ScriptBuffer script = EnginePrivate.getRemoteHandleCallbackScript(batchId, callId, data);
                    conduit.addScript(script);
                }
            }
            catch (IOException ex)
            {
                // We're a bit stuck we died half way through writing so
View Full Code Here


            {
                // Try all the conduits, starting with the first
                boolean written = false;
                for (Iterator<ScriptConduit> it = conduits.iterator(); !written && it.hasNext();)
                {
                    ScriptConduit conduit = it.next();
                    try
                    {
                        written = conduit.addScript(script);
                    }
                    catch (Exception ex)
                    {
                        it.remove();
                        log.debug("Failed to write to ScriptConduit, removing conduit from list: " + conduit);
View Full Code Here

                log.debug("Call[" + i + "]=" + call.getScriptName() + "." + call.getMethodName() + (params == null ? "[]" : Arrays.asList(params)));
            }

            Replies replies = remoter.execute(calls);

            ScriptConduit conduit = new BayeuxScriptConduit(converterManager, JSON_OUTPUT);
            for (Reply reply : replies)
            {
                String batchId = calls.getBatchId();
                log.debug("Reply="+reply+" BatchId="+batchId);

                if (reply.getThrowable() != null)
                {
                    Throwable ex = reply.getThrowable();
                    ScriptBuffer script = EnginePrivate.getRemoteHandleExceptionScript(batchId, reply.getCallId(), ex);
                    conduit.addScript(script);

                    log.warn("--Erroring: batchId[" + batchId + "] message[" + ex.toString() + ']');
                }
                else
                {
                    Object data = reply.getReply();
                    log.debug("data="+data);
                    ScriptBuffer script = EnginePrivate.getRemoteHandleCallbackScript(batchId, reply.getCallId(), data);
                    conduit.addScript(script);
                }
            }

            String output = conduit.toString();
            log.debug("<< "+output);
            Channel channel = bayeux.getChannel("/dwr" + fromClient.getId(), true);
            channel.publish(client, output, calls.getBatchId());
        }
        catch (Exception ex)
View Full Code Here

TOP

Related Classes of org.directwebremoting.extend.ScriptConduit

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.