• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Map across application

 
Navin Pillu
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

We are using Spring 3.0. Here we want to use a HashMap. We want to initialize it when application loads at 1st time. Also it is modifiable at any time from any class. The modification should be available to all other classes across application whoever will use it.

Can any one suggest suitable strategy

Thanks
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can define a Map as a @Bean if you wish. But you can not use @Autowire to wire it into your beans, you must use @Resource or @Inject. This is due to the semantics of @Autowired. See https://jira.springsource.org/browse/SPR-8519

Note that HashMap is not thread safe. You might want to consider ConcurrentHashMap
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic