Package org.apache.openjpa.meta
Class NoneMetaDataFactory
- java.lang.Object
-
- org.apache.openjpa.meta.NoneMetaDataFactory
-
- All Implemented Interfaces:
CallbackModes
,MetaDataDefaults
,MetaDataFactory
,MetaDataModes
public class NoneMetaDataFactory extends java.lang.Object implements MetaDataFactory, MetaDataDefaults
No-op metadata I/O to prevent attempts to load other classes.- Author:
- Abe White
-
-
Field Summary
-
Fields inherited from interface org.apache.openjpa.event.CallbackModes
CALLBACK_FAIL_FAST, CALLBACK_IGNORE, CALLBACK_LOG, CALLBACK_RETHROW, CALLBACK_ROLLBACK
-
Fields inherited from interface org.apache.openjpa.meta.MetaDataFactory
STORE_DEFAULT, STORE_PER_CLASS, STORE_VERBOSE
-
Fields inherited from interface org.apache.openjpa.meta.MetaDataModes
MODE_ALL, MODE_ANN_MAPPING, MODE_MAPPING, MODE_MAPPING_INIT, MODE_META, MODE_NONE, MODE_QUERY
-
-
Constructor Summary
Constructors Constructor Description NoneMetaDataFactory()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addClassExtensionKeys(java.util.Collection exts)
Add any extension keys used by this instance to the given set.void
addFieldExtensionKeys(java.util.Collection exts)
Add any extension keys used by this instance to the given set.void
clear()
Clear any internal caches.boolean
drop(java.lang.Class[] cls, int mode, java.lang.ClassLoader envLoader)
Drop the metadata for the given classes in the given mode(s).java.lang.reflect.Member
getBackingMember(FieldMetaData fmd)
Return the backing member for the given field metadata.int
getCallbackMode()
What to do on lifecycle callback exceptions.boolean
getCallbacksBeforeListeners(int type)
If callbacks are fired before listeners for the given event type.int
getDefaultAccessType()
Return the default access type for a base persistent class withClassMetaData.ACCESS_UNKNOWN
access type.int
getDefaultIdentityType()
Return the default identity type for unmapped classes without primary key fields.MetaDataDefaults
getDefaults()
Return the metadata defaults for this factory.java.lang.String
getDefaultSchema()
Returns the default schema.static NoneMetaDataFactory
getInstance()
java.lang.Class<?>
getManagedClass(java.lang.Class<?> c)
Gets the managed class corresponding to the given meta-class.java.lang.String
getManagedClassName(java.lang.String metamodelClassName)
Gets the name of the managed class for the given fully-qualified meta-model class name.java.lang.reflect.Member
getMemberByProperty(ClassMetaData meta, java.lang.String property, int access, boolean scan)
Get the field or getter for the given attribute of the given class.java.lang.String
getMetaModelClassName(java.lang.String managedClassName)
Gets the name of the meta-model class for the given fully-qualified managed class name.java.util.Set
getPersistentTypeNames(boolean classpath, java.lang.ClassLoader envLoader)
Return all persistent class names, using the metadata locations supplied in configuration, optionally scanning the classpath.java.lang.Class
getQueryScope(java.lang.String queryName, java.lang.ClassLoader loader)
Return the type defining the given query name, if any.java.lang.Class
getResultSetMappingScope(java.lang.String resultSetMappingName, java.lang.ClassLoader loader)
Return the type defining the given result set mapping name, if any.java.lang.Class<? extends java.lang.Exception>
getUnimplementedExceptionType()
Return a runtime exception class to throw for un-implemented managed interface methods.boolean
isAbstractMappingUniDirectional(OpenJPAConfiguration conf)
Whether the relationship in MappedSuper class must be uni-directional.boolean
isDataStoreObjectIdFieldUnwrapped()
Whether the field in the object id class corresponding to a datastore id persistence-capable primary key field is the simple datastore id value of the related instance.boolean
isDeclaredInterfacePersistent()
Whether declared interfaces of a class are treated as persistent types.java.lang.Boolean
isDefaultCascadePersistEnabled()
Whether cascade-persist was declared in the persistence unit defaults.boolean
isMetaClass(java.lang.Class<?> c)
Affirms if the given class is a meta-class.boolean
isNonDefaultMappingAllowed(OpenJPAConfiguration conf)
Whether non-default mapping is allowed.void
load(java.lang.Class cls, int mode, java.lang.ClassLoader envLoader)
Load metadata for the given class in the given mode(s).void
loadXMLMetaData(java.lang.Class<?> cls)
Load XMLClassMetadata for the given class.ClassArgParser
newClassArgParser()
Return a properly-configured class arg parser for our expected metadata format.void
populate(ClassMetaData meta, int access)
Populate the given metadata with default settings.void
populate(ClassMetaData meta, int access, boolean ignoreTransient)
Populate the given metadata with default settings.void
setDefaultCascadePersistEnabled(java.lang.Boolean bool)
void
setDefaultSchema(java.lang.String schema)
Sets the default schema.void
setIgnoreNonPersistent(boolean ignore)
Whether to ignore members which are not persistent by default during metadata population.void
setRepository(MetaDataRepository repos)
Set the repository to load metadata into.void
setStoreDirectory(java.io.File dir)
Base directory for storing metadata.void
setStoreMode(int store)
Storage mode.void
setStrict(boolean strict)
If true, I/O's must exactly obey the mode directives given, and may not load additional information.boolean
store(ClassMetaData[] metas, QueryMetaData[] queries, SequenceMetaData[] seqs, int mode, java.util.Map output)
Store the given metadata.
-
-
-
Method Detail
-
getInstance
public static NoneMetaDataFactory getInstance()
-
setRepository
public void setRepository(MetaDataRepository repos)
Description copied from interface:MetaDataFactory
Set the repository to load metadata into. This method will be called before use.- Specified by:
setRepository
in interfaceMetaDataFactory
-
setStoreDirectory
public void setStoreDirectory(java.io.File dir)
Description copied from interface:MetaDataFactory
Base directory for storing metadata. May not be called.- Specified by:
setStoreDirectory
in interfaceMetaDataFactory
-
setStoreMode
public void setStoreMode(int store)
Description copied from interface:MetaDataFactory
Storage mode. May not be called.- Specified by:
setStoreMode
in interfaceMetaDataFactory
-
setStrict
public void setStrict(boolean strict)
Description copied from interface:MetaDataFactory
If true, I/O's must exactly obey the mode directives given, and may not load additional information.- Specified by:
setStrict
in interfaceMetaDataFactory
-
load
public void load(java.lang.Class cls, int mode, java.lang.ClassLoader envLoader)
Description copied from interface:MetaDataFactory
Load metadata for the given class in the given mode(s). If loading inMetaDataModes.MODE_QUERY
, the class may be null. Loaded metadata should be added directly to the repository. It should have its source mode set appropriately viaClassMetaData.setSourceMode(int)
.- Specified by:
load
in interfaceMetaDataFactory
mode
- the mode to load metadata in: if mapping information is stored together with metadata, then you can load mapping data even if this mode only includesMODE_META
, so long as thestrict
property hasn't been set
-
store
public boolean store(ClassMetaData[] metas, QueryMetaData[] queries, SequenceMetaData[] seqs, int mode, java.util.Map output)
Description copied from interface:MetaDataFactory
Store the given metadata.- Specified by:
store
in interfaceMetaDataFactory
mode
- hint about what aspects of the metadata have changedoutput
- if non-null, rather than storing metadata directly, add entries mapping each output destination such as aFile
to the planned output for that destination in string form- Returns:
- false if this factory is unable to store metadata
-
drop
public boolean drop(java.lang.Class[] cls, int mode, java.lang.ClassLoader envLoader)
Description copied from interface:MetaDataFactory
Drop the metadata for the given classes in the given mode(s).- Specified by:
drop
in interfaceMetaDataFactory
- Returns:
- false if any metadata could not be dropped
-
getDefaults
public MetaDataDefaults getDefaults()
Description copied from interface:MetaDataFactory
Return the metadata defaults for this factory.- Specified by:
getDefaults
in interfaceMetaDataFactory
-
getPersistentTypeNames
public java.util.Set getPersistentTypeNames(boolean classpath, java.lang.ClassLoader envLoader)
Description copied from interface:MetaDataFactory
Return all persistent class names, using the metadata locations supplied in configuration, optionally scanning the classpath. Return null if no types are supplied and this factory is unable to scan the classpath. This method should not be used directly by outside code; useMetaDataRepository.getPersistentTypeNames(boolean, java.lang.ClassLoader)
instead.
-
getQueryScope
public java.lang.Class getQueryScope(java.lang.String queryName, java.lang.ClassLoader loader)
Description copied from interface:MetaDataFactory
Return the type defining the given query name, if any.- Specified by:
getQueryScope
in interfaceMetaDataFactory
-
getResultSetMappingScope
public java.lang.Class getResultSetMappingScope(java.lang.String resultSetMappingName, java.lang.ClassLoader loader)
Description copied from interface:MetaDataFactory
Return the type defining the given result set mapping name, if any.- Specified by:
getResultSetMappingScope
in interfaceMetaDataFactory
-
newClassArgParser
public ClassArgParser newClassArgParser()
Description copied from interface:MetaDataFactory
Return a properly-configured class arg parser for our expected metadata format.- Specified by:
newClassArgParser
in interfaceMetaDataFactory
-
clear
public void clear()
Description copied from interface:MetaDataFactory
Clear any internal caches.- Specified by:
clear
in interfaceMetaDataFactory
-
addClassExtensionKeys
public void addClassExtensionKeys(java.util.Collection exts)
Description copied from interface:MetaDataFactory
Add any extension keys used by this instance to the given set.- Specified by:
addClassExtensionKeys
in interfaceMetaDataFactory
-
addFieldExtensionKeys
public void addFieldExtensionKeys(java.util.Collection exts)
Description copied from interface:MetaDataFactory
Add any extension keys used by this instance to the given set.- Specified by:
addFieldExtensionKeys
in interfaceMetaDataFactory
-
getDefaultAccessType
public int getDefaultAccessType()
Description copied from interface:MetaDataDefaults
Return the default access type for a base persistent class withClassMetaData.ACCESS_UNKNOWN
access type.- Specified by:
getDefaultAccessType
in interfaceMetaDataDefaults
-
getDefaultIdentityType
public int getDefaultIdentityType()
Description copied from interface:MetaDataDefaults
Return the default identity type for unmapped classes without primary key fields.- Specified by:
getDefaultIdentityType
in interfaceMetaDataDefaults
-
getCallbackMode
public int getCallbackMode()
Description copied from interface:MetaDataDefaults
What to do on lifecycle callback exceptions.- Specified by:
getCallbackMode
in interfaceMetaDataDefaults
-
getCallbacksBeforeListeners
public boolean getCallbacksBeforeListeners(int type)
Description copied from interface:MetaDataDefaults
If callbacks are fired before listeners for the given event type. Defaults to false.- Specified by:
getCallbacksBeforeListeners
in interfaceMetaDataDefaults
-
setIgnoreNonPersistent
public void setIgnoreNonPersistent(boolean ignore)
Description copied from interface:MetaDataDefaults
Whether to ignore members which are not persistent by default during metadata population. Defaults to true.- Specified by:
setIgnoreNonPersistent
in interfaceMetaDataDefaults
-
isDeclaredInterfacePersistent
public boolean isDeclaredInterfacePersistent()
Description copied from interface:MetaDataDefaults
Whether declared interfaces of a class are treated as persistent types. Defaults to true.- Specified by:
isDeclaredInterfacePersistent
in interfaceMetaDataDefaults
-
isDataStoreObjectIdFieldUnwrapped
public boolean isDataStoreObjectIdFieldUnwrapped()
Description copied from interface:MetaDataDefaults
Whether the field in the object id class corresponding to a datastore id persistence-capable primary key field is the simple datastore id value of the related instance. Defaults to false.- Specified by:
isDataStoreObjectIdFieldUnwrapped
in interfaceMetaDataDefaults
-
populate
public void populate(ClassMetaData meta, int access)
Description copied from interface:MetaDataDefaults
Populate the given metadata with default settings.- Specified by:
populate
in interfaceMetaDataDefaults
access
- access type constant fromClassMetaData
-
populate
public void populate(ClassMetaData meta, int access, boolean ignoreTransient)
Description copied from interface:MetaDataDefaults
Populate the given metadata with default settings.- Specified by:
populate
in interfaceMetaDataDefaults
access
- access type constant fromClassMetaData
-
getBackingMember
public java.lang.reflect.Member getBackingMember(FieldMetaData fmd)
Description copied from interface:MetaDataDefaults
Return the backing member for the given field metadata.- Specified by:
getBackingMember
in interfaceMetaDataDefaults
-
getMemberByProperty
public java.lang.reflect.Member getMemberByProperty(ClassMetaData meta, java.lang.String property, int access, boolean scan)
Description copied from interface:MetaDataDefaults
Get the field or getter for the given attribute of the given class.- Specified by:
getMemberByProperty
in interfaceMetaDataDefaults
- Parameters:
meta
- is the declaring classproperty
- name of the logical attributeaccess
- whether to look for the field of getter method. If unknown, then field or property is chosen based on the access type used by the given class.scan
- if true and access is unknown then scans the annotation on the member to determine access.
-
getUnimplementedExceptionType
public java.lang.Class<? extends java.lang.Exception> getUnimplementedExceptionType()
Description copied from interface:MetaDataDefaults
Return a runtime exception class to throw for un-implemented managed interface methods.- Specified by:
getUnimplementedExceptionType
in interfaceMetaDataDefaults
-
loadXMLMetaData
public void loadXMLMetaData(java.lang.Class<?> cls)
Description copied from interface:MetaDataFactory
Load XMLClassMetadata for the given class. Loaded metadata should be added directly to the repository.- Specified by:
loadXMLMetaData
in interfaceMetaDataFactory
-
getMetaModelClassName
public java.lang.String getMetaModelClassName(java.lang.String managedClassName)
Description copied from interface:MetaDataFactory
Gets the name of the meta-model class for the given fully-qualified managed class name.- Specified by:
getMetaModelClassName
in interfaceMetaDataFactory
-
getManagedClassName
public java.lang.String getManagedClassName(java.lang.String metamodelClassName)
Description copied from interface:MetaDataFactory
Gets the name of the managed class for the given fully-qualified meta-model class name.- Specified by:
getManagedClassName
in interfaceMetaDataFactory
-
isMetaClass
public boolean isMetaClass(java.lang.Class<?> c)
Description copied from interface:MetaDataFactory
Affirms if the given class is a meta-class.- Specified by:
isMetaClass
in interfaceMetaDataFactory
-
getManagedClass
public java.lang.Class<?> getManagedClass(java.lang.Class<?> c)
Description copied from interface:MetaDataFactory
Gets the managed class corresponding to the given meta-class.- Specified by:
getManagedClass
in interfaceMetaDataFactory
- Returns:
- null if the given input is not a meta-class.
-
isAbstractMappingUniDirectional
public boolean isAbstractMappingUniDirectional(OpenJPAConfiguration conf)
Description copied from interface:MetaDataDefaults
Whether the relationship in MappedSuper class must be uni-directional.- Specified by:
isAbstractMappingUniDirectional
in interfaceMetaDataDefaults
-
isNonDefaultMappingAllowed
public boolean isNonDefaultMappingAllowed(OpenJPAConfiguration conf)
Description copied from interface:MetaDataDefaults
Whether non-default mapping is allowed.- Specified by:
isNonDefaultMappingAllowed
in interfaceMetaDataDefaults
-
isDefaultCascadePersistEnabled
public java.lang.Boolean isDefaultCascadePersistEnabled()
Description copied from interface:MetaDataDefaults
Whether cascade-persist was declared in the persistence unit defaults.- Specified by:
isDefaultCascadePersistEnabled
in interfaceMetaDataDefaults
-
setDefaultCascadePersistEnabled
public void setDefaultCascadePersistEnabled(java.lang.Boolean bool)
- Specified by:
setDefaultCascadePersistEnabled
in interfaceMetaDataDefaults
-
getDefaultSchema
public java.lang.String getDefaultSchema()
Description copied from interface:MetaDataDefaults
Returns the default schema.- Specified by:
getDefaultSchema
in interfaceMetaDataDefaults
-
setDefaultSchema
public void setDefaultSchema(java.lang.String schema)
Description copied from interface:MetaDataDefaults
Sets the default schema.- Specified by:
setDefaultSchema
in interfaceMetaDataDefaults
-
-