My favorites | Sign in
Project Home Downloads Issues Source
Search
for
BroadwayMonitorDSL  

Featured
Updated Nov 1, 2007 by vmatt...@gmail.com

Broadway Monitor DSL

Broadway provides a builder class to build monitor components using a grammar that is specific to monitoring. The MonitorDsl object tones down the verbosity required when using traditional boiler plate Java procedural code. The DSL introduces several methods that provides verbs and other grammatical structures to build the monitor using precise vernicular. Here the parts of the DSL:

  • observe() - an declarative which indicates a given resource to observe.
  • forCondition() - this statement setups the condition for which to observe.
  • When.thisIsTrue() ( or When.thisIsFals() ) - use this to create a conditional statement and indicate which result would cause the monitor to execute its action.
  • execute() - an imperative that actually execute the action when the monitor's conditional evaluates to the expected value (true/false).

Here is a snapshot on how to setup and use the BeanMonitor DSL component.

    private BeanMonitor monitor;
    private BeanMonitorDsl monDsl;

    ...
    

    public SimplePojoMonitor5() {
        monitor = new BeanMonitor();
        monDsl  = new BeanMonitorDsl(monitor);
    }
    
    public void startMonitor() {
		
        monDsl
	    .observe(new ObservedBean("pojo1", pojo1))
	    .observe(new ObservedBean("pojo2", pojo2))
	    .observe(new ObservedBean("pojo3", pojo3))
	    .forCondition(
	    	When.thisIsTrue(
	    		"((params.pojo1.interger + params.pojo2.interger + params.pojo3.interger) / 3) > 40"
		)
	     );
			
	...
	
	monDsl.execute(action);
    }

As you can see, the DSL reduces the verbosity of boiler plate code procedural code and provides a succint approach to build the Broadway monitor.

View entire example.


Sign in to add a comment
Powered by Google Project Hosting