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
Post a Comment