Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. The ServiceMix container reads the servicemix.xml file and sees it needs to instantiate a FilePoller.
  2. The container calls the init() method of FilePoller as well as the init() methods of its parents.
  3. The container determines that FilePoller is an MBean and, therefore, calls the start() method of FilePoller, which it inherits from its parent PollingComponentSupport.
  4. The start() method will:
    a. Create a timerTask.
    b. Schedule the the timerTask at a fixed rate. The start() method uses the "timer" (created in the init method) to schedule the timerTask at a fixed rate: timer.scheduleAtFixedRate(timerTask, firstTime, period). Recall "period" is a property of FilePoller. It was assigned the value of 1000ms by dependency injection from the servicemix.xml file.
    c. timer will call the run() method of the timerTask periodically. timerTask's run method() is defined inline. It will get the workManager object (see below for details).
    e d. The workManager will call scheduleWork(PollingComponentSupport.this). Note: it passes in PollingComponent support, which by virtue of its inheritance hierarchy, is also of type "Work", which is a "Runnable."
    f e. workManager.scheduleWork(Work) will likely create or get a Thread, passing in a Runnable object, i.e. PollingComponentSupport, and call its run() method
    g f. PollingComponent's run() method calls poll(), which is implemented in FilePoller.
    h g. From this point on the call sequence can be followed in FilePoller...
    i h. The start() method of PollingComponentSupport, will eventually calls super.start(), which propagates up to call the start() method of BaseLifeCycle, which sets the component state to "RUNNING."

Eventually, one of the threads that is polling (lookingsee step g. above) for a file in the inbox directory will see a file in the inbox directory. It will use workManager's thread pool to get a thread for processing the file. Processing the file consists of streaming it in from inbox, creating a normalized message, and sending the message to the NMR.

...