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


Java PortletSession类代码示例

本文整理汇总了Java中javax.portlet.PortletSession的典型用法代码示例。如果您正苦于以下问题:Java PortletSession类的具体用法?Java PortletSession怎么用?Java PortletSession使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getDescription

import javax.portlet.PortletSession; //导入依赖的package包/类
@Override
public String getDescription(boolean includeClientInfo) {
	PortletRequest request = getRequest();
	StringBuilder result = new StringBuilder();
	result.append("context=").append(request.getContextPath());
	if (includeClientInfo) {
		PortletSession session = request.getPortletSession(false);
		if (session != null) {
			result.append(";session=").append(session.getId());
		}
		String user = getRequest().getRemoteUser();
		if (StringUtils.hasLength(user)) {
			result.append(";user=").append(user);
		}
	}
	return result.toString();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:PortletWebRequest.java

示例2: registerPortletApplicationScopes

import javax.portlet.PortletSession; //导入依赖的package包/类
/**
 * Register web-specific scopes ("request", "session", "globalSession")
 * with the given BeanFactory, as used by the Portlet ApplicationContext.
 * @param bf the BeanFactory to configure
 * @param pc the PortletContext that we're running within
 */
static void registerPortletApplicationScopes(ConfigurableListableBeanFactory bf, PortletContext pc) {
	bf.registerScope(WebApplicationContext.SCOPE_REQUEST, new RequestScope());
	bf.registerScope(WebApplicationContext.SCOPE_SESSION, new SessionScope(false));
	bf.registerScope(WebApplicationContext.SCOPE_GLOBAL_SESSION, new SessionScope(true));
	if (pc != null) {
		PortletContextScope appScope = new PortletContextScope(pc);
		bf.registerScope(WebApplicationContext.SCOPE_APPLICATION, appScope);
		// Register as PortletContext attribute, for ContextCleanupListener to detect it.
		pc.setAttribute(PortletContextScope.class.getName(), appScope);
	}

	bf.registerResolvableDependency(PortletRequest.class, new RequestObjectFactory());
	bf.registerResolvableDependency(PortletResponse.class, new ResponseObjectFactory());
	bf.registerResolvableDependency(PortletSession.class, new SessionObjectFactory());
	bf.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:PortletApplicationContextUtils.java

示例3: setAttribute

import javax.portlet.PortletSession; //导入依赖的package包/类
@Override
public void setAttribute(String name, Object value, int scope) {
	if (scope == SCOPE_REQUEST) {
		if (!isRequestActive()) {
			throw new IllegalStateException(
					"Cannot set request attribute - request is not active anymore!");
		}
		this.request.setAttribute(name, value);
	}
	else {
		PortletSession session = getSession(true);
		if (scope == SCOPE_GLOBAL_SESSION) {
			session.setAttribute(name, value, PortletSession.APPLICATION_SCOPE);
			this.globalSessionAttributesToUpdate.remove(name);
		}
		else {
			session.setAttribute(name, value);
			this.sessionAttributesToUpdate.remove(name);
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:PortletRequestAttributes.java

示例4: removeAttribute

import javax.portlet.PortletSession; //导入依赖的package包/类
@Override
public void removeAttribute(String name, int scope) {
	if (scope == SCOPE_REQUEST) {
		if (isRequestActive()) {
			this.request.removeAttribute(name);
			removeRequestDestructionCallback(name);
		}
	}
	else {
		PortletSession session = getSession(false);
		if (session != null) {
			if (scope == SCOPE_GLOBAL_SESSION) {
				session.removeAttribute(name, PortletSession.APPLICATION_SCOPE);
				this.globalSessionAttributesToUpdate.remove(name);
			}
			else {
				session.removeAttribute(name);
				this.sessionAttributesToUpdate.remove(name);
			}
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:PortletRequestAttributes.java

示例5: getAttributeNames

import javax.portlet.PortletSession; //导入依赖的package包/类
@Override
public String[] getAttributeNames(int scope) {
	if (scope == SCOPE_REQUEST) {
		if (!isRequestActive()) {
			throw new IllegalStateException(
					"Cannot ask for request attributes - request is not active anymore!");
		}
		return StringUtils.toStringArray(this.request.getAttributeNames());
	}
	else {
		PortletSession session = getSession(false);
		if (session != null) {
			if (scope == SCOPE_GLOBAL_SESSION) {
				return StringUtils.toStringArray(session.getAttributeNames(PortletSession.APPLICATION_SCOPE));
			}
			else {
				return StringUtils.toStringArray(session.getAttributeNames());
			}
		}
		else {
			return new String[0];
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:25,代码来源:PortletRequestAttributes.java

示例6: handleActionRequest

import javax.portlet.PortletSession; //导入依赖的package包/类
@Override
public void handleActionRequest(ActionRequest request, ActionResponse response) throws Exception {
	// Delegate to PortletContentGenerator for checking and preparing.
	check(request, response);

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

	handleActionRequestInternal(request, response);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:AbstractController.java

示例7: handleRenderRequest

import javax.portlet.PortletSession; //导入依赖的package包/类
@Override
public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws Exception {
	// If the portlet is minimized and we don't want to render then return null.
	if (WindowState.MINIMIZED.equals(request.getWindowState()) && !this.renderWhenMinimized) {
		return null;
	}

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

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

	return handleRenderRequestInternal(request, response);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:AbstractController.java

示例8: testGlobalSessionScope

import javax.portlet.PortletSession; //导入依赖的package包/类
@Test
public void testGlobalSessionScope() {
	WebApplicationContext ac = initApplicationContext(WebApplicationContext.SCOPE_GLOBAL_SESSION);
	MockRenderRequest request = new MockRenderRequest();
	PortletRequestAttributes requestAttributes = new PortletRequestAttributes(request);
	RequestContextHolder.setRequestAttributes(requestAttributes);
	try {
		assertNull(request.getPortletSession().getAttribute(NAME, PortletSession.APPLICATION_SCOPE));
		DerivedTestBean bean = ac.getBean(NAME, DerivedTestBean.class);
		assertSame(bean, request.getPortletSession().getAttribute(NAME, PortletSession.APPLICATION_SCOPE));
		assertSame(bean, ac.getBean(NAME));
		request.getPortletSession().invalidate();
		assertTrue(bean.wasDestroyed());
	}
	finally {
		RequestContextHolder.setRequestAttributes(null);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:PortletApplicationContextScopeTests.java

示例9: setAttribute

import javax.portlet.PortletSession; //导入依赖的package包/类
@Override
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);
		}
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:MockPortletSession.java

示例10: serveResource

import javax.portlet.PortletSession; //导入依赖的package包/类
@Override
public void serveResource(ResourceRequest resourceRequest,
		ResourceResponse resourceResponse) throws IOException,
		PortletException {
	System.out.println("=====serveResource=======");
	String domainNo = ParamUtil.getString(resourceRequest, "domainNo");
	String administrationNo = ParamUtil.getString(resourceRequest,
			"administrationNo");
	PrintWriter pw = resourceResponse.getWriter();
	JSONObject juser = JSONFactoryUtil.createJSONObject();

	juser.put("domainNo", domainNo);
	juser.put("administrationNo", administrationNo);
	pw.println(juser.toString());
	PortletSession session = resourceRequest.getPortletSession();
	// PortletMode portletMode= resourceRequest.getPortletMode();
	// portletMode.s
	session.setAttribute("domainNo", domainNo);
	System.out.println(juser.toString());
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:21,代码来源:DossierProcPortlet.java

示例11: serveResource

import javax.portlet.PortletSession; //导入依赖的package包/类
@Override
public void serveResource(ResourceRequest resourceRequest,
		ResourceResponse resourceResponse) throws IOException,
		PortletException {
	System.out.println("=====serveResource=======");
	String domainNo = ParamUtil.getString(resourceRequest, "domainNo");
	String administrationNo = ParamUtil.getString(resourceRequest,
			"administrationNo");
	PrintWriter pw = resourceResponse.getWriter();
	JSONObject juser = JSONFactoryUtil.createJSONObject();

	juser.put("domainNo", domainNo);
	juser.put("administrationNo", administrationNo);
	pw.println(juser.toString());
	PortletSession session = resourceRequest.getPortletSession();
	session.setAttribute("domainNo", domainNo);
}
 
开发者ID:openegovplatform,项目名称:OEPv2,代码行数:18,代码来源:MenuListDomain.java

示例12: getIdsOfPaginatedFriends

import javax.portlet.PortletSession; //导入依赖的package包/类
private List<String> getIdsOfPaginatedFriends(RenderRequest request, RenderResponse response, PortletSession session,
        FacebookClientWrapper facebookClient) throws PortletException, IOException {
    // Count total number of friends
    Integer friendsCount = getFriendsCount(session, facebookClient);

    // Obtain number of current page
    Integer currentPage = getCurrentPageNumber(request, session);

    Integer indexStart = (currentPage - 1) * ITEMS_PER_PAGE;
    List<NamedFacebookType> friendsToDisplay = facebookClient.getPageOfFriends(indexStart, ITEMS_PER_PAGE);
    getPaginatorUrls(friendsCount, response);

    // Collect IDS of friends to display
    List<String> ids = new ArrayList<String>();
    for (NamedFacebookType current : friendsToDisplay) {
        ids.add(current.getId());
    }

    return ids;
}
 
开发者ID:exo-samples,项目名称:docs-samples,代码行数:21,代码来源:FacebookFriendsPortlet.java

示例13: setErrorMessage

import javax.portlet.PortletSession; //导入依赖的package包/类
public static void setErrorMessage(PortletRequest request, String errorMsg, Throwable t)
{
	if ( errorMsg == null ) errorMsg = "null";
	PortletSession pSession = request.getPortletSession(true);
	pSession.setAttribute("error.message",errorMsg);

	OutputStream oStream = new ByteArrayOutputStream();
	PrintStream pStream = new PrintStream(oStream);

	log.error("{}", oStream);
	log.error("{}", pStream);

	// errorMsg = errorMsg .replaceAll("<","&lt;").replaceAll(">","&gt;");

	StringBuffer errorOut = new StringBuffer();
	errorOut.append("<p class=\"portlet-msg-error\">\n");
	errorOut.append(FormattedText.escapeHtmlFormattedText(errorMsg));
	errorOut.append("\n</p>\n<!-- Traceback for this error\n");
	errorOut.append(oStream.toString());
	errorOut.append("\n-->\n");

	pSession.setAttribute("error.output",errorOut.toString());

	Map map = request.getParameterMap();
	pSession.setAttribute("error.map",map);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:27,代码来源:PortletHelper.java

示例14: debugPrint

import javax.portlet.PortletSession; //导入依赖的package包/类
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);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:20,代码来源:PortletHelper.java

示例15: processActionReset

import javax.portlet.PortletSession; //导入依赖的package包/类
public void processActionReset(String action,ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	// TODO: Check Role
	log.debug("Removing preferences....");
	clearSession(request);
	PortletSession pSession = request.getPortletSession(true);
	PortletPreferences prefs = request.getPreferences();
	try {
		prefs.reset("sakai.descriptor");
		for (String element : fieldList) {
			prefs.reset("imsti."+element);
			prefs.reset("sakai:imsti."+element);
		}
		log.debug("Preference removed");
	} catch (ReadOnlyException e) {
		setErrorMessage(request, rb.getString("error.modify.prefs")) ;
		return;
	}
	prefs.store();

	// Go back to the main edit page
	pSession.setAttribute("sakai.view", "edit");
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:25,代码来源:IMSBLTIPortlet.java


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