public interface AdapterManager extends Injectable
adapters and identities for each and every POJO that is being used by the framework.
It provides a consistent set of adapters in memory, providing an
adapter for the POJOs that are in use ensuring that the
same object is not loaded twice into memory.
Each POJO is given an adapter so that the framework can
work with the POJOs even though it does not understand their types. Each POJO
maps to an adapter and these are reused.
| Modifier and Type | Interface and Description |
|---|---|
static class |
AdapterManager.ConcurrencyChecking |
| Modifier and Type | Method and Description |
|---|---|
ObjectAdapter |
adapterFor(Object domainObject)
Looks up or creates a standalone (value) or root adapter.
|
ObjectAdapter |
adapterFor(Object domainObject,
ObjectAdapter parentAdapter)
Looks up or creates a standalone (value), aggregated or root adapter.
|
ObjectAdapter |
adapterFor(Object pojo,
ObjectAdapter parentAdapter,
OneToManyAssociation collection)
Looks up or creates a collection adapter.
|
ObjectAdapter |
adapterFor(TypedOid oid)
As per
adapterFor(TypedOid, ConcurrencyChecking), with
. |
ObjectAdapter |
adapterFor(TypedOid oid,
AdapterManager.ConcurrencyChecking concurrencyChecking)
Either returns an existing
adapter (as per
getAdapterFor(Oid)), otherwise re-creates an adapter with the
specified (persistent) Oid. |
ObjectAdapter |
getAdapterFor(Object pojo)
Gets the
adapter for the specified domain object if
it exists in the identity map. |
ObjectAdapter |
getAdapterFor(Oid oid)
|
injectIntoObjectAdapter getAdapterFor(Oid oid)
oid - - must not be nullObjectAdapter getAdapterFor(Object pojo)
adapter for the specified domain object if
it exists in the identity map.
Provided by the AdapterManager when used by framework.
pojo - - must not be nullObjectAdapter adapterFor(TypedOid oid)
adapterFor(TypedOid, ConcurrencyChecking), with
.
This method will always return an object, possibly indicating it is persistent; so make sure that you know that the oid does indeed represent an object you know exists.
ObjectAdapter adapterFor(TypedOid oid, AdapterManager.ConcurrencyChecking concurrencyChecking)
adapter (as per
getAdapterFor(Oid)), otherwise re-creates an adapter with the
specified (persistent) Oid.
Typically called when the Oid is already known, that is, when
resolving an already-persisted object. Is also available for
Memento support however, so Oid could also represent a
transient object.
The pojo itself is recreated by delegating to a PojoRecreator implementation.
The default impl just uses the ObjectSpecification.createObject();
however object stores (eg JDO/DataNucleus) can provide alternative implementations
in order to ensure that the created pojo is attached to a persistence context.
If the adapter is recreated, its
ResolveState will be set to ResolveState.GHOST.
The AdapterManager.ConcurrencyChecking parameter determines whether concurrency checking is performed.
If it is requested, then a check is made to ensure that the version
of the oid of the recreated adapter is the same as that of the provided oid.
If the version differs, then a ConcurrencyException is thrown.
ALSO, even if a ConcurrencyException, then the provided oid's version
will be set to the current
value. This allows the client to retry if they wish.
{@link - ObjectNotFoundException} if the object does not exist.ObjectAdapter adapterFor(Object domainObject)
ObjectAdapter adapterFor(Object domainObject, ObjectAdapter parentAdapter)
ObjectAdapter adapterFor(Object pojo, ObjectAdapter parentAdapter, OneToManyAssociation collection)
Copyright © 2010–2014 The Apache Software Foundation. All rights reserved.