brooklyncentral/brooklyn — pull request #152 by aledsage (2012-06-01 12:40:14+00:00)
Title: Sensor adapter for java

Submitted for comments only - please do not merge!

This adds a version of HttpSensorAdapter and JmxSensorAdapter that can be used from pure-Java (i.e. no closures or duck-typing required).

A few things to note:
* This is work in progress, to see if people like the direction it is going.
* The aim is for the code to be easy-to-write: intuitive coding with code completion and types that tell the user what options there are, and what to pass in.
* It continues to use the existing "Registry" pattern etc.
* The package and class names are temporary, while working on this.
* We'd (probably) put these in sub-packages for http/jmx/etc.
* For backwards compatibility keey the groovy-style methods - their impl could delegate to some pure java code, or be left untouched.
* We'd deprecate those groovy methods, and direct people instead to a dedicated groovy shim class in an appropriately named package (which could eventually move to its own project).
* The error reporting and logging needs more work to be as good as what's there already.
* Still need to port the SshSensorAdapter etc.
* There are a couple of "features" added here as we go along:
* Supplying an "onError" handler for what to set the sensor to (e.g. if can't find MBean then onError would say to set service_up = false)
* Http result: support other content types (rather than failing if content-type not defined, or if content is not a valid string).