java - Inject the values with singleton scope using class name -


i new spring. class diagram this

public abstract class cache{     refreshcache() {       clearcache();       createcache();     }     clearcache();     createcache();     getname(); }  @component @scope("singleton") @qualifier("category") class category extends cache implements icategory{}  @component @scope("singleton") @qualifier("attr") class attr extends cache implements iattr{}  @component @scope("singleton") @qualifier("country") class country extends cache implements icountry{} 

by default scope of spring beans singleton. want create cache management service. reflection classes extends cache class cache singleton scope if instantiate them "new" getting new object other different object , other class inject following.

class {   @inject   country c }  class b {   @inject   attr attr } 

every injection using same cache if create "new" refresh not reflect them.

p.s. - main goal create class know classes extending cache class , given name (getname() function cache class) refresh respective cache. if spring have functionality enough.

"the main goal create class know classes extending cache class , given name (getname() function cache class)"

just create collection @autowired or @inject

@autowired list<cache> 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -