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


Java SessionScoped类代码示例

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


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

示例1: applyBeforeFeatureConfig

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
void applyBeforeFeatureConfig(Class testClass) {
    CdiContainer container = CdiContainerLoader.getCdiContainer();

    if (!isContainerStarted()) {
        container.boot(CdiTestSuiteRunner.getTestContainerConfig());
        containerStarted = true;
        bootExternalContainers(testClass);
    }

    List<Class<? extends Annotation>> restrictedScopes = new ArrayList<Class<? extends Annotation>>();

    //controlled by the container and not supported by weld:
    restrictedScopes.add(ApplicationScoped.class);
    restrictedScopes.add(Singleton.class);

    if (this.parent == null && this.testControl.getClass().equals(TestControlLiteral.class)) {
        //skip scope-handling if @TestControl isn't used explicitly on the test-class -> TODO re-visit it
        restrictedScopes.add(RequestScoped.class);
        restrictedScopes.add(SessionScoped.class);
    }

    this.previousProjectStage = ProjectStageProducer.getInstance().getProjectStage();
    ProjectStageProducer.setProjectStage(this.projectStage);

    startScopes(container, testClass, null, restrictedScopes.toArray(new Class[restrictedScopes.size()]));
}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:27,代码来源:CdiCucumberTestRunner.java

示例2: processClaimValueInjections

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
void processClaimValueInjections(@Observes ProcessInjectionPoint pip) {
    log.debugf("pipRaw: %s", pip.getInjectionPoint());
    InjectionPoint ip = pip.getInjectionPoint();
    if (ip.getAnnotated().isAnnotationPresent(Claim.class) && ip.getType() instanceof Class) {
        Class rawClass = (Class) ip.getType();
        if (Modifier.isFinal(rawClass.getModifiers())) {
            Claim claim = ip.getAnnotated().getAnnotation(Claim.class);
            rawTypes.add(ip.getType());
            rawTypeQualifiers.add(claim);
            log.debugf("+++ Added Claim raw type: %s", ip.getType());
            Class declaringClass = ip.getMember().getDeclaringClass();
            Annotation[] appScoped = declaringClass.getAnnotationsByType(ApplicationScoped.class);
            Annotation[] sessionScoped = declaringClass.getAnnotationsByType(SessionScoped.class);
            if ((appScoped != null && appScoped.length > 0) || (sessionScoped != null && sessionScoped.length > 0)) {
                String err = String.format("A raw type cannot be injected into application/session scope: IP=%s", ip);
                pip.addDefinitionError(new DeploymentException(err));
            }

        }
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:22,代码来源:MPJWTExtension.java

示例3: startAsynchronous

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
/**
 * Does actually not work
 */
@Override
@Asynchronous
public void startAsynchronous(final IWorkflowListener listener)
{
	try
	{
		CdiContextAwareRunnable runnable = new CdiContextAwareRunnable(this.newWorkflowRunnable(listener));
		// runnable.addContext(RequestScoped.class);
		runnable.addContext(SessionScoped.class);
		// runnable.addContext(ApplicationScoped.class);
		runnable.addContext(ConversationScoped.class);

		runnable.run();
	}
	catch (WorkflowException e)
	{
		LOG.error(e.getMessage(), e);
	}
}
 
开发者ID:sebfz1,项目名称:wicket-quickstart-cdi-async,代码行数:23,代码来源:WorkflowBean.java

示例4: scope

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
public Class<? extends Annotation> scope() {
    if (null == scope) {
        synchronized (this) {
            if (null == scope) {
                Class<?> c = getClass();
                if (c.isAnnotationPresent(RequestScoped.class)) {
                    scope = RequestScoped.class;
                } else if (c.isAnnotationPresent(SessionScoped.class)) {
                    scope = SessionScoped.class;
                } else if (c.isAnnotationPresent(ApplicationScoped.class)) {
                    scope = ApplicationScoped.class;
                } else {
                    scope = NormalScope.class;
                }
            }
        }
    }
    return scope;
}
 
开发者ID:actframework,项目名称:actframework,代码行数:20,代码来源:DestroyableBase.java

示例5: checkDependentScope

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
/**
 * Checks if a custom resolver method injected parameter scope is {@link Dependent}
 * 
 * @param type
 *            The parameter type being checked
 * @return Returns true if the paraeter scope is {@link Dependent}
 */
private boolean checkDependentScope(Class<?> type) {
    for (Annotation annotation : type.getAnnotations()) {
        if (annotation.annotationType().equals(SessionScoped.class) || annotation.annotationType().equals(RequestScoped.class)
                || annotation.annotationType().equals(ApplicationScoped.class)) {
            return false;
        }
        Class<?> viewScopedClass = null;
        try {
            // Account for JEE 7 @ViewScoped scope
            viewScopedClass = Class.forName("javax.faces.view.ViewScoped");
        } catch (Exception e) {
            // JEE 6 environment
            if (logger.isDebugEnabled()) {
                logger.debug("Class javax.faces.view.ViewScoped was not found: Running in a Java EE 6 environment.");
            }
        }
        if (viewScopedClass != null) {
            if (annotation.annotationType().equals(viewScopedClass)) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:gonmarques,项目名称:cdi-properties,代码行数:32,代码来源:DependentResolverMethodParametersVerifier.java

示例6: beforeStopApplication

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
public void beforeStopApplication(Object endObject)
{
    WebBeansContext webBeansContext = getWebBeansContext();
    ContextsService contextsService = webBeansContext.getContextsService();
    contextsService.endContext(Singleton.class, null);
    contextsService.endContext(ApplicationScoped.class, null);
    contextsService.endContext(RequestScoped.class, null);
    contextsService.endContext(SessionScoped.class, mockHttpSession);

    ELContextStore elStore = ELContextStore.getInstance(false);
    if (elStore == null)
    {
        return;
    }
    elStore.destroyELContextStore();
}
 
开发者ID:HotswapProjects,项目名称:HotswapAgent,代码行数:17,代码来源:HAOpenWebBeansTestLifeCycle.java

示例7: doReinjectSessionBasedBean

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
private static void doReinjectSessionBasedBean(BeanManagerImpl beanManager, Class<?> beanClass, AbstractClassBean<?> bean) {
    Map<Class<? extends Annotation>, List<Context>> contexts = getContexts(beanManager);
    List<Context> contextList = contexts.get(SessionScoped.class);

    if (contextList != null && !contextList.isEmpty()) {
        for (Context ctx: contextList) {
            Context sessionCtx = PassivatingContextWrapper.unwrap(ctx);
            if (sessionCtx instanceof HttpSessionContextImpl) {
                doReinjectHttpSessionBasedBean(beanManager, beanClass, bean, (HttpSessionContextImpl) sessionCtx);
            } else if (sessionCtx instanceof BoundSessionContextImpl) {
                doReinjectBoundSessionBasedBean(beanManager, beanClass, bean, (BoundSessionContextImpl) sessionCtx);
            } else if (sessionCtx instanceof HttpSessionDestructionContext) {
                // HttpSessionDestructionContext is temporary used for HttpSession context destruction, we don't handle it
            } else {
                LOGGER.warning("Unexpected session context class '{}'.", sessionCtx.getClass().getName());
            }
        }
    } else {
        LOGGER.warning("No session context found in BeanManager.");
    }
}
 
开发者ID:HotswapProjects,项目名称:HotswapAgent,代码行数:22,代码来源:BeanReloadExecutor.java

示例8: sessionCreated

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void sessionCreated(final HttpSessionEvent event) {
    try {
        if (logger.isDebugEnabled()) {
            logger.debug("Starting a session with session id : [{0}]", event.getSession().getId());
        }
        if (webBeansContext instanceof WebappWebBeansContext) { // start before child
            ((WebappWebBeansContext) webBeansContext).getParent().getContextsService().startContext(SessionScoped.class, event.getSession());
        }
        contextsService.startContext(SessionScoped.class, event.getSession());
    } catch (final Exception e) {
        logger.error(OWBLogConst.ERROR_0020, event.getSession());
        WebBeansUtil.throwRuntimeExceptions(e);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:19,代码来源:BeginWebBeansListener.java

示例9: ensureRequestContextCanBeRestarted

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
@Test
public void ensureRequestContextCanBeRestarted() throws Exception {
    final ApplicationComposers composers = new ApplicationComposers(EnsureRequestScopeThreadLocalIsCleanUpTest.class);
    composers.before(this);
    final CdiAppContextsService contextsService = CdiAppContextsService.class.cast(WebBeansContext.currentInstance().getService(ContextsService.class));
    final Context req1 = contextsService.getCurrentContext(RequestScoped.class);
    assertNotNull(req1);
    final Context session1 = contextsService.getCurrentContext(SessionScoped.class);
    assertNotNull(session1);
    contextsService.endContext(RequestScoped.class, null);
    contextsService.startContext(RequestScoped.class, null);
    final Context req2 = contextsService.getCurrentContext(RequestScoped.class);
    assertNotSame(req1, req2);
    final Context session2 = contextsService.getCurrentContext(SessionScoped.class);
    assertSame(session1, session2);
    composers.after();
    assertNull(contextsService.getCurrentContext(RequestScoped.class));
    assertNull(contextsService.getCurrentContext(SessionScoped.class));
}
 
开发者ID:apache,项目名称:tomee,代码行数:20,代码来源:EnsureRequestScopeThreadLocalIsCleanUpTest.java

示例10: addScopesForDefaultBehavior

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
private void addScopesForDefaultBehavior(List<Class<? extends Annotation>> scopeClasses)
{
    if (this.parent != null && !this.parent.isScopeStarted(RequestScoped.class))
    {
        if (!scopeClasses.contains(RequestScoped.class))
        {
            scopeClasses.add(RequestScoped.class);
        }
    }
    if (this.parent != null && !this.parent.isScopeStarted(SessionScoped.class))
    {
        if (!scopeClasses.contains(SessionScoped.class))
        {
            scopeClasses.add(SessionScoped.class);
        }
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:18,代码来源:CdiTestRunner.java

示例11: startContexts

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
@Override
public void startContexts()
{
    wrapped.startContexts();

    if (isManualScopeHandling())
    {
        for (ExternalContainer externalContainer : CdiTestRunner.getActiveExternalContainers())
        {
            externalContainer.startScope(Singleton.class);
            externalContainer.startScope(ApplicationScoped.class);
            externalContainer.startScope(RequestScoped.class);
            externalContainer.startScope(SessionScoped.class);
            externalContainer.startScope(ConversationScoped.class);
        }
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:18,代码来源:ContextControlDecorator.java

示例12: stopContexts

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
@Override
public void stopContexts()
{
    if (isManualScopeHandling())
    {
        for (ExternalContainer externalContainer : CdiTestRunner.getActiveExternalContainers())
        {
            externalContainer.stopScope(ConversationScoped.class);
            externalContainer.stopScope(SessionScoped.class);
            externalContainer.stopScope(RequestScoped.class);
            externalContainer.stopScope(ApplicationScoped.class);
            externalContainer.stopScope(Singleton.class);
        }
    }

    wrapped.stopContexts();
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:18,代码来源:ContextControlDecorator.java

示例13: startScope

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
@Override
public void startScope(Class<? extends Annotation> scopeClass)
{
    if (RequestScoped.class.equals(scopeClass))
    {
        initRequest();
        initResponse();

        initFacesContext();

        initDefaultView();
    }
    else if (SessionScoped.class.equals(scopeClass))
    {
        initSession();
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:18,代码来源:MockedJsf2TestContainer.java

示例14: stopScope

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
@Override
public void stopScope(Class<? extends Annotation> scopeClass)
{
    if (RequestScoped.class.equals(scopeClass))
    {
        if (this.facesContext != null)
        {
            this.facesContext.release();
        }
        this.facesContext = null;
        this.request = null;
        this.response = null;
    }
    else if (SessionScoped.class.equals(scopeClass))
    {
        this.session = null;
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:19,代码来源:MockedJsf2TestContainer.java

示例15: startContext

import javax.enterprise.context.SessionScoped; //导入依赖的package包/类
@Override
public void startContext(Class<? extends Annotation> scopeClass)
{
    if (scopeClass.isAssignableFrom(ApplicationScoped.class))
    {
        startApplicationScope();
    }
    else if (scopeClass.isAssignableFrom(SessionScoped.class))
    {
        startSessionScope();
    }
    else if (scopeClass.isAssignableFrom(RequestScoped.class))
    {
        startRequestScope();
    }
    else if (scopeClass.isAssignableFrom(ConversationScoped.class))
    {
        startConversationScope();
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:21,代码来源:OpenWebBeansContextControl.java


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