當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。