java类javax.portlet.PortletSession的实例源码

PortletSessionImpl.java 文件源码 项目:portals-pluto 阅读 14 收藏 0 点赞 0 评论 0
public Enumeration<String> getAttributeNames(int scope) {
    // Return all attribute names in the nested HttpSession object.
    if (scope == PortletSession.APPLICATION_SCOPE) {
        return httpSession.getAttributeNames();
    }
    // Return attribute names with the portlet-scoped prefix.
    Vector<String> portletScopedNames = new Vector<String>();
    for (Enumeration<String> en = httpSession.getAttributeNames();
    en.hasMoreElements(); ) {
        String name = en.nextElement();
        if (isInCurrentPortletScope(name)) {
            portletScopedNames.add(
                    PortletSessionUtil.decodeAttributeName(name));
        }
    }
    return portletScopedNames.elements();

}
PortletHelper.java 文件源码 项目:sakai 阅读 14 收藏 0 点赞 0 评论 0
public static void debugPrint(PortletRequest request, String line)
{
    if ( line == null ) return;
    line = line.replaceAll("<","&lt;").replaceAll(">","&gt;");

    PortletSession pSession = request.getPortletSession(true);
    String debugOut = null;
    try {
        debugOut = (String) pSession.getAttribute("debug.print");
    } catch (Throwable t) {
        debugOut = null;
    }
    if ( debugOut == null ) {
        debugOut = line;
    } else {
        debugOut = debugOut + "\n" + line;
    }
    pSession.setAttribute("debug.print",debugOut);
}
MockPortletSession.java 文件源码 项目:class-guard 阅读 24 收藏 0 点赞 0 评论 0
public void setAttribute(String name, Object value, int scope) {
    if (scope == PortletSession.PORTLET_SCOPE) {
        if (value != null) {
            this.portletAttributes.put(name, value);
        }
        else {
            this.portletAttributes.remove(name);
        }
    }
    else if (scope == PortletSession.APPLICATION_SCOPE) {
        if (value != null) {
            this.applicationAttributes.put(name, value);
        }
        else {
            this.applicationAttributes.remove(name);
        }
    }
}
ExternalAppScopedAttributeTest.java 文件源码 项目:portals-pluto 阅读 14 收藏 0 点赞 0 评论 0
protected TestResult checkSetAppScopedAttributeElsewhereSeenHere(
        PortletSession session) {
    TestResult result = new TestResult();
    result.setDescription("Ensure application scoped attributes set "
            + "elsewhere in portlet session can be seen here.");

    Object value = session.getAttribute(EXT_KEY,
                                        PortletSession.APPLICATION_SCOPE);
    if (VALUE.equals(value)) {
        result.setReturnCode(TestResult.PASSED);
    } else {
        result.setReturnCode(TestResult.WARNING);
        result.setResultMessage("This test will not pass until you have "
                + "opened the external resource using the link provided below.");
    }
    return result;
}
FacesRequestAttributes.java 文件源码 项目:lams 阅读 20 收藏 0 点赞 0 评论 0
public static Object getAttribute(String name, ExternalContext externalContext) {
    Object session = externalContext.getSession(false);
    if (session instanceof PortletSession) {
        return ((PortletSession) session).getAttribute(name, PortletSession.APPLICATION_SCOPE);
    }
    else if (session != null) {
        return externalContext.getSessionMap().get(name);
    }
    else {
        return null;
    }
}
FacesRequestAttributes.java 文件源码 项目:lams 阅读 20 收藏 0 点赞 0 评论 0
public static void setAttribute(String name, Object value, ExternalContext externalContext) {
    Object session = externalContext.getSession(true);
    if (session instanceof PortletSession) {
        ((PortletSession) session).setAttribute(name, value, PortletSession.APPLICATION_SCOPE);
    }
    else {
        externalContext.getSessionMap().put(name, value);
    }
}
FacesRequestAttributes.java 文件源码 项目:lams 阅读 19 收藏 0 点赞 0 评论 0
public static void removeAttribute(String name, ExternalContext externalContext) {
    Object session = externalContext.getSession(false);
    if (session instanceof PortletSession) {
        ((PortletSession) session).removeAttribute(name, PortletSession.APPLICATION_SCOPE);
    }
    else if (session != null) {
        externalContext.getSessionMap().remove(name);
    }
}
FacesRequestAttributes.java 文件源码 项目:lams 阅读 21 收藏 0 点赞 0 评论 0
public static String[] getAttributeNames(ExternalContext externalContext) {
    Object session = externalContext.getSession(false);
    if (session instanceof PortletSession) {
        return StringUtils.toStringArray(
                ((PortletSession) session).getAttributeNames(PortletSession.APPLICATION_SCOPE));
    }
    else if (session != null) {
        return StringUtils.toStringArray(externalContext.getSessionMap().keySet());
    }
    else {
        return new String[0];
    }
}
PortletRequestAttributes.java 文件源码 项目:spring4-understanding 阅读 17 收藏 0 点赞 0 评论 0
/**
 * Exposes the {@link PortletSession} that we're wrapping.
 * @param allowCreate whether to allow creation of a new session if none exists yet
 */
protected final PortletSession getSession(boolean allowCreate) {
    if (isRequestActive()) {
        return this.request.getPortletSession(allowCreate);
    }
    else {
        // Access through stored session reference, if any...
        if (this.session == null && allowCreate) {
            throw new IllegalStateException(
                    "No session found and request already completed - cannot create new session!");
        }
        return this.session;
    }
}
PortletWrappingController.java 文件源码 项目:spring4-understanding 阅读 22 收藏 0 点赞 0 评论 0
@Override
public ModelAndView handleResourceRequest(
        ResourceRequest request, ResourceResponse response) throws Exception {

    if (!(this.portletInstance instanceof ResourceServingPortlet)) {
        throw new NoHandlerFoundException("Cannot handle resource request - target portlet [" +
                this.portletInstance.getClass() + " does not implement ResourceServingPortlet");
    }
    ResourceServingPortlet resourcePortlet = (ResourceServingPortlet) this.portletInstance;

    // Delegate to PortletContentGenerator for checking and preparing.
    checkAndPrepare(request, response);

    // Execute in synchronized block if required.
    if (isSynchronizeOnSession()) {
        PortletSession session = request.getPortletSession(false);
        if (session != null) {
            Object mutex = PortletUtils.getSessionMutex(session);
            synchronized (mutex) {
                resourcePortlet.serveResource(request, response);
                return null;
            }
        }
    }

    resourcePortlet.serveResource(request, response);
    return null;
}


问题


面经


文章

微信
公众号

扫码关注公众号