亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? dwrpplainjsmarshaller.java

?? dwr 源文件 dwr 源文件 dwr 源文件
?? JAVA
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
/*
 * Copyright 2005 Joe Walker
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.directwebremoting.dwrp;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.directwebremoting.AccessControl;
import org.directwebremoting.Call;
import org.directwebremoting.Calls;
import org.directwebremoting.ConverterManager;
import org.directwebremoting.Creator;
import org.directwebremoting.CreatorManager;
import org.directwebremoting.InboundContext;
import org.directwebremoting.InboundVariable;
import org.directwebremoting.MarshallException;
import org.directwebremoting.Marshaller;
import org.directwebremoting.OutboundContext;
import org.directwebremoting.OutboundVariable;
import org.directwebremoting.Replies;
import org.directwebremoting.Reply;
import org.directwebremoting.ScriptSession;
import org.directwebremoting.TypeHintContext;
import org.directwebremoting.WebContext;
import org.directwebremoting.WebContextFactory;
import org.directwebremoting.remoted.DwrSystem;
import org.directwebremoting.util.ContinuationUtil;
import org.directwebremoting.util.DebuggingPrintWriter;
import org.directwebremoting.util.JavascriptUtil;
import org.directwebremoting.util.LocalUtil;
import org.directwebremoting.util.Logger;
import org.directwebremoting.util.Messages;
import org.directwebremoting.util.MimeConstants;

/**
 * A Marshaller that output plain Javascript.
 * This marshaller can be tweaked to output Javascript in an HTML context.
 * This class works in concert with DirectScriptConduit, they should be
 * considered closely related and it is important to understand what one does
 * while editing the other.
 * @author Joe Walker [joe at getahead dot ltd dot uk]
 */
public class DwrpPlainJsMarshaller implements Marshaller
{
    /* (non-Javadoc)
     * @see org.directwebremoting.Marshaller#marshallInbound(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
    public Calls marshallInbound(HttpServletRequest request, HttpServletResponse response) throws IOException
    {
        // We must parse the parameters before we setup the conduit because it's
        // only after doing this that we know the scriptSessionId

        WebContext webContext = WebContextFactory.get();
        ParseResponse parseResponse = (ParseResponse) request.getAttribute(ATTRIBUTE_PARSE_RESPONSE);
        if (parseResponse == null)
        {
            parseResponse = parseRequest(request);

            // Save calls for retry exception
            request.setAttribute(ATTRIBUTE_PARSE_RESPONSE, parseResponse);
        }

        // Various bits of parseResponse need to be stashed away places
        storeParseResponse(request, webContext, parseResponse);

        Calls calls = parseResponse.getCalls();

        // Special case handling for long poll of the DWRSystem.poll() method.
        // If there is only 1 call and that call is a Poll, then we will wait until
        // there are scripts to send.   If there is more than 1 request, do not suspend
        // as it should not be held up by the poll.
        if (calls.getCallCount() == 1)
        {
            Call call = calls.getCall(0);
            if ("DWRSystem".equals(call.getScriptName()) && "poll".equals(call.getMethodName())) //$NON-NLS-1$ //$NON-NLS-2$
            {
                try
                {
                    DwrSystem system = (DwrSystem) webContext.getServletContext().getAttribute(call.getScriptName());
                    if (system != null)
                    {
                        system.pollPreStreamWait();
                    }
                }
                catch (Exception ex)
                {
                    // Allow Jetty RequestRetry exception to propogate to container
                    ContinuationUtil.rethrowIfContinuation(ex);
                    log.warn("Error calling pollWait()", ex); //$NON-NLS-1$
                }
            }
        }

        // Get the output stream and setup the mimetype
        response.setContentType(getOutboundMimeType());
        PrintWriter out;
        if (log.isDebugEnabled())
        {
            // This might be considered evil - altering the program flow
            // depending on the log status, however DebuggingPrintWriter is
            // very thin and only about logging
            out = new DebuggingPrintWriter("", response.getWriter()); //$NON-NLS-1$
        }
        else
        {
            out = response.getWriter();
        }

        // Save the output stream so the outbound marshaller can get at it
        request.setAttribute(ATTRIBUTE_REQUEST, out);

        // The conduit to pass on reverse ajax scripts
        DirectScriptConduit conduit = new DirectScriptConduit(out, this);
        request.setAttribute(ATTRIBUTE_CONDUIT, conduit);

        // Setup a debugging prefix
        if (out instanceof DebuggingPrintWriter)
        {
            DebuggingPrintWriter dpw = (DebuggingPrintWriter) out;
            dpw.setPrefix("out(" + conduit.hashCode() + "): "); //$NON-NLS-1$ //$NON-NLS-2$
        }

        // Send the script prefix (if any)
        sendOutboundScriptPrefix(out);

        // From the call to addScriptConduit() there could be 2 threads writing
        // to 'out' so we synchronize on 'out' to make sure there are no
        // clashes
        ScriptSession scriptSession = WebContextFactory.get().getScriptSession();
        scriptSession.addScriptConduit(conduit);

        // Debug the environment
        if (log.isDebugEnabled() && calls.getCallCount() > 0)
        {
            // We can just use 0 because they are all shared
            InboundContext inctx = (InboundContext) parseResponse.getInboundContexts().get(0);
            StringBuffer buffer = new StringBuffer();

            for (Iterator it = inctx.getInboundVariableNames(); it.hasNext();)
            {
                String key = (String) it.next();
                InboundVariable value = inctx.getInboundVariable(key);
                if (key.startsWith(ConversionConstants.INBOUND_CALLNUM_PREFIX) &&
                    key.indexOf(ConversionConstants.INBOUND_CALLNUM_SUFFIX + ConversionConstants.INBOUND_KEY_ENV) != -1)
                {
                    buffer.append(key + '=' + value.toString() + ", "); //$NON-NLS-1$
                }
            }

            if (buffer.length() > 0)
            {
                log.debug("Environment:  " + buffer.toString()); //$NON-NLS-1$
            }
        }

        callLoop:
        for (int callNum = 0; callNum < calls.getCallCount(); callNum++)
        {
            Call call = calls.getCall(callNum);
            InboundContext inctx = (InboundContext) parseResponse.getInboundContexts().get(callNum);

            // Get a list of the available matching methods with the coerced
            // parameters that we will use to call it if we choose to use
            // that method.
            Creator creator = creatorManager.getCreator(call.getScriptName());

            // Which method are we using?
            Method method = findMethod(call, inctx);
            call.setMethod(method);
            if (method == null)
            {
                String name = call.getScriptName() + '.' + call.getMethodName();
                throw new IllegalArgumentException(Messages.getString("DefaultRemoter.UnknownMethod", name)); //$NON-NLS-1$
            }

            // Check this method is accessible
            String reason = accessControl.getReasonToNotExecute(creator, call.getScriptName(), method);
            if (reason != null)
            {
                throw new SecurityException(Messages.getString("ExecuteQuery.AccessDenied")); //$NON-NLS-1$
            }

            // Convert all the parameters to the correct types
            Object[] params = new Object[method.getParameterTypes().length];
            for (int j = 0; j < method.getParameterTypes().length; j++)
            {
                try
                {
                    Class paramType = method.getParameterTypes()[j];
                    InboundVariable param = inctx.getParameter(callNum, j);
                    TypeHintContext incc = new TypeHintContext(converterManager, method, j);
                    params[j] = converterManager.convertInbound(paramType, param, inctx, incc);
                }
                catch (MarshallException ex)
                {
                    log.warn("Marshalling exception: " + ex.getMessage()); //$NON-NLS-1$

                    call.setMethod(null);
                    call.setParameters(null);
                    call.setException(ex);

                    continue callLoop;
                }
            }

            call.setParameters(params);
        }

        return calls;
    }

    /**
     * @param request
     * @param webContext
     * @param parseResponse
     */
    private void storeParseResponse(HttpServletRequest request, WebContext webContext, ParseResponse parseResponse)
    {
        webContext.setCurrentPageInformation(parseResponse.getPage(), parseResponse.getScriptSessionId());

        // Remaining parameters get put into the request for later consumption
        Map paramMap = parseResponse.getSpareParameters();
        if (paramMap.size() != 0)
        {
            for (Iterator it = paramMap.entrySet().iterator(); it.hasNext();)
            {
                Map.Entry entry = (Map.Entry) it.next();
                String key = (String) entry.getKey();
                String value = (String) entry.getValue();

                request.setAttribute(key, value);
                log.debug("Moved param to request: " + key + "=" + value); //$NON-NLS-1$ //$NON-NLS-2$
            }
        }
    }

    /**
     * Find the method the best matches the method name and parameters
     * @param call The function call we are going to make
     * @param inctx The data conversion context
     * @return A matching method, or null if one was not found.
     */
    private Method findMethod(Call call, InboundContext inctx)
    {
        if (call.getScriptName() == null)
        {
            throw new IllegalArgumentException(Messages.getString("DefaultRemoter.MissingClassParam")); //$NON-NLS-1$
        }

        if (call.getMethodName() == null)
        {
            throw new IllegalArgumentException(Messages.getString("DefaultRemoter.MissingMethodParam")); //$NON-NLS-1$
        }

        Creator creator = creatorManager.getCreator(call.getScriptName());
        Method[] methods = creator.getType().getMethods();
        List available = new ArrayList();

        methods:
        for (int i = 0; i < methods.length; i++)
        {
            // Check method name and access
            if (methods[i].getName().equals(call.getMethodName()))
            {
                // Check number of parameters
                if (methods[i].getParameterTypes().length == inctx.getParameterCount())
                {
                    // Clear the previous conversion attempts (the param types
                    // will probably be different)
                    inctx.clearConverted();

                    // Check parameter types
                    for (int j = 0; j < methods[i].getParameterTypes().length; j++)
                    {
                        Class paramType = methods[i].getParameterTypes()[j];
                        if (!converterManager.isConvertable(paramType))
                        {
                            // Give up with this method and try the next
                            continue methods;
                        }
                    }

                    available.add(methods[i]);
                }
            }
        }

        // Pick a method to call
        if (available.size() > 1)
        {
            log.warn("Warning multiple matching methods. Using first match."); //$NON-NLS-1$
        }

        if (available.isEmpty())
        {
            String name = call.getScriptName() + '.' + call.getMethodName();
            throw new IllegalArgumentException(Messages.getString("DefaultRemoter.UnknownMethod", name)); //$NON-NLS-1$
        }

        // At the moment we are just going to take the first match, for a
        // later increment we might pick the best implementation
        return (Method) available.get(0);
    }

    /* (non-Javadoc)
     * @see org.directwebremoting.Marshaller#marshallOutbound(org.directwebremoting.Replies, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
     */
    public void marshallOutbound(Replies replies, HttpServletRequest request, HttpServletResponse response) throws IOException
    {
        // We build the answer up in a StringBuffer because that makes is easier
        // to debug, and because that's only what the compiler does anyway.
        PrintWriter out = (PrintWriter) request.getAttribute(ATTRIBUTE_REQUEST);
        DirectScriptConduit conduit = (DirectScriptConduit) request.getAttribute(ATTRIBUTE_CONDUIT);

        ScriptSession scriptSession = WebContextFactory.get().getScriptSession();

        OutboundContext converted = new OutboundContext();
        for (int i = 0; i < replies.getReplyCount(); i++)
        {
            Reply reply = replies.getReply(i);

            // The existance of a throwable indicates that something went wrong
            if (reply.getThrowable() != null)
            {
                Throwable ex = reply.getThrowable();
                OutboundVariable ov = convertException(ex, converted);

                String script = ov.getInitCode() + "DWREngine._handleServerError('" + reply.getId() + "', " + ov.getAssignCode() + ");"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                sendScript(out, script);

                log.warn("--Erroring: id[" + reply.getId() + "] message[" + ex.toString() + ']'); //$NON-NLS-1$ //$NON-NLS-2$
            }
            else
            {
                Object data = reply.getReply();

                try
                {
                    OutboundVariable ov = converterManager.convertOutbound(data, converted);

                    String script = ov.getInitCode() + "DWREngine._handleResponse('" + reply.getId() + "', " + ov.getAssignCode() + ");"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    sendScript(out, script);
                }
                catch (MarshallException ex)
                {
                    OutboundVariable ov = convertException(ex, converted);

                    String script = ov.getInitCode() + "DWREngine._handleServerError('" + reply.getId() + "', " + ov.getAssignCode() + ");"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    sendScript(out, script);

                    log.warn("--MarshallException: id[" + reply.getId() + "] message[" + ex.toString() + ']'); //$NON-NLS-1$ //$NON-NLS-2$
                }
                catch (Exception ex)
                {
                    OutboundVariable ov = convertException(ex, converted);

                    String script = ov.getInitCode() + "DWREngine._handleServerError('" + reply.getId() + "', " + ov.getAssignCode() + ");"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    sendScript(out, script);

                    log.warn("--Erroring: id[" + reply.getId() + "] message[" + ex.toString() + ']', ex); //$NON-NLS-1$ //$NON-NLS-2$
                }
            }
        }

        scriptSession.removeScriptConduit(conduit);
        conduit.close();

        sendOutboundScriptSuffix(out);

        // log.debug(replyString);
    }

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91理论电影在线观看| 国产凹凸在线观看一区二区| 99久久国产综合精品色伊| 日韩欧美成人激情| 亚洲成av人**亚洲成av**| 91影院在线免费观看| 久久久久久**毛片大全| 久久精品国产免费| 欧美日韩国产高清一区二区| 亚洲色图欧洲色图| 国产成+人+日韩+欧美+亚洲| 日韩免费电影网站| 无码av免费一区二区三区试看| av在线不卡电影| 国产日韩欧美不卡| 国产一区二区三区黄视频| 欧美一级高清大全免费观看| 午夜不卡av在线| 欧美亚洲综合网| 一区二区三区不卡视频| 99久久精品情趣| 国产精品卡一卡二卡三| 国产在线精品视频| 精品国精品自拍自在线| 久久精品国产成人一区二区三区| 欧美精品久久一区二区三区| 亚洲国产日韩av| 在线亚洲一区观看| 亚洲另类色综合网站| 99久久99久久精品免费看蜜桃| 欧美国产视频在线| 日韩一级免费一区| 日本欧美在线看| 欧美一区二区三区四区在线观看| 偷拍日韩校园综合在线| 欧美日韩精品系列| 丝袜国产日韩另类美女| 在线观看91av| 日本美女一区二区三区视频| 日韩一区二区精品在线观看| 男女男精品视频网| 欧美mv日韩mv亚洲| 久久99国产乱子伦精品免费| 欧美va亚洲va香蕉在线| 狠狠色综合播放一区二区| 久久伊99综合婷婷久久伊| 国产精一品亚洲二区在线视频| 国产色综合一区| 成人久久视频在线观看| 亚洲色大成网站www久久九九| 91久久线看在观草草青青| 亚洲综合色成人| 欧美日韩国产高清一区二区 | 日韩三级视频在线看| 免费成人av在线播放| 久久女同精品一区二区| 成人av在线网站| 亚洲黄色片在线观看| 欧美日韩不卡一区二区| 美女视频一区在线观看| 久久久久一区二区三区四区| 成人美女视频在线看| 亚洲精品综合在线| 欧美一区二区三区色| 国产在线国偷精品产拍免费yy| 国产精品视频免费| 在线观看免费成人| 另类调教123区| 欧美国产1区2区| 一本久道中文字幕精品亚洲嫩| 成人激情动漫在线观看| 亚洲一区在线视频观看| 欧美一级精品在线| 高清不卡在线观看| 亚洲国产va精品久久久不卡综合| 日韩欧美国产一二三区| jvid福利写真一区二区三区| 亚洲一区二区三区在线| 精品国产乱码久久久久久夜甘婷婷| 成人激情免费视频| 日本美女一区二区三区| 中文字幕不卡在线观看| 欧美日韩国产在线观看| 黄一区二区三区| 一区二区国产视频| 2020日本不卡一区二区视频| 91在线精品一区二区三区| 石原莉奈一区二区三区在线观看| 国产亚洲精品久| 欧美日韩一卡二卡| 国产成人99久久亚洲综合精品| 亚洲午夜私人影院| 国产日本亚洲高清| 538prom精品视频线放| 国产v综合v亚洲欧| 日韩成人伦理电影在线观看| 国产精品久久久久久一区二区三区 | 日韩精品一二三四| 国产精品久久久久永久免费观看| 91精品国产综合久久小美女| 国产不卡视频在线观看| 亚洲国产你懂的| 中文字幕成人网| 欧美成人艳星乳罩| 欧美色图12p| 波多野结衣中文字幕一区二区三区| 天天操天天综合网| 最好看的中文字幕久久| 久久亚洲一级片| 91精品国产日韩91久久久久久| 国产精品色呦呦| 日韩三级电影网址| 欧美亚洲综合久久| 成人av影院在线| 国产在线精品一区二区三区不卡| 午夜欧美2019年伦理| 亚洲欧洲日韩一区二区三区| 精品国产伦理网| 8x福利精品第一导航| 在线精品国精品国产尤物884a| 成人精品免费视频| 韩国女主播一区| 免费一区二区视频| 亚洲成人自拍网| 亚洲欧美另类小说视频| 欧美激情资源网| 久久午夜老司机| 欧美成人a视频| 欧美一区二区女人| 欧美日韩高清一区二区三区| 色老汉一区二区三区| av激情综合网| 不卡的电影网站| 国产白丝网站精品污在线入口| 韩国av一区二区三区在线观看| 日本va欧美va精品发布| 午夜欧美视频在线观看| 亚洲成人你懂的| 亚洲午夜久久久久久久久电影网| 亚洲免费av观看| 日韩美女视频19| 亚洲三级免费观看| 综合电影一区二区三区| 中文字幕日韩精品一区| 国产精品伦理在线| 国产精品成人免费在线| 中文成人综合网| 国产精品美女久久久久av爽李琼| 欧美激情一区二区三区全黄| 日本一区二区视频在线| 欧美韩国日本综合| 国产精品乱子久久久久| 1000精品久久久久久久久| 日韩一区在线播放| 亚洲人午夜精品天堂一二香蕉| 国产精品高清亚洲| 亚洲欧美日韩中文字幕一区二区三区 | 91婷婷韩国欧美一区二区| 99麻豆久久久国产精品免费 | 色综合久久综合网97色综合| 色综合久久精品| 91美女视频网站| 欧美性大战久久久久久久蜜臀| 国产亚洲制服色| 国产精品理伦片| 一区二区三区日韩在线观看| 亚洲最新视频在线观看| 亚洲成人av电影在线| 美女一区二区三区| 国产成人一区二区精品非洲| 成人免费看片app下载| 一本色道久久综合亚洲精品按摩| 欧美视频完全免费看| 6080yy午夜一二三区久久| 精品国产污网站| 日本一区免费视频| 亚洲激情欧美激情| 日韩国产欧美三级| 韩国成人福利片在线播放| 成人三级伦理片| 色呦呦一区二区三区| 3d动漫精品啪啪1区2区免费| 精品久久久久一区二区国产| 日本一区二区三区电影| 伊人性伊人情综合网| 视频在线在亚洲| 国产高清精品在线| 在线日韩国产精品| 日韩精品一区二区三区视频播放| 国产视频911| 亚洲一区二区三区四区的| 秋霞电影网一区二区| 大胆欧美人体老妇| 欧美日韩精品一区二区天天拍小说| 日韩久久免费av| 综合精品久久久| 麻豆中文一区二区| av一本久道久久综合久久鬼色| 欧美高清性hdvideosex| 国产女同互慰高潮91漫画|