title: Designing a Java library with Spring
body: <p>I am extracting some functionality from an existing program into a separate library.
  This program uses Spring for dependency injection and other tasks and I'd like to keep using it in the library as well.</p>
  
  <p>This library needs to monitor the filesystem for changes, so it will kick off some kind of separate thread to do this.</p>
  
  <p>I don't really know what my options are for initialisation of the library:</p>
  
  <ul>
  <li><p>How do I initialise the library's context? I cannot assume that library users will make use of Spring too, but I can distribute Spring with the library.</p></li>
  <li><p>How do I manage my filesystem monitoring thread? Is it good design to expect the program to instantiate a main class of the library and the call init or something like that?</p></li>
  </ul>