java - Specific instance/Non Singleton -


how instantiate java class parameters , use same instance through out application?

what want when tibco esb requests web service call application,i capture user information(user name) in 1 pojo class can use pojo class , user information @ other places in application particular tibco request.

this question might sounds crazy implement in application.waiting thoughts guys.

you can use threadlocal solution:

public class myclassinstanceholder {     private static threadlocal<myclass> instance = new threadlocal<>();      public static setinstance(myclass instance) {         instance.set(instance);     }     public static myclass getinstance() {         instance.get();     } } ... myclass myinstance = myclassinstanceholder.getinstance(); 

so in thread you'll have access object stored in threadlocal.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -