Session engine (rebased onto dev_5_0)



This is the same as gh-834 but rebased onto dev_5_0.

----

related to https://github.com/openmicroscopy/openmicroscopy/pull/2686
this should mostly cover the issue raised in http://lists.openmicroscopy.org.uk/pipermail/ome-users/2014-June/004528.html