I have an application-driven bean whose main purpose is to serve the rest of the application with less dynamic data, such as all available languages and a few more things.
ApplicationController
@ManagedBean(eager=true)
@ApplicationScoped
public class ApplicationController implements Serializable {
private static final long serialVersionUID = 25488214212L;
private List<Language> languages;
private Map<Language, List<LevelDescription>> descriptionsPersonal;
private Map<Language, List<LevelDescription>> descriptionsTechnical;
private List<Integer> levels = new ArrayList<Integer>();
@EJB private LanguageDao languageDao;
@EJB private LevelDescriptionDao levelDescriptionDao;
@EJB private IntraConnectionBean intraBean;
@EJB private ApplicationBean appBean;
public ApplicationController() {
}
@PostConstruct
public void init(){
languages = languageDao.findAll();
descriptionsTechnical = new HashMap<Language, List<LevelDescription>>();
descriptionsPersonal = new HashMap<Language, List<LevelDescription>>();
for(int i = 0; i < 6; i++)
levels.add(i);
for(Language l : languages){
List<LevelDescription> desc = levelDescriptionDao.findAll(l, true);
if(!desc.isEmpty())
descriptionsTechnical.put(l, desc);
desc = levelDescriptionDao.findAll(l, false);
if(!desc.isEmpty())
descriptionsPersonal.put(l, desc);
}
}
public List<Language> getLanguages(){
if(lang)
return languages;
}
public List<LevelDescription> getTechnicalItems(Language lang) {
return descriptionsTechnical.get(lang);
}
public List<LevelDescription> getPersonalItems(Language lang) {
return descriptionsPersonal.get(lang);
}
public List<Integer> getLevels(){
return levels;
}
}
It seems to be working fine. Some time. When I leave the application alone for a while, maybe for an hour, I get extremely strange behavior. The get-get methods either start returning empty collections or return collections with objects that seem correct but do not work with selectOneMenus publishing. Redeployment makes it work again, which also makes the experiment more difficult, since enabling debug mode will make it work again by redistributing.
? , , , , dev- . EJB , , . ?
, , , - , beans. .