Announcement Announcement Module
Collapse
No announcement yet.
How to load data during startup - design question? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to load data during startup - design question?

    I am new to tomcat and spring, so thanks in advance for being polite.

    I will have to parse a fairly large XML file and store it in memory as a HashMap so other spring web apps have access to this class.

    How would I go about doing this? Can this HashMap be treated as a DAO and I can ask other spring objects to ingest it in their app?

    How can I force tomcat to load this HashMap during start time, so the file is populated and loaded only once?

    Thanks,
    Bob

  • #2
    Have you looked at the Lifecycle interfaces?
    http://static.springframework.org/sp...tory-lifecycle

    Comment


    • #3
      Hi.
      Unless I am mistaken, you can do this by simply declaring your bean (the one who loads the XML and store it in a map) as a Spring bean, with the defaut scope, i.e. Singleton. The XML loading and the Map populating goes in an init-method (can be configured via xml or via JSR 250 annotation @PostConstruct).
      This bean can then be injected into any other bean needing him.

      Regards.

      Comment

      Working...
      X