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


Java PortletContext.setAttribute方法代码示例

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


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

示例1: registerPortletApplicationScopes

import javax.portlet.PortletContext; //导入方法依赖的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

示例2: registerPortletApplicationScopes

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

	beanFactory.registerResolvableDependency(PortletRequest.class, new RequestObjectFactory());
	beanFactory.registerResolvableDependency(PortletSession.class, new SessionObjectFactory());
	beanFactory.registerResolvableDependency(WebRequest.class, new WebRequestObjectFactory());
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:22,代码来源:PortletApplicationContextUtils.java

示例3: checkSetAttribute

import javax.portlet.PortletContext; //导入方法依赖的package包/类
protected TestResult checkSetAttribute(PortletContext context) {
    TestResult res = new TestResult();
    res.setName("Set Attribute Test");
    res.setDescription("Sets and retrieves portlet contextuest attribute.");

    context.setAttribute(KEY, VAL);
    Object val = context.getAttribute(KEY);
    if(!VAL.equals(val)) {
        res.setReturnCode(TestResult.FAILED);
        res.setResultMessage("Retrieved value: '"+val+"' - Expected '"+VAL+"'");
    }
    else {
        res.setReturnCode(TestResult.PASSED);
    }

    context.removeAttribute(KEY);
    return res;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:19,代码来源:SimpleAttributeTest.java

示例4: checkRemoveAttribute

import javax.portlet.PortletContext; //导入方法依赖的package包/类
protected TestResult checkRemoveAttribute(PortletContext context) {
    TestResult res = new TestResult();
    res.setName("Remove Context Attribute Test");
    res.setDescription("Sets, removes and retrieves portlet request attribute.");

    context.setAttribute(KEY, VAL);
    context.removeAttribute(KEY);
    Object val = context.getAttribute(KEY);
    if(val!=null) {
        res.setReturnCode(TestResult.FAILED);
        res.setResultMessage("Retrieved value: '"+val+"' - Expected '"+VAL+"'");
    }
    else {
        res.setReturnCode(TestResult.PASSED);
    }

    return res;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:19,代码来源:SimpleAttributeTest.java

示例5: checkEnumerateAttributesInContext

import javax.portlet.PortletContext; //导入方法依赖的package包/类
protected TestResult checkEnumerateAttributesInContext(
		PortletContext context) {
    TestResult result = new TestResult();
    result.setDescription("Sets attributes in portlet context "
    		+ "and enumerates over them.");

    int count = 5;
    for (int i = 0; i < count; i++) {
    	context.setAttribute(KEY + "." + i, VAL);
    }

    int found = 0;
    for (Enumeration<?> en = context.getAttributeNames();
    		en.hasMoreElements(); ) {
        if (en.nextElement().toString().startsWith(KEY)) {
            found++;
        }
    }

    if (count == found) {
    	result.setReturnCode(TestResult.PASSED);
    } else {
    	result.setReturnCode(TestResult.FAILED);
    	result.setResultMessage("Expected " + count + " attributes. "
    			+ "Found " + found);
    }
    return result;
}
 
开发者ID:apache,项目名称:portals-pluto,代码行数:29,代码来源:SimpleAttributeTest.java


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