Recently, I'm learning about JEE7 websocket api, then I run a demo on newest Tomcat server, but I've found that the annotation @javax.inject.Singleton
doesn't work, here's the demo code posted in Jiji_Sasidharan's blog: demo code
it work's well in glassfish4 server, but if run in Tomcat, ChatServerEndPoint
instance won't be singleton, but an instance per client(peer), indicates that @Singleton doesn't work at all.
if I want to achieve the same result as it run on glassfish, I have to change the modifier of field : Set<Session> userSessions
to : static Set<Session> userSessions
.
in Chapter 6 session 1 of Tyrus(open source JSR 356) documentation
can anybody explain why, pls help, tks!