Developing Apama Applications > Developing Apama Applications in Java > Overview of Apama Java Applications > About monitors
About monitors
Monitor classes configure the activity of the correlator. This is analogous to how an Enterprise Java Bean effectively defines the activity of an application server.
All monitor classes must implement the com.apama.jmon.Monitor interface and define an onLoad method. When a monitor class is loaded into the correlator, it is instantiated as an object and its onLoad method is executed. In Java parlance, this would be equivalent to the static void main (args[]) method.
Most Java code (with certain limitations) can be executed within the onLoad method, although its primary purpose is probably to configure one or more asynchronous listeners for specific events or event sequences.
A monitor class must define a ‘no argument’ constructor. The Java code within the correlator uses this when the class definition is loaded.
Below is a minimal monitor:
import com.apama.jmon.*;
 
public class Simple implements Monitor {
   /**
   * No argument constructor used by the jmon framework on
   * application loading
   */
   public Simple() {}
 
   /**
    * Implementation of the Monitor interface onLoad method.
    * Does nothing.
   */
   public void onLoad() {
   }
}
The above monitor class does nothing and is shown here as a template for how to define a monitor class.
EPL - Although there are similarities, the concept of a monitor in EPL and in Java is not the same. The EPL monitor is a very powerful custom programming structure, whereas in Java a monitor class is primarily a standard Java class with an entry method that gets automatically executed upon loading (as described below).
Copyright © 2013 Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.