当前位置: 首页>>代码示例>>Java>>正文


Java WebContext.getServletContext方法代码示例

本文整理汇总了Java中org.directwebremoting.WebContext.getServletContext方法的典型用法代码示例。如果您正苦于以下问题:Java WebContext.getServletContext方法的具体用法?Java WebContext.getServletContext怎么用?Java WebContext.getServletContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.directwebremoting.WebContext的用法示例。


在下文中一共展示了WebContext.getServletContext方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: convertInbound

import org.directwebremoting.WebContext; //导入方法依赖的package包/类
public Object convertInbound(Class paramType, InboundVariable iv, InboundContext inctx)
{
    WebContext webcx = WebContextFactory.get();

    if (HttpServletRequest.class.isAssignableFrom(paramType))
    {
        return webcx.getHttpServletRequest();
    }

    if (HttpServletResponse.class.isAssignableFrom(paramType))
    {
        return webcx.getHttpServletResponse();
    }

    if (ServletConfig.class.isAssignableFrom(paramType))
    {
        return webcx.getServletConfig();
    }

    if (ServletContext.class.isAssignableFrom(paramType))
    {
        return webcx.getServletContext();
    }

    if (HttpSession.class.isAssignableFrom(paramType))
    {
        return webcx.getSession(true);
    }

    return null;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:32,代码来源:ServletConverter.java

示例2: Publisher

import org.directwebremoting.WebContext; //导入方法依赖的package包/类
/**
 * Create a new publish thread and start it
 */
public Publisher()
{
    WebContext webContext = WebContextFactory.get();
    ServletContext servletContext = webContext.getServletContext();

    serverContext = ServerContextFactory.get(servletContext);

    // A bit nasty: the call to serverContext.getScriptSessionsByPage()
    // below could fail because the system might need to read web.xml which
    // means it needs a ServletContext, which is only available  using
    // WebContext, which in turn requires a DWR thread. We can cache the
    // results simply by calling this in a DWR thread, as we are now.
    webContext.getScriptSessionsByPage("");

    synchronized (Publisher.class)
    {
        if (worker == null)
        {
            worker = new Thread(this, "Publisher");
            worker.start();
        }
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:Publisher.java

示例3: getServletContext

import org.directwebremoting.WebContext; //导入方法依赖的package包/类
/**
 * Gets the servlet context from the current web context, if one exists,
 * otherwise gets it from the thread-local stash.
 */
static ServletContext getServletContext()
{
    WebContext webcx = WebContextFactory.get();
    if (webcx != null)
    {
        return webcx.getServletContext();
    }
    else
    {
        return servletContexts.get().getFirst();
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:17,代码来源:DwrGuiceUtil.java

示例4: getServletContext

import org.directwebremoting.WebContext; //导入方法依赖的package包/类
/**
 * Gets the servlet context from the thread-local stash, if any,
 * otherwise from the current web context, if one exists,
 * otherwise from the singleton server context, if it exists,
 * otherwise from the first of all server contexts, if there are any,
 * otherwise null.
 */
public static ServletContext getServletContext()
{
    LinkedList<ServletContext> sclist = servletContexts.get();
    if (!sclist.isEmpty())
    {
        return sclist.getFirst();
    }

    WebContext webcx = WebContextFactory.get();
    if (webcx != null)
    {
        return webcx.getServletContext();
    }

    ServerContext serverContext = StartupUtil.getSingletonServerContext();
    if (serverContext != null)
    {
        return serverContext.getServletContext();
    }

    for (ServerContext sc : StartupUtil.getAllServerContexts())
    {
        // Use the ServletContext of the first ServerContext we see.
        return sc.getServletContext();
    }

    return null;
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:36,代码来源:DwrGuiceUtil.java

示例5: convertInbound

import org.directwebremoting.WebContext; //导入方法依赖的package包/类
public Object convertInbound(Class<?> paramType, InboundVariable data)
{
    WebContext webcx = WebContextFactory.get();

    if (HttpServletRequest.class.isAssignableFrom(paramType))
    {
        return webcx.getHttpServletRequest();
    }

    if (HttpServletResponse.class.isAssignableFrom(paramType))
    {
        return webcx.getHttpServletResponse();
    }

    if (ServletConfig.class.isAssignableFrom(paramType))
    {
        return webcx.getServletConfig();
    }

    if (ServletContext.class.isAssignableFrom(paramType))
    {
        return webcx.getServletContext();
    }

    if (HttpSession.class.isAssignableFrom(paramType))
    {
        return webcx.getSession(true);
    }

    return null;
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:32,代码来源:ServletConverter.java

示例6: normalizePage

import org.directwebremoting.WebContext; //导入方法依赖的package包/类
public String normalizePage(String unnormalized)
{
    synchronized (initLock)
    {
        if (welcomeFiles == null)
        {
            if (servletContext != null)
            {
                welcomeFiles = getWebXmlWelcomeFileList(servletContext);
            }
            else
            {
                WebContext webContext = WebContextFactory.get();
                if (webContext == null)
                {
                    log.warn("Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults.");
                    log.warn(" - To prevent this message from happening, either call the PageNormalizer from a DWR thread");
                    log.warn(" - Or seed the PageNormalizer with a ServletContext before access from outside a DWR thread");
                }
                else
                {
                    ServletContext threadServletContext = webContext.getServletContext();
                    welcomeFiles = getWebXmlWelcomeFileList(threadServletContext);
                }
            }
        }

        if (welcomeFiles == null)
        {
            log.debug("Using default welcome file list (index.[jsp|htm[l]])");
            welcomeFiles = getDefaultWelcomeFileList();
        }
    }

    if (unnormalized == null)
    {
        return null;
    }

    String normalized = unnormalized;

    if (!normalizeIncludesQueryString)
    {
        int queryPos = normalized.indexOf('?');
        if (queryPos != -1)
        {
            normalized = normalized.substring(0, queryPos);
        }
    }

    for (Iterator it = welcomeFiles.iterator(); it.hasNext();)
    {
        String welcomeFile = (String) it.next();
        if (normalized.endsWith(welcomeFile))
        {
            normalized = normalized.substring(0, normalized.length() - welcomeFile.length());
            break;
        }
    }

    return normalized;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:63,代码来源:DefaultPageNormalizer.java

示例7: normalizePage

import org.directwebremoting.WebContext; //导入方法依赖的package包/类
public String normalizePage(String unnormalized)
{
    synchronized (initLock)
    {
        if (welcomeFiles == null)
        {
            if (servletContext != null)
            {
                welcomeFiles = getWebXmlWelcomeFileList(servletContext);
            }
            else
            {
                WebContext webContext = WebContextFactory.get();
                if (webContext == null)
                {
                    log.warn("Can't find ServletContext to check for <welcome-file-list> in web.xml. Assuming defaults.");
                    log.warn(" - To prevent this message from happening, either call the PageNormalizer from a DWR thread");
                    log.warn(" - Or seed the PageNormalizer with a ServletContext before access from outside a DWR thread");
                }
                else
                {
                    ServletContext threadServletContext = webContext.getServletContext();
                    welcomeFiles = getWebXmlWelcomeFileList(threadServletContext);
                }
            }
        }

        if (welcomeFiles == null)
        {
            log.debug("Using default welcome file list (index.[jsp|htm[l]])");
            welcomeFiles = getDefaultWelcomeFileList();
        }
    }

    if (unnormalized == null)
    {
        return null;
    }

    String normalized = unnormalized;

    if (!normalizeIncludesQueryString)
    {
        int queryPos = normalized.indexOf('?');
        if (queryPos != -1)
        {
            normalized = normalized.substring(0, queryPos);
        }
    }

    if (!normalizeIncludesSessionID)
    {
        final Pattern p = Pattern.compile(
            "([^;\\?#]+)" // group 1: protocol, host, and path (up to first of ; ? or #)
            + ";[^\\?#]+" // sessionid (up to first of ? or #)
            + "(.*)"); // group 2: remainder (any ? or # segments)
        Matcher m = p.matcher(normalized);
        if (m.matches())
        {
            // Concatenate the parts without sessionid
            normalized = m.group(1) + m.group(2);
        }
    }

    for (String welcomeFile : welcomeFiles)
    {
        if (normalized.endsWith(welcomeFile))
        {
            normalized = normalized.substring(0, normalized.length() - welcomeFile.length());
            break;
        }
    }

    return normalized;
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:76,代码来源:DefaultPageNormalizer.java


注:本文中的org.directwebremoting.WebContext.getServletContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。