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

Featured
Updated Dec 26, 2007 by vmatt...@gmail.com

Project Broadway

Project Broadway is an extensible and customizable monitoring API. Broadway lets developers easily create monitor components to observe pre-defined conditions and specify how to react when these conditions are encountered.

As an API, Broadway can be used at different levels of implmentation. At its core, Broadway lets you separate the monitoring concerns from the observed resources. It has a flexible design that allows it to work in any environment where JavaBean property values can be read either directly through in-VM method execution or through some detached mechanism (i.e. reflection, rmi, jmx, web service, etc).

Monitoring with Broadway

Broadway scans bean properties of one or more registered JavaBeans for pre-defined states. When that condition is evaluated, you can specify an Action to be executed based on the outcome of the evaluation. The core of Broadway includes an implementation that allows you to express the monitoring condition using an Expression Language . You can use any scripting language supported by the Apache BSF project to express your monitored condition. Broadway uses the Groovy scripting language as its default expression language.

Using Broadway

As mentioned earlier, out of the box, Broadway includes a set of API's that allows you to specify monitored conditions using a string expression. Here, we see how we can register two plain beans and specify conditions used to monitor property values on those beans. We also specify an action object that executes a script when the condition becomes true.

    MapResourceCollector resources = new MapResourceCollector();
    ScriptedAction action = new ScriptedAction("scripts/action_script.groovy");

    Pojo pojo1 = new Pojo();
    pojo1.setStringProperty("Hello");
    resources.putResource("pojo1", pojo1);

    Pojo pojo2 = new Pojo();
    pojo2.setIntegerProperty(45)
    resources.putResource("pojo1", pojo1);

    String expr = "params.pojo1.StringProperty == 'Hello' && params.pojo2.BooleanProperty == false;";

    BeanMonitor monitor = new BeanMonitor();
    monitor.setMonitorExpression(expr);
    monitor.setAction(action);
    monitor.setResourceCollector(resources);

    // pass contextual data to action
    monitor.getContext().putValue("var1", new Integer(1));
    monitor.getContext().putValue("var2", new Integer(2));
    
    // scans properties using expression in exp.
    monitor.scan();

About the Code Snippet: It shows how you can use a Broadway component to monitor to monitor property values on two Java objects pojo1 and pojo2. The observed objects are first registered in a Resource Collector. Then, the expression used to monitor the object is set in variable expr. In this example, we are using Groovy to express a condition which will trigger the action. We set a Scripted Action object which will execute a script file when the condition is established. We can pass additional context information to the script action using the monitor's internal context object.

Ready to Get Started ?

Here are few links to get you Started with Broadway

Broadway Core Design

These components are core interfaces in Broadway. They are implemented to create Broadway Monitor components that can be used to monitor any arbitrary resource and their states. The default implementation provided with Broadway allows developers to write code to monitor state changes on Java objects using the JavaBean notations.


Sign in to add a comment
Powered by Google Project Hosting