Versions Compared

Key

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

...

The XML code for the File Binding example is located in the ServiceMix installation directory under the examples\file-binding directory in the servicemix.xml file. It is recommended that you refer to the servicemix.xml file while reading this document. The Java class files are located in the servicemix-1.0.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 #Useful Code Hints section below.
The File Binding XML file, servicemix.xml, contains two components and a supporting bean. One component waits for a file to be deposited into the the inbox directory, retrieves it, sends it to the Normalized Message Router (NMR). The NMR routes the file to another component, which deposits it into an outbox directory.

...

This section describes some interesting aspects of how the ServiceMix JBI container interacts with the File Binding application. The Java class files are located in the servicemix-1.0.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.

  • filePoller Details *
  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 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
    5. Analyzing the start method, the start method will
    a. Create a timerTask, which overrides the "run()" method inline, the run() method will eventually get the WorkManager and schedule work
    b. Start method uses the "timer" (created in the init method) to schedule the timerTask it just created at a fixed rate, timer.scheduleAtFixedRate(timerTask, firstTime, period)
    c. Timer will call the run method of the timerTask periodically
    d. timerTask's run method is defined inline.
    e. it will get the workManager object (see below for details)
    f. the work manager will call scheduleWork(PollingComponentSupport.this). note: it passes in PollingComponent support, which by virtual of its inheritance hierarchy, is also of type "Work", which is also a "runnable"
    g. WorkManager.scheduleWork(Work) will likely create or get a Thread, passing in a runnable, i.e. PollingComponentSupport, and call its "run" method
    h. PollingComponent's run method calls poll(), which is implemented in filePoller
    i. From this point on the call sequence can be followed in filePoller
    6. The start method of PollingComponentSupport, will eventually call super.start(), which propagates up to call the start method of BaseLifeCycle, which sets the component state to RUNNING

...