After login user data stored in the SessionScoped bean. I want to each 5 second get each account stored in the session and send to backend. My timer
@Singleton
@Startup
public class FrontendTimer {
@Inject
private UserContext userContext;
@Schedule(second = "*/5", minute = "*", hour = "*", persistent = false)
@Asynchronous
public void atSchedule() throws InterruptedException {
System.out.println("Get Logged user stored in the session each 5 seconds ");
System.out.println("FR " + userContext.getAccount().toString());
}
}
Only way to start the scheduler is create @Startup and @Singleton class. Only way to keep user data in the frontend, save account to SessionScoped CDI bean, JSF native beans deprecated.
You will get error like : WELD-001303: No active contexts for scope type javax.enterprise.context.SessionScoped
Project location here https://github.com/armdev/eap Class by itself https://github.com/armdev/eap/blob/master/eap-web/src/main/java/io/project/app/beans/FrontendTimer.java
Basically I want to have a standard timer who can get data from Session Scope.