public abstract class AbstractPersistenceManager extends Object implements PersistenceManagerServices
PersistenceManager.FactoriesDEFAULT_DOMAIN_NAME, DEFAULT_DOMAIN_URL, DISABLED, MANDATORY, MANDATORY_IF_DECLARED, PERSISTENCE_DYNOBJECT_NAMESPACE, PERSISTENCE_NAMESPACE| Modifier | Constructor and Description |
|---|---|
protected |
AbstractPersistenceManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAlias(String name,
Class aClass)
Associates an alias with a class.
|
protected DynStruct |
addDefinition(Class theClass,
DynClass definition,
String domainName,
String domainUrl) |
DynStruct |
addDefinition(Class theClass,
String name,
InputStream definitions,
ClassLoader loader,
String domainName,
String domainUrl)
Add a new definition to the class in the persistent manager.
|
DynStruct |
addDefinition(Class theClass,
String name,
Map definitions,
String domainName,
String domainUrl)
Add a new definition to the class in the persistent manager.
|
DynStruct |
addDefinition(Class theClass,
String name,
String description,
String domainName,
String domainUrl)
Add a new definition to the class in the persistent manager.
|
DynStruct |
addDefinition(DynStruct definition,
String domainName,
String domainUrl)
Add a new definition to the class in the persistent manager.
|
Object |
create(PersistentState state)
Instantiates an object from a persistent state.
|
PersistentStateServices |
createPersistentState(PersistentContextServices context) |
PersistentStateServices |
createState(Object object,
PersistentContextServices context) |
int |
getAutoValidation()
Gets the validation which will be applied in
PersistenceManager.getState(Object),
PersistenceManager.create(PersistentState) methods. |
DynStruct |
getDefinition(Class persistentClass)
If the provided persistent class has registered an attribute definition
in this manager, then this method returns that definition.
|
DynStruct |
getDefinition(String className)
Return the associated definition to the java class name passed as parameter.
|
List |
getDomainDefinitions(String domainName) |
Map |
getDomains() |
DynStruct |
getDynObjectDefinition(String className)
Return the associated definition to the dynClass name passed as parameter.
|
PersistenceManager.Factories |
getFactories() |
PersistentContextServices |
getNewContext() |
Object |
getObject(InputStream is)
De-serializes an state from the data read from the provided
is. |
PersistentState |
getState(Object obj)
Creates a persistent state from an Persistent object.
|
PersistentState |
getState(Object obj,
boolean collectAllErrors)
Creates a persistent state from an Persistent object.
|
List |
getWrappedList(List list,
PersistentContextServices context) |
Map |
getWrappedMap(Map map,
PersistentContextServices context) |
Set |
getWrappedSet(Set set,
PersistentContextServices context) |
void |
putObject(OutputStream os,
Object obj)
Serializes the object "obj" and writes the serialized data in
the provided
OutputStream. |
void |
registerFactory(PersistenceFactory factory)
Register an instance of
PersistenceFactory that can manage some
objects that requires an especial construction or persistence. |
void |
setAutoValidation(int validationMode)
Sets the validation which will be applied in
PersistenceManager.getState(Object),
PersistenceManager.create(PersistentState) methods. |
void |
unregisterClass(Class theClass)
Unregister a registered class from the manager.
|
void |
unregisterClass(String name)
Unregister a registered java class from the manager.
|
void |
unregisterFactory(PersistenceFactory factory) |
void |
validate(PersistentState state,
int mode)
Validates persistent state by using the corresponding registered
attribute definition.
|
void |
validateAll(PersistentState state,
int mode)
Validates all persistent state related to the
state by using
the corresponding registered attribute definition. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreatePersistentStateloadState, saveStatepublic void addAlias(String name, Class aClass) throws PersistenceClassNotRegistered
PersistenceManagerAssociates an alias with a class. This is similar to a symbolic link, which allows to access the class by means of its alias.
When an alias is defined, it replaces any class whose qualified name is equal to the alias. Therefore, this class will never be instantiated, and instead the class pointed by the the alias will be instantiated.
For example, if the following alias is defined:
Class aClass = org.gvsig.fmap.mapcontext.rendering.symbols.SimpleMarkerSymbol.class;
manager.addAlias(
"org.gvsig.fmap.mapcontext.rendering.symbols.ArrowMarkerSymbol", aClass);
then, SimpleMarkerSymbol will be instantiated instead of ArrowMarkerSymbol from any PersistentState which references ArrowMarkerSymbol.
Aliases are useful to provided backward-compatibility paths (as old no existing classes may be aliased to substitution classes), but are also useful to avoid limitations on ClassLoaders. As a Class object is provided, it will be possible to instantiate it even if the current ClassLoader has no direct visibility of the class to instantiate.
addAlias in interface PersistenceManagername - The alias to reference a classPersistenceClassNotRegistered - if aClass is not registeredpublic PersistenceManager.Factories getFactories()
getFactories in interface PersistenceManagerpublic PersistentContextServices getNewContext()
getNewContext in interface PersistenceManagerServicespublic Object create(PersistentState state) throws PersistenceException
PersistenceManagerInstantiates an object from a persistent state. The PersistentState object knows the class of the persisted object, and instantiates it by using introspection. The object must implement the Persistent interface so that it can understand the PersistentState.
create in interface PersistenceManagerstate - The state of the object to be instantiatedstate object.PersistenceExceptionpublic Object getObject(InputStream is)
PersistenceManager
De-serializes an state from the data read from the provided
is. Depending on the implementation the serialized data
may have different formats, such as XML or binary data.
Note that a particular implementation will only be able to de-serialize data which has been serialized by the same implementation.
getObject in interface PersistenceManagerpublic void putObject(OutputStream os, Object obj)
PersistenceManager
Serializes the object "obj" and writes the serialized data in
the provided OutputStream. Depending on the implementation the
serialized data may have different formats, such as XML or binary data.
Note that a particular implementation will only be able to de-serialize data which has been serialized by the same implementation.
putObject in interface PersistenceManagerpublic DynStruct getDefinition(Class persistentClass)
PersistenceManagerIf the provided persistent class has registered an attribute definition in this manager, then this method returns that definition. Otherwise, it returns null.
getDefinition in interface PersistenceManagerpersistentClass - The class whose corresponding attribute definition is to be
retrieved.public DynStruct getDefinition(String className)
PersistenceManagerReturn the associated definition to the java class name passed as parameter.
getDefinition in interface PersistenceManagerclassName - of the java class to retrieve definitionpublic DynStruct getDynObjectDefinition(String className)
PersistenceManagerReturn the associated definition to the dynClass name passed as parameter.
getDynObjectDefinition in interface PersistenceManagerpublic void validate(PersistentState state, int mode) throws PersistenceValidateExceptions
PersistenceManager
Validates persistent state by using the corresponding registered
attribute definition. mode specifies what to do when a
definition of a state class is not registered.
validate in interface PersistenceManagerPersistenceValidateExceptionspublic void validateAll(PersistentState state, int mode) throws PersistenceValidateExceptions
PersistenceManager
Validates all persistent state related to the state by using
the corresponding registered attribute definition. mode
specifies what to do when a definition of a state class is not
registered.
validateAll in interface PersistenceManagerPersistenceValidateExceptions#setAutoValidation(int)}public int getAutoValidation()
PersistenceManager
Gets the validation which will be applied in PersistenceManager.getState(Object),
PersistenceManager.create(PersistentState) methods.
getAutoValidation in interface PersistenceManagerPersistenceManager.DISABLED,
PersistenceManager.MANDATORY or PersistenceManager.MANDATORY_IF_DECLARED#validateAll(PersistentState),
#registerClass(Class, DynStruct)public void setAutoValidation(int validationMode)
throws PersistenceException
PersistenceManager
Sets the validation which will be applied in PersistenceManager.getState(Object),
PersistenceManager.create(PersistentState) methods. Validation ensures that
persisted or de-persisted objects match the declared definition (which
must have been previously registered by using
#registerClass(Class, DynStruct)).
When automatic validation is enabled (MANDATORY or
MANDATORY_IF_DECLARED), a ValidationException will be thrown by
PersistenceManager.getState(Object), PersistenceManager.create(PersistentState) if a
validation error is found.
setAutoValidation in interface PersistenceManagervalidationMode - On of the following values: PersistenceManager.DISABLED,
PersistenceManager.MANDATORY or PersistenceManager.MANDATORY_IF_DECLAREDPersistenceException - If the mode is not supported by this manager#validateAll(PersistentState),
#registerClass(Class, DynStruct)public PersistentState getState(Object obj) throws PersistenceException, PersistenceValidateExceptions, PersistenceTypeNotSupportedException
PersistenceManagerCreates a persistent state from an Persistent object.
getState in interface PersistenceManagerobj - The Persistent object to be persistedPersistenceExceptionPersistenceValidateExceptionsPersistenceTypeNotSupportedExceptionpublic PersistentState getState(Object obj, boolean collectAllErrors) throws PersistenceException
PersistenceManagergetState in interface PersistenceManagerPersistenceExceptionpublic PersistentStateServices createState(Object object, PersistentContextServices context) throws PersistenceException
createState in interface PersistenceManagerServicesPersistenceExceptionpublic List getWrappedList(List list, PersistentContextServices context)
getWrappedList in interface PersistenceManagerServicespublic Map getWrappedMap(Map map, PersistentContextServices context)
getWrappedMap in interface PersistenceManagerServicespublic Set getWrappedSet(Set set, PersistentContextServices context)
getWrappedSet in interface PersistenceManagerServicespublic Map getDomains()
getDomains in interface PersistenceManagerServicespublic List getDomainDefinitions(String domainName)
getDomainDefinitions in interface PersistenceManagerServicespublic DynStruct addDefinition(Class theClass, String name, String description, String domainName, String domainUrl)
PersistenceManagerdomainName can by in only one
domainURL. If you try to register the same
domainName with two URL an exception will be raised. addDefinition in interface PersistenceManagername - of the new definitiondescription - of the new definition, can be null.domainName - , can be null.domainUrl - , can be null.public DynStruct addDefinition(Class theClass, String name, InputStream definitions, ClassLoader loader, String domainName, String domainUrl)
PersistenceManageraddDefinition in interface PersistenceManagertheClass - to be persistentname - of the class definition to associate to theClassdefinitions - input stream from load the definitions of classesloader - , loader to resolve references to classesdomainName - (can be null)domainUrl - (can be null)PersistenceManager.addDefinition(Class, String, String, String, String)public DynStruct addDefinition(Class theClass, String name, Map definitions, String domainName, String domainUrl)
PersistenceManageraddDefinition in interface PersistenceManagertheClass - to be persistentname - of the class definition to associate to theClassdefinitions - , map from get the definition of the classdomainName - (can be null)domainUrl - (can be null)PersistenceManager.addDefinition(Class, String, String, String, String)protected DynStruct addDefinition(Class theClass, DynClass definition, String domainName, String domainUrl)
public DynStruct addDefinition(DynStruct definition, String domainName, String domainUrl) throws AddDefinitionException
PersistenceManageraddDefinition in interface PersistenceManagerdefinition - , TODOdomainName - (can be null)domainUrl - (can be null)AddDefinitionExceptionPersistenceManager.addDefinition(Class, String, String, String, String)public void registerFactory(PersistenceFactory factory)
PersistenceManager
Register an instance of PersistenceFactory that can manage some
objects that requires an especial construction or persistence. This
factory will use the default domain name and URL.
registerFactory in interface PersistenceManagerpublic void unregisterClass(Class theClass)
PersistenceManagerUnregister a registered class from the manager.
unregisterClass in interface PersistenceManager#registerClass(Class, DynStruct, String)public void unregisterClass(String name)
PersistenceManagerUnregister a registered java class from the manager.
unregisterClass in interface PersistenceManagername - the java class name to unregister#registerClass(Class)public void unregisterFactory(PersistenceFactory factory)
unregisterFactory in interface PersistenceManagerpublic PersistentStateServices createPersistentState(PersistentContextServices context)
createPersistentState in interface PersistenceManagerServices