You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@isis.apache.org by Dan Haywood <da...@haywood-associates.co.uk> on 2012/08/23 11:04:03 UTC

ISIS-14, ISIS-245, ISIS-248 - changing the way that concurrency checks are performed.

Just a heads-up on this.

Some of the recent commits I've been doing now allow the version
information (a sequence, and an optional user and timestamp) to be stored
in the RootOid.  This version information, if present, isn't part of the
equals()/hashCode() equivalence checks, but is serialized out as part of
the state.  As such, it constitutes a convenient way for a viewer to
capture the version of an object that has been rendered, just by
serializing the Oid.  This commits were done under the general slew of
commits under ISIS-14 (the JDO object store), and are non-breaking.

Concurrently with this, the existing Version interface, as referenced by
ObjectAdapter/PojoAdapter, also holds a sequence, user and date.  ISIS-245
was a ticket I worked on yesterday, which collapsed to Version hierarchy
(Version being an interface, and SerialNumberVersion and FileVersion being
the two implementations) into a single class, called Version.  I've
retained SerialNumberVersion and FileVersion, but their only distinguishing
responsibility was to act as a factory (providing defaults for the
different fields of Version).

I then retrofitted the version information within RootOid so that it holds
a reference to Version.

All of the above is just a refactoring, and should be non-breaking.

ISIS-248, finally, was another ticket I worked on yesterday, in which the
version field on ObjectAdapter disappears, and instead the ObjectAdapter
delegates to its Oid for the version information.  Any call to set the
version (following an update) on the ObjectAdapter is delegated on
similarly.

The new, breaking, change is the following check that's been added in
AdapterManagerDefault (the class that retrieves the object from the
datastore):

    @Override
    public ObjectAdapter adapterFor(final TypedOid typedOid) {

        // attempt to locate adapter for the Oid
        final ObjectAdapter adapterLookedUpByOid = getAdapterFor(typedOid);
        if (adapterLookedUpByOid != null) {
            return adapterLookedUpByOid;
        }

        final Object pojo = pojoRecreator.recreatePojo(typedOid);
        ObjectAdapter adapter = mapRecreatedPojo(typedOid, pojo);

        // START: ISIS-148 change
        Oid adapterOid = adapter.getOid();
        if(adapterOid instanceof RootOid) {
            final RootOid recreatedOid = (RootOid) adapterOid;
            final RootOid originalOid = (RootOid) typedOid;

recreatedOid.checkLock(getAuthenticationSession().getUserName(),
originalOid);
        }
        // END: ISIS-148 change

        return adapter;
    }


It ought now to be possible to start removing concurrency checks from the
viewers (Scimpi, HTML etc), while those viewers that don't yet do proper
concurrency checking (Wicket, Restful) will get this for free (but need to
handle any ConcurrencyExceptions that could now propogate out of the
persistor.

OK, that's all.
Dan