On 1 February 2013 16:26, Maurizio Taverna <[email protected]>wrote:

> Hello Dan,
> I have a (stupid) question about retrieving objects.
>

Hmm, hardly!



> Looking at the source code (claims/viewer-html), it seems to that  the
> collection returned for method call ( example from an allEmployees)  is
> stored in the context (session).  The context  to store all the object,
> when is needed to retrieve an object, simply search in the session to find
> a matching key.  Something like this :
>
> final String idString = request.getObjectId();
> final ObjectAdapter adapter = context.getMappedObject(idString);
> ...
> getPersistenceSession().resolveImmediately(adapter);
>
>
> My question is, is it possible retrieve an object from the data store
> using the key, without this storing in the context ?
>
>
It is.

The viewer-html was the first webapp viewer, written by Rob (Matthews).  As
you have rightly figured out, it has its own internal scheme for
identifying objects, either persistent or transient, and they go into this
"context", which - if I recall correctly - is really just a couple of
hashes for the two different types of object.

One of the reasons that Rob wrote it that way was that, at the time, the
Oid was only an internal identifier and didn't fully identify an object;
again, as I recall, it identified the instance of object, but not the type
(java.lang.Class) of the object.

Since then, though, the Oid does now have this capability, such that
oid.enstring(...) can return a completely unique id (a URI, really) for any
object in Isis.  This mostly came about because I wanted to write the
Restful Objects viewer as a completely stateless viewer.

Incidentally, while on the topic of the Oid, as you'll see if you use the
RO  viewer, the Oid also encodes optimistic locking information.  Put
crudely: the responsibility of the objectstore is to persist objects, while
the responsibility of the Isis runtime (namely PersistenceSession) is to
add in the optimistic locking stuff.  To retrieve an object (for which you
had an Oid string), you can use
IsisContext.getPersistenceSession().getAdapterManager().adapterFor(...) ,
and specify whether you want optimistic locking concurrency checks to be
performed (eg if invoking an action) or not (eg if just redisplaying an
object).

I'm adding in [email protected] to the reply; I think these sorts of
conversations ought to be on-list.

Cheers
Dan




> Thanks
> Maurizio
>
>
>
>
>

Reply via email to