java - Lookup with InitialContext lookup() and @Inject of Singleton -


i have @singleton bean use store state shared other beans/threads. state shared maintained in hashmap. other beans require services of singleton @inject , invoke methods.

recently, had introduce quartz scheduler since had asynchronous jobs done. in 1 quartz job lookup singleton using intialcontext lookup(), , use methods provided singleton. once job executes, other beans use @inject (for singleton) no longer information maintained in hashmap.

@singleton(mappedname = "clientsessionmgr") public class clientsessionmgr {      private final map<string, clientsession> clientsessions = new hashmap<string, clientsession>();      /* methods manage clientsessions data */ } 

one amongst few beans inject above singleton.

@stateless(mappedname = "nwdcredprofrepo") public class nwdcredprofrepo {    @inject private clientsessionmgr csm;    /* bean methods invoke methods of singleton */ } 

the quartz job lookup of singleton , uses methods provided same.

public class clientsyncprobe implements job {   private clientsessionmgr csm;    @override   public void execute(jobexecutioncontext jec) throws jobexecutionexception {       initialcontent ic = new initialcontext();       csm = (clientsessionmgr) ic.lookup("java:app/svweb/clientsessionmgr");        /* tasks, , */       ic.close()   } } 

i guessing missing pattern principle. help?


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - How to Hide Date Menu from Datepicker in yii2 -