public class MetaDataRepository extends Object implements PCRegistry.RegisterClassListener, Configurable, Closeable, MetaDataModes, Serializable
Modifier and Type | Field and Description |
---|---|
protected boolean |
_locking |
protected boolean |
_preload |
protected boolean |
_preloadComplete |
protected static Class<?>[] |
EMPTY_CLASSES |
protected FieldMetaData[] |
EMPTY_FIELDS |
protected ClassMetaData[] |
EMPTY_METAS |
protected static NonPersistentMetaData[] |
EMPTY_NON_PERSISTENT |
protected Order[] |
EMPTY_ORDERS |
protected XMLMetaData[] |
EMPTY_XMLMETAS |
static int |
VALIDATE_MAPPING
Bit flag to validate mappings.
|
static int |
VALIDATE_META
Bit flag to validate metadata.
|
static int |
VALIDATE_NONE
Constant to not validate any metadata.
|
static int |
VALIDATE_RUNTIME
Bit flag for runtime validation.
|
static int |
VALIDATE_UNENHANCED
Bit flag to validate unenhanced metadata only.
|
MODE_ALL, MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY
Constructor and Description |
---|
MetaDataRepository()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
ClassMetaData |
addMetaData(Class<?> cls)
Create a new metadata, populate it with default information, add it to the repository, and
return it.
|
ClassMetaData |
addMetaData(Class<?> cls,
int access)
Create a new metadata, populate it with default information, add it to the repository, and
return it.
|
ClassMetaData |
addMetaData(Class<?> cls,
int access,
boolean ignoreTransient)
Create a new metadata, populate it with default information, add it to the repository, and
return it.
|
NonPersistentMetaData |
addNonMappedInterface(Class<?> iface)
Add the given non-mapped interface to the repository.
|
NonPersistentMetaData |
addPersistenceAware(Class<?> cls)
Add the given class as persistence-aware.
|
QueryMetaData |
addQueryMetaData(Class<?> cls,
String name)
Add a new query metadata to the repository and return it.
|
QueryMetaData |
addQueryMetaData(QueryMetaData meta) |
SequenceMetaData |
addSequenceMetaData(String name)
Add a new sequence metadata to the repository and return it.
|
void |
addSystemListener(Object listener)
Add the given system lifecycle listener.
|
XMLClassMetaData |
addXMLClassMetaData(Class<?> type)
Create a new metadata, populate it with default information, add it to the repository, and
return it.
|
void |
clear()
Clear the cache of parsed metadata.
|
void |
close()
Free the resources used by this repository.
|
void |
endConfiguration()
Invoked upon completion of bean property configuration for this object.
|
Collection<String> |
getAliasNames() |
ClassMetaData |
getCachedMetaData(Class<?> cls)
Return the cached metadata for the given class, without any resolution.
|
ClassMetaData |
getCachedMetaData(String typeName)
This method returns the ClassMetaData whose described type name matches the typeName parameter.
|
QueryMetaData |
getCachedQueryMetaData(Class<?> cls,
String name) |
QueryMetaData |
getCachedQueryMetaData(String name)
Return the cached query metadata for the given name.
|
SequenceMetaData |
getCachedSequenceMetaData(String name)
Return the cached a sequence metadata for the given name.
|
XMLMetaData |
getCachedXMLMetaData(Class<?> cls)
Return the cached XMLClassMetaData for the given class Return null if none.
|
String |
getClosestAliasName(String alias) |
OpenJPAConfiguration |
getConfiguration()
Return the configuration for the repository.
|
ClassMetaData[] |
getImplementorMetaDatas(Class<?> cls,
ClassLoader envLoader,
boolean mustExist)
Return all least-derived metadatas with some mapped assignable type that implement the given
class.
|
Log |
getLog()
Return the metadata log.
|
ClassMetaData |
getMetaData(Class<?> cls,
ClassLoader envLoader,
boolean mustExist)
Return the metadata for the given class.
|
ClassMetaData |
getMetaData(Object oid,
ClassLoader envLoader,
boolean mustExist)
Return the least-derived class metadata for the given application identity object.
|
ClassMetaData |
getMetaData(String alias,
ClassLoader envLoader,
boolean mustExist)
Return the metadata for the given alias name.
|
MetaDataFactory |
getMetaDataFactory()
The I/O used to load metadata.
|
ClassMetaData[] |
getMetaDatas()
Return all the metadata instances currently in the repository.
|
Class<?> |
getMetaModel(Class<?> entity,
boolean load)
Gets the meta class corresponding to the given class.
|
Class<?> |
getMetaModel(ClassMetaData meta,
boolean load)
Gets the meta class corresponding to the given persistent class.
|
NonPersistentMetaData |
getNonMappedInterface(Class<?> iface)
Gets the metadata corresponding to the given non-mapped interface.
|
NonPersistentMetaData[] |
getNonMappedInterfaces()
Gets the corresponding metadatas for all registered, non-mapped interfaces
|
FieldMetaData |
getOrderByField(ClassMetaData meta,
String orderBy) |
NonPersistentMetaData |
getPersistenceAware(Class<?> cls)
Gets the metadata corresponding to the given persistence-aware class.
|
NonPersistentMetaData[] |
getPersistenceAwares()
Gets all the metadatas for persistence-aware classes
|
Set<String> |
getPersistentTypeNames(boolean devpath,
ClassLoader envLoader)
Return the set of configured persistent classes, or null if the user did not configure any.
|
boolean |
getPreload()
Sets whether this repository will load all known persistent classes at initialization.
|
protected static Object |
getQueryKey(Class<?> cls,
String name)
Return a unique key for a given class / name.
|
QueryMetaData |
getQueryMetaData(Class<?> cls,
String name,
ClassLoader envLoader,
boolean mustExist)
Return query metadata for the given class, name, and classloader.
|
QueryMetaData[] |
getQueryMetaDatas()
Return the cached query metadata.
|
int |
getResolve()
The metadata resolution mode.
|
SequenceMetaData |
getSequenceMetaData(String name,
ClassLoader envLoader,
boolean mustExist)
Return sequence metadata for the given name and classloader.
|
SequenceMetaData[] |
getSequenceMetaDatas()
Return the cached sequence metadata.
|
int |
getSourceMode()
The source mode determining what metadata to load.
|
LifecycleEventManager.ListenerList |
getSystemListeners()
Return the system lifecycle listeners
|
int |
getValidate()
The metadata validation level.
|
XMLMetaData |
getXMLMetaData(Class<?> cls)
Return XML metadata for a given field metadata
|
boolean |
is_systemListenersActivated()
Whether any system (default) listeners have been registered.
|
Collection<Class<?>> |
loadPersistentTypes(boolean devpath,
ClassLoader envLoader)
Load the persistent classes named in configuration.
|
Collection<Class<?>> |
loadPersistentTypes(boolean devpath,
ClassLoader envLoader,
boolean mustExist)
Load the persistent classes named in configuration.
|
static boolean |
needsPreload(OpenJPAConfiguration conf) |
protected ClassMetaData |
newClassMetaData(Class<?> type)
Create a new class metadata instance.
|
protected ClassMetaData[] |
newClassMetaDataArray(int length)
Create a new array of the proper class metadata subclass.
|
protected ClassMetaData |
newEmbeddedClassMetaData(ValueMetaData owner)
Create a new embedded class metadata instance.
|
protected FieldMetaData |
newFieldMetaData(String name,
Class<?> type,
ClassMetaData owner)
Create a new field metadata instance.
|
protected FieldMetaData[] |
newFieldMetaDataArray(int length)
Create a new array of the proper field metadata subclass.
|
protected Order |
newOrder(FieldMetaData owner,
String name,
boolean asc)
Create an
Order for the given field and declaration. |
protected Order[] |
newOrderArray(int size)
Create an array of orders of the given size.
|
QueryMetaData |
newQueryMetaData(Class<?> cls,
String name)
Create a new query metadata instance.
|
protected Order |
newRelatedFieldOrder(FieldMetaData owner,
FieldMetaData rel,
boolean asc)
Order by a field of the related type.
|
protected SequenceMetaData |
newSequenceMetaData(String name)
Create a new sequence metadata instance.
|
protected ValueMetaData |
newValueMetaData(FieldMetaData owner)
Create a new value metadata instance.
|
protected Order |
newValueOrder(FieldMetaData owner,
boolean asc)
Order by the field value.
|
protected XMLClassMetaData |
newXMLClassMetaData(Class<?> type)
Create a new xml class metadata
|
protected XMLMetaData[] |
newXMLClassMetaDataArray(int length)
Create a new array of the proper xml class metadata subclass.
|
XMLFieldMetaData |
newXMLFieldMetaData(Class<?> type,
String name)
Create a new xml field meta, add it to the fieldMap in the given xml class metadata
|
void |
preload()
If the openjpa.MetaDataRepository plugin value Preload=true is set, this method will load all
MetaData for all persistent classes and will remove locking from this class.
|
protected void |
prepareMapping(ClassMetaData meta)
Prepare metadata for mapping resolution.
|
void |
register(Class<?> cls) |
void |
registerAlias(String alias,
Class<?> cls) |
boolean |
removeMetaData(Class<?> cls)
Remove a metadata instance from the repository.
|
boolean |
removeMetaData(ClassMetaData meta)
Remove a metadata instance from the repository.
|
boolean |
removeNonMappedInterface(Class<?> iface)
Remove a non-mapped interface from the repository
|
boolean |
removePersistenceAware(Class<?> cls)
Remove a persitence-aware class from the repository
|
boolean |
removeQueryMetaData(Class<?> cls,
String name)
Remove query metadata for the given class name if in the repository.
|
boolean |
removeQueryMetaData(QueryMetaData meta)
Remove the given query metadata from the repository.
|
boolean |
removeSequenceMetaData(SequenceMetaData meta)
Remove the given sequence metadata from the repository.
|
boolean |
removeSequenceMetaData(String name)
Remove sequence metadata for the name if in the repository.
|
boolean |
removeSystemListener(Object listener)
Remove the given system lifecycle listener.
|
QueryMetaData |
searchQueryMetaDataByName(String name)
Searches all cached query metadata by name.
|
void |
setConfiguration(Configuration conf)
Invoked prior to setting bean properties.
|
void |
setMetaDataFactory(MetaDataFactory factory)
The I/O used to load metadata.
|
void |
setMetaModel(Class<?> m2)
Puts the meta class corresponding to the given entity class.
|
void |
setMetaModel(ClassMetaData meta,
Class<?> m2)
Puts the meta class corresponding to the given persistent class.
|
void |
setPreload(boolean l)
Sets whether this repository will load all known persistent classes at initialization.
|
void |
setResolve(int mode)
The metadata resolution mode.
|
void |
setResolve(int mode,
boolean on)
The metadata resolution mode.
|
void |
setSourceMode(int mode)
The source mode determining what metadata to load.
|
void |
setSourceMode(int mode,
boolean on)
The source mode determining what metadata to load.
|
void |
setValidate(int validate)
The metadata validation level.
|
void |
setValidate(int validate,
boolean on)
The metadata validation level.
|
void |
startConfiguration()
Invoked before bean property configuration is begun on this object.
|
public static final int VALIDATE_NONE
public static final int VALIDATE_META
public static final int VALIDATE_MAPPING
public static final int VALIDATE_UNENHANCED
public static final int VALIDATE_RUNTIME
protected static final Class<?>[] EMPTY_CLASSES
protected static final NonPersistentMetaData[] EMPTY_NON_PERSISTENT
protected final ClassMetaData[] EMPTY_METAS
protected final FieldMetaData[] EMPTY_FIELDS
protected final Order[] EMPTY_ORDERS
protected final XMLMetaData[] EMPTY_XMLMETAS
protected boolean _preload
protected boolean _preloadComplete
protected boolean _locking
public MetaDataRepository()
Configurable
.public OpenJPAConfiguration getConfiguration()
public Log getLog()
public MetaDataFactory getMetaDataFactory()
public void setMetaDataFactory(MetaDataFactory factory)
public int getValidate()
VALIDATE_META | VALIDATE_UNENHANCED
.public void setValidate(int validate)
VALIDATE_META | VALIDATE_UNENHANCED
.public void setValidate(int validate, boolean on)
VALIDATE_META | VALIDATE_MAPPING | VALIDATE_UNENHANCED
.public int getResolve()
MODE_META | MODE_MAPPING
.public void setResolve(int mode)
MODE_META | MODE_MAPPING
.public void setResolve(int mode, boolean on)
MODE_META | MODE_MAPPING
.public int getSourceMode()
MODE_META | MODE_MAPPING | MODE_QUERY
.public void setSourceMode(int mode)
MODE_META | MODE_MAPPING | MODE_QUERY
.public void setSourceMode(int mode, boolean on)
MODE_META | MODE_MAPPING | MODE_QUERY
.public boolean getPreload()
public void setPreload(boolean l)
public void preload()
public ClassMetaData getMetaData(Class<?> cls, ClassLoader envLoader, boolean mustExist)
cls
- the class to retrieve metadata forenvLoader
- the environmental class loader, if anymustExist
- if true, throws a MetaDataException
if no metadata is foundpublic ClassMetaData getMetaData(String alias, ClassLoader envLoader, boolean mustExist)
alias
- the alias to class to retrieve metadata forenvLoader
- the environmental class loader, if anymustExist
- if true, throws a MetaDataException
if no metadata is foundClassMetaData.getTypeAlias()
public String getClosestAliasName(String alias)
public Collection<String> getAliasNames()
protected void prepareMapping(ClassMetaData meta)
ClassMetaData.defineSuperclassFields(boolean)
.public ClassMetaData[] getMetaDatas()
public ClassMetaData getCachedMetaData(Class<?> cls)
public ClassMetaData addMetaData(Class<?> cls)
public ClassMetaData addMetaData(Class<?> cls, int access)
access
- the access type to use in populating metadatapublic ClassMetaData addMetaData(Class<?> cls, int access, boolean ignoreTransient)
access
- the access type to use in populating metadataprotected ClassMetaData newClassMetaData(Class<?> type)
protected ClassMetaData[] newClassMetaDataArray(int length)
protected FieldMetaData newFieldMetaData(String name, Class<?> type, ClassMetaData owner)
protected FieldMetaData[] newFieldMetaDataArray(int length)
protected XMLMetaData[] newXMLClassMetaDataArray(int length)
protected ClassMetaData newEmbeddedClassMetaData(ValueMetaData owner)
protected ValueMetaData newValueMetaData(FieldMetaData owner)
protected Order newOrder(FieldMetaData owner, String name, boolean asc)
Order
for the given field and declaration. This method delegates to
newRelatedFieldOrder(org.apache.openjpa.meta.FieldMetaData, org.apache.openjpa.meta.FieldMetaData, boolean)
and #newValueFieldOrder
by default.public FieldMetaData getOrderByField(ClassMetaData meta, String orderBy)
protected Order newValueOrder(FieldMetaData owner, boolean asc)
protected Order newRelatedFieldOrder(FieldMetaData owner, FieldMetaData rel, boolean asc)
protected Order[] newOrderArray(int size)
public boolean removeMetaData(ClassMetaData meta)
public boolean removeMetaData(Class<?> cls)
public ClassMetaData getMetaData(Object oid, ClassLoader envLoader, boolean mustExist)
oid
- the oid to get the metadata forenvLoader
- the environmental class loader, if anymustExist
- if true, throws a MetaDataException
if no metadata is foundpublic ClassMetaData[] getImplementorMetaDatas(Class<?> cls, ClassLoader envLoader, boolean mustExist)
cls
- the class or interface to retrieve implementors forenvLoader
- the environmental class loader, if anymustExist
- if true, throws a MetaDataException
if no metadata is foundpublic NonPersistentMetaData getPersistenceAware(Class<?> cls)
public NonPersistentMetaData[] getPersistenceAwares()
public NonPersistentMetaData addPersistenceAware(Class<?> cls)
cls
- non-null and must not alreaddy be added as persitence-capablepublic boolean removePersistenceAware(Class<?> cls)
public NonPersistentMetaData getNonMappedInterface(Class<?> iface)
public NonPersistentMetaData[] getNonMappedInterfaces()
public NonPersistentMetaData addNonMappedInterface(Class<?> iface)
iface
- the non-mapped interfacepublic boolean removeNonMappedInterface(Class<?> iface)
public void clear()
MetaDataFactory
's cache.public Set<String> getPersistentTypeNames(boolean devpath, ClassLoader envLoader)
devpath
- if true, search for metadata files in directories in the classpath if no classes
are configured explicitlyenvLoader
- the class loader to use, or null for defaultpublic Collection<Class<?>> loadPersistentTypes(boolean devpath, ClassLoader envLoader)
devpath
- if true, search for metadata files in directories
in the classpath if the no classes are configured explicitlyenvLoader
- the class loader to use, or null for defaultpublic Collection<Class<?>> loadPersistentTypes(boolean devpath, ClassLoader envLoader, boolean mustExist)
devpath
- if true, search for metadata files in directories in the classpath if the no
classes are configured explicitlyenvLoader
- the class loader to use, or null for defaultmustExist
- if true then empty list of classes or any unloadable but specified class will
raise an exception.public void register(Class<?> cls)
register
in interface PCRegistry.RegisterClassListener
public void setMetaModel(Class<?> m2)
public void setMetaModel(ClassMetaData meta, Class<?> m2)
public Class<?> getMetaModel(ClassMetaData meta, boolean load)
public Class<?> getMetaModel(Class<?> entity, boolean load)
public void setConfiguration(Configuration conf)
Configurable
setConfiguration
in interface Configurable
public void startConfiguration()
Configurable
startConfiguration
in interface Configurable
public void endConfiguration()
Configurable
endConfiguration
in interface Configurable
public QueryMetaData getQueryMetaData(Class<?> cls, String name, ClassLoader envLoader, boolean mustExist)
public QueryMetaData[] getQueryMetaDatas()
public QueryMetaData getCachedQueryMetaData(Class<?> cls, String name)
public QueryMetaData getCachedQueryMetaData(String name)
public QueryMetaData addQueryMetaData(Class<?> cls, String name)
public QueryMetaData addQueryMetaData(QueryMetaData meta)
public QueryMetaData newQueryMetaData(Class<?> cls, String name)
public boolean removeQueryMetaData(QueryMetaData meta)
public boolean removeQueryMetaData(Class<?> cls, String name)
public QueryMetaData searchQueryMetaDataByName(String name)
protected static Object getQueryKey(Class<?> cls, String name)
public SequenceMetaData getSequenceMetaData(String name, ClassLoader envLoader, boolean mustExist)
public SequenceMetaData[] getSequenceMetaDatas()
public SequenceMetaData getCachedSequenceMetaData(String name)
public SequenceMetaData addSequenceMetaData(String name)
protected SequenceMetaData newSequenceMetaData(String name)
public boolean removeSequenceMetaData(SequenceMetaData meta)
public boolean removeSequenceMetaData(String name)
public boolean is_systemListenersActivated()
public void addSystemListener(Object listener)
public boolean removeSystemListener(Object listener)
public LifecycleEventManager.ListenerList getSystemListeners()
public void close()
public XMLMetaData getXMLMetaData(Class<?> cls)
public XMLClassMetaData addXMLClassMetaData(Class<?> type)
type
- the access type to use in populating metadatapublic XMLMetaData getCachedXMLMetaData(Class<?> cls)
protected XMLClassMetaData newXMLClassMetaData(Class<?> type)
public XMLFieldMetaData newXMLFieldMetaData(Class<?> type, String name)
public static boolean needsPreload(OpenJPAConfiguration conf)
public ClassMetaData getCachedMetaData(String typeName)
Copyright © 2006–2019 Apache Software Foundation. All rights reserved.