开发者

CDI session scoped bean is created only one time also if the user access from two different browser

开发者 https://www.devze.com 2023-03-16 04:24 出处:网络
i have a strange behaviour i\'m seeing that if the user access to session bean from two different browser, the istance of session bean is the same.In my opinion this is an unespected behaviour.

i have a strange behaviour i'm seeing that if the user access to session bean from two different browser, the istance of session bean is the same. In my opinion this is an unespected behaviour. Someone have solved the same problem? I'm using Jsf 2.0, Spring 3.0.5, Hibernate and like WebServer Glassfish. Thank you in advance.

Update

import model.entity.Utente;
import java.io开发者_开发百科.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

/**
 *
 * @author 
 */
@Named
@SessionScoped
public class SessionBean implements Serializable {

this is how i declare CDI session bean


I guess the bean is managed by Spring not by CDI. (If you want to use CDI with Spring you need to do a lot of work, only using javax.inject.Named is not enougth.)

Spring knows javax.inject.Named but not javax.enterprise.context.SessionScoped. To make a Spring Bean Session scoped, you need @org.springframework.context.annotation.Scope("session").

@see also: Spring Reference Chapter 3.5.4 Request, session, and global session scopes

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号