Versions Compared

Key

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

...

Useful Code Hints

This section describes some interesting aspects of the startup sequence and how the ServiceMix container interacts with the File Binding application. The Java class files are located in the servicemix-1.0.1.jar file in the ServiceMix installation directory. To look at the Java source code, unjar and decompile the .class files or download the source code. Viewing the Java source code is necessary for understanding the information in this section below.

...

  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 (See PollingComponentSupport.java):
    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).
    d. The workManager will call "scheduleWork(PollingComponentSupport.this)". Note: it passes in PollingComponent support, which by virtue of its inheritance hierarchy, is of type "Work", which is a "Runnable" object."
    e. "workManager.scheduleWork(Work)" will likely create or get a Thread, passing in a Runnable object, i.e. PollingComponentSupport, and call its run() method.
    f. PollingComponent's run() method calls poll(), which is implemented in FilePoller.
    g. From this point on the call sequence can be followed in FilePoller...
    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 (see 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.

...

Summarizing, when the ServiceMix container instantiates an MBean it firsts sets the property values if there are any, then calls the init() method of the class and its' parent classes, if applicable. Then it calls the start() method of the class. When a Spring bean starts up, the properties are set and then the
afterPropertiesSet() method is called.

Related Documentation

For more information on the following topics please see:

...