Aggregator

From MobiComp

Jump to: navigation, search

Summary

An aggregator is a MobiComp component that incorporates the behaviour of a Tracker and a Listener.

  • The Listener part receives notification of one or more events.
  • An action, such as a transformation, is then performed on the event data.
  • The transformed data is put back into the context store by the Tracker part.

Aggregators can perform tasks of any complexity, from simple unit conversions to combining low-level sensor elements to produce an element at a higher level of abstraction. For example, information from temperature, door, window, and light sensors might be used to determine room occupancy.

See also:

Developer info

Aggregators extend Tracker and implement ContextListener.

For an example, see SemacodeImageTracker in the package org.mobicomp.camera in the j2se source tree. This class listens for image put events. When notified of a new image, it extracts the ContextObject and sets a flag to indicate that a new image has arrived. In the Tracker checkStatus method, it checks the flag and, if necessary, extracts the image path from the ContextObject and passes it to an external semacode decoder. If the decoder returns a valid url, the Tracker part constructs a new beacon ContextObject, wraps it in a ContextElement, and puts the element into the store.

The beacon element can then be used, for example, by a BeaconListener to display the web page indicated by the semacode url.