Refactoring

Refactoring classses to make the concerns of each class clearer.

All state changes of an ExternalResource are now made by the
ExternalResourceManager instead of whatever object is requesting the
resource.

To make this happen, the reserve/lock/release methods have been re-written using the
Template Method Pattern, implementing the state change flow in the abstract base class
and letting sub-classes continue to implement the inner locking mechanism by calling the
abstract method reservation/locking/releasingMechanism().

The main reason for wanting this change is to make it easier to use the external resource manager from a groovy script (such as a build flow DSL) with code similar to this:

manager.lock(resource)
//... do some work
manager.release(resource)

without ever having to change the internal state of the resource manually (as was needed before this commit).

The code is a contribution from Ericsson AB (http://www.ericsson.com/) and has been reviewed internally by Marco Miller (https://github.com/marco-miller)