|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.domain.DomainObjectFactory
This is a factory class to support instantiation of an appropriate domain object class from a given data object.
The architecture of the persistence and domain layers intentionally does not impose a simple one-to-one correspondence between data object types and domain object classes. It is possible for multiple domain object classes to encapsulate a given data object. It is also possible that a single domain object class can encapsulate data objects of different types. The primary factory design objectives are:
DomainObjectInstantiator
, that can make use of any
properties of the given data object.
DomainObjectInstantiator
has been registered
with the factory for type X, and even then, it may be possible for
the instantiator code to examine other properties of the data object
and decide that the given data object is not supported (presumably
because there is no sensible way to choose which domain object class
should be instantiated for the particular data object).
DomainObjectInstantiator
,
DataObject
,
DomainObject
Field Summary | |
static String |
versionId
|
Constructor Summary | |
DomainObjectFactory()
|
Method Summary | |
static DomainObjectInstantiator |
getInstantiator(ObjectType dataObjectType)
Get the registered or inherited instantiator for the specified object type. |
static DomainObjectInstantiator |
getInstantiator(String dataObjectType)
Wrapper around getInstantiator(ObjectType). |
static DomainObjectInstantiator |
getRegisteredInstantiator(ObjectType dataObjectType)
Get the registered instantiator for the specified object type. |
static DomainObjectInstantiator |
getRegisteredInstantiator(String dataObjectType)
Wrapper around getRegisteredInstantiator(ObjectType). |
static DomainObject |
newInstance(DataObject dataObject)
Instantiates a domain object given a data object. |
static DomainObject |
newInstance(OID oid)
Instantiate a domain object given an OID. |
static DomainObjectInstantiator |
registerInstantiator(ObjectType dataObjectType,
DomainObjectInstantiator instantiator)
Register an instantiator for the data object type specified by dataObjectType. |
static DomainObjectInstantiator |
registerInstantiator(String dataObjectType,
DomainObjectInstantiator instantiator)
Wrapper around registerInstantiator(ObjectType, DomainObjectInstantiator) . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String versionId
Constructor Detail |
public DomainObjectFactory()
Method Detail |
public static DomainObject newInstance(DataObject dataObject) throws PersistenceException, InstantiatorNotFoundException
The process of instantiating the domain object involves delegating to
a DomainObjectInstantiator
. The instantiator may use any
information about the DataObject to produce the appropriate domain
object.
The result may be null if there is no instantiator registered for the
dataObjectType of the specified dataObject
, OR if the registered
instantiator does not support instantiation of the specified
dataObject
.
dataObject
- The data object from which to instantiate
a domain object.
null
, if called with the null
data object
parameter. The result may also be null
if no domain object
could be instantiated for the given data object.
InstantiatorNotFoundException
- if no Instantiator could be found
PersistenceException
DataObject
,
DomainObject
public static DomainObject newInstance(OID oid) throws InstantiatorNotFoundException
oid
- the oid of the data object for which to instantiate
a domain object.
DataObjectNotFoundException
- if object could not be retrieved.
InstantiatorNotFoundException
newInstance(DataObject)
,
DataObject
,
DomainObject
public static DomainObjectInstantiator registerInstantiator(ObjectType dataObjectType, DomainObjectInstantiator instantiator)
newInstance(x)
is executued, the specified
instantiator will be used if the specified
dataObjectType is equal to x.getObjectType()
.
Any object type that does not have an instantiator registered with this factory is not supported by the factory.
If another instantiator was already registered for the specified object type, the previous instantiator is replaced and returned.
dataObjectType
- The data object type for which to register
the instantiator specified by instantiatorinstantiator
- The instantiator that will handle data objects
of the data object type specified by dataObjectType when
newInstance() is called.
InstantiatorRegistryException
- if null == dataObjectTyperegisterInstantiator(String, DomainObjectInstantiator)
,
newInstance(DataObject)
,
DataObject
,
DomainObject
public static DomainObjectInstantiator registerInstantiator(String dataObjectType, DomainObjectInstantiator instantiator)
registerInstantiator(ObjectType, DomainObjectInstantiator)
.
dataObjectType
- The fully qualified name of the data object type
for which to register the specified instantiator.
The qualified name is the model name followed by a '.'
followed by the object type name (e.g. "com.arsdigita.kernel.Party").instantiator
- The instantiator that will handle data objects
of the type specified by typeName when this newInstance() is
called.
InstantiatorRegistryException
- if the dataObjectType does not existregisterInstantiator(ObjectType, DomainObjectInstantiator)
public static DomainObjectInstantiator getRegisteredInstantiator(ObjectType dataObjectType)
dataObjectType
- The data object type whose registered
instantiator is to be returned
registerInstantiator(ObjectType,DomainObjectInstantiator)
public static DomainObjectInstantiator getRegisteredInstantiator(String dataObjectType)
dataObjectType
- The fully qualified name of the data object type
whose registered instantiator is to be returned
getRegisteredInstantiator(ObjectType)
,
registerInstantiator(ObjectType,DomainObjectInstantiator)
public static DomainObjectInstantiator getInstantiator(ObjectType dataObjectType)
dataObjectType
- The data object type whose registered or
inherited instantiator is to be returned
registerInstantiator(ObjectType,DomainObjectInstantiator)
public static DomainObjectInstantiator getInstantiator(String dataObjectType)
dataObjectType
- The fully qualified name of the data object type
whose registered or inherited instantiator is to be returned
getInstantiator(ObjectType)
,
registerInstantiator(ObjectType,DomainObjectInstantiator)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |