|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.nakedobjects.runtime.persistence.adaptermanager.AdapterManagerAbstract
org.nakedobjects.runtime.persistence.adaptermanager.AdapterManagerDefault
public class AdapterManagerDefault
| Field Summary | |
|---|---|
protected OidAdapterMap |
oidAdapterMap
Optionally injected, otherwise will default. |
protected PojoAdapterMap |
pojoAdapterMap
Optionally injected, otherwise will default. |
| Constructor Summary | |
|---|---|
AdapterManagerDefault()
|
|
| Method Summary | |
|---|---|
NakedObject |
adapterFor(java.lang.Object pojo)
Either returns an existing adapter (as per AdapterManagerLookup.getAdapterFor(Object)), otherwise creates either a
transient root or a standalone adapter for the supplied domain object, depending on
its NakedObjectSpecification. |
NakedObject |
adapterFor(java.lang.Object pojo,
NakedObject ownerAdapter,
Identified identified)
Either returns an existing adapter (as per AdapterManagerLookup.getAdapterFor(Object)), otherwise creates either a
transient, standalone or aggregated adapter for the supplied domain object,
depending on its NakedObjectSpecification and the context arguments provided. |
NakedObject |
addExistingAdapter(NakedObject nakedObject)
Add a pre-existing adapter straight into the maps. |
void |
close()
|
protected NakedObject |
createAggregatedAdapter(java.lang.Object pojo,
NakedObject ownerAdapter,
Identified identified)
Creates an adapter with an AggregatedOid (so that its version and its
persistence are the same as its owning parent). |
protected Oid |
createOid(java.lang.Object pojo)
The default implementation will always create a new transient adapter, using the
OidGenerator. |
protected AggregateAdapters |
createOrRecreateRootAdapter(java.lang.Object pojo)
Creates a new root adapter for the supplied domain object. |
void |
debugData(DebugString debug)
|
java.lang.String |
debugTitle()
|
AdapterFactory |
getAdapterFactory()
|
NakedObject |
getAdapterFor(java.lang.Object pojo)
Gets the adapter for the specified domain object if it exists in the identity map. |
NakedObject |
getAdapterFor(Oid oid)
Gets the adapter for the Oid if it exists in the identity map. |
java.lang.Object |
getCollectionPojo(OneToManyAssociation association,
NakedObject ownerAdapter)
|
OidGenerator |
getOidGenerator()
|
SpecificationLoader |
getSpecificationLoader()
|
java.util.Iterator<NakedObject> |
iterator()
|
void |
open()
|
NakedObject |
recreateRootAdapter(Oid oid,
java.lang.Object pojo)
Either returns an existing adapter (as per #getAdapterFor(Object) or
#getAdapterFor(Oid)), otherwise re-creates an adapter with the specified (persistent)
Oid. |
void |
remapAsPersistent(NakedObject adapter)
Remaps the adapter and any associated aggregated (collection) adapters using a
new value for the Oid provided by the OidGenerator. |
void |
remapUpdated(Oid oid)
Remaps an Oid that has been updated so that its adapter (if any) is mapped to that Oid. |
void |
removeAdapter(NakedObject adapter)
Removes the specified object from both the identity-adapter map, and the pojo-adapter map. |
void |
reset()
|
void |
setAdapterFactory(AdapterFactory adapterFactory)
Injected. |
void |
setOidAdapterMap(OidAdapterMap identityAdapterMap)
For dependency injection. |
void |
setOidGenerator(OidGenerator oidGenerator)
Injected. |
void |
setPojoAdapterMap(PojoAdapterMap pojoAdapterMap)
For dependency injection. |
void |
setServicesInjector(ServicesInjector servicesInjector)
Injected. |
void |
setSpecificationLoader(SpecificationLoader specificationLoader)
Injected. |
NakedObject |
testCreateTransient(java.lang.Object pojo,
Oid oid)
For testing purposes only. |
| Methods inherited from class org.nakedobjects.runtime.persistence.adaptermanager.AdapterManagerAbstract |
|---|
injectInto, removeAdapter |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected PojoAdapterMap pojoAdapterMap
protected OidAdapterMap oidAdapterMap
| Constructor Detail |
|---|
public AdapterManagerDefault()
| Method Detail |
|---|
public void open()
open in interface SessionScopedComponentpublic void close()
close in interface SessionScopedComponentpublic void reset()
reset in interface Resettablepublic java.util.Iterator<NakedObject> iterator()
iterator in interface java.lang.Iterable<NakedObject>public NakedObject addExistingAdapter(NakedObject nakedObject)
AdapterManagerBackdooradapter straight into the maps.
addExistingAdapter in interface AdapterManagerBackdoorpublic NakedObject getAdapterFor(java.lang.Object pojo)
AdapterManagerLookupadapter for the specified domain object if it exists in the identity map.
getAdapterFor in interface AdapterManagerLookuppojo - - must not be null
public NakedObject getAdapterFor(Oid oid)
AdapterManagerLookupadapter for the Oid if it exists in the identity map.
getAdapterFor in interface AdapterManagerLookupoid - - must not be null
public NakedObject adapterFor(java.lang.Object pojo)
AdapterManagerLookup.getAdapterFor(Object)), otherwise creates either a
transient root or a standalone adapter for the supplied domain object, depending on
its NakedObjectSpecification.
The rules for creating a standalone vs transient root adapter are as for
AdapterManager.adapterFor(Object, NakedObject, Identified).
Historical notes: previously called createAdapterForTransient, though this name wasn't quite right.
Looks up getAdapterFor(Object) or returns a new transient
adapterFor in interface AdapterManager
public NakedObject adapterFor(java.lang.Object pojo,
NakedObject ownerAdapter,
Identified identified)
AdapterManagerAdapterManagerLookup.getAdapterFor(Object)), otherwise creates either a
transient, standalone or aggregated adapter for the supplied domain object,
depending on its NakedObjectSpecification and the context arguments provided.
If no adapter is found for the provided pojo, then the rules for creating the adapter are as follows:
specification indicates that this is an immutable
value, then a ResolveState.VALUE adapter is created
Identified argument indicates that for this particular
property/collection the object is aggregated or that the pojo's own
specification indicates that the pojo is intrinsically aggregated,
then an aggregated adapter is created. Note that the
ResolveState of such NakedObject's is independent of its ownerAdapter, but it
has the same optimistic locking version.
ResolveState.TRANSIENT adapter is created.
adapterFor in interface AdapterManagerpojo - - pojo to adaptownerAdapter - - only used if aggregated
public NakedObject recreateRootAdapter(Oid oid,
java.lang.Object pojo)
AdapterManagerPersistadapter (as per #getAdapterFor(Object) or
#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.
If the adapter is recreated, its ResolveState will be
ResolveState.GHOST if a persistent Oid, or ResolveState.TRANSIENT otherwise.
recreateRootAdapter in interface AdapterManagerPersistpublic void remapUpdated(Oid oid)
AdapterManagerProxyOid that has been updated so that its adapter (if any) is mapped to that Oid.
Part of public API so that the proxy persistor can maintain its maps when it processes a newly persisted object.
remapUpdated in interface AdapterManagerProxyAdapterManagerPersist.remapAsPersistent(NakedObject)public void removeAdapter(NakedObject adapter)
This indicates that the object is no longer in use, and therefore that no objects exists within the system.
If an adapter is removed while its pojo still is referenced then a subsequent
interaction of that pojo will create a different adapter, in a
transient state.
TODO: should do a cascade remove of any aggregated objects.
removeAdapter in interface AdapterManagerpublic void remapAsPersistent(NakedObject adapter)
adapter and any associated aggregated (collection) adapters using a
new value for the Oid provided by the OidGenerator.
The Oid of the supplied adapter should be in such a state that it can be
converted from transient to persistent. Note
that some Oid implementations require an initial state call to do this (eg to read from a
database identity or sequence value).
The adapter is remapped in the AdapterManager, and the previous is
set to its transient value). Similarly for any aggregated adapters. This is needed for client/server so that the client can remap a changed object.
Note that there is no management of Versions here. That is because the
PersistenceSession is expected to manage this. (In practice this is done by the
NakedObjectStore implementation delegated by the PersistenceSessionObjectStore, and
propogated back to client-side as required).
remapAsPersistent in interface AdapterManagerPersistAdapterManagerProxy.remapUpdated(Oid)
public java.lang.Object getCollectionPojo(OneToManyAssociation association,
NakedObject ownerAdapter)
public NakedObject testCreateTransient(java.lang.Object pojo,
Oid oid)
testCreateTransient in interface AdapterManagerTestSupport#adapterFor(Object),
#recreateRootAdapter(Object, Oid)protected AggregateAdapters createOrRecreateRootAdapter(java.lang.Object pojo)
adapter for the supplied domain object.
createOid(Object)protected Oid createOid(java.lang.Object pojo)
adapter, using the
OidGenerator. However, the method has protected visibility so can be overridden if
required. For example, some object stores (eg Hibernate) may be able to infer from the pojo itself what the
Oid and persistence state of the object is.
protected NakedObject createAggregatedAdapter(java.lang.Object pojo,
NakedObject ownerAdapter,
Identified identified)
adapter with an AggregatedOid (so that its version and its
persistence are the same as its owning parent).
Should only be called if the pojo is known not to be mapped.
Helper method, but protected so can be overridden if required. For example, some object stores (specifically, the XML object store at time of writing) do not support aggregated Oids for anything other than collections.
public java.lang.String debugTitle()
debugTitle in interface DebugInfopublic void debugData(DebugString debug)
debugData in interface DebugInfopublic void setOidAdapterMap(OidAdapterMap identityAdapterMap)
If not injected, will be instantiated within #init() method.
public void setPojoAdapterMap(PojoAdapterMap pojoAdapterMap)
If not injected, will be instantiated within #init() method.
public AdapterFactory getAdapterFactory()
setAdapterFactory(AdapterFactory)public void setAdapterFactory(AdapterFactory adapterFactory)
setAdapterFactory in interface AdapterFactoryAwarepublic SpecificationLoader getSpecificationLoader()
setSpecificationLoader(SpecificationLoader)public void setSpecificationLoader(SpecificationLoader specificationLoader)
setSpecificationLoader in interface SpecificationLoaderAwarepublic OidGenerator getOidGenerator()
setOidGenerator(OidGenerator)public void setOidGenerator(OidGenerator oidGenerator)
setOidGenerator in interface OidGeneratorAwarepublic void setServicesInjector(ServicesInjector servicesInjector)
setServicesInjector in interface ServicesInjectorAware
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||