Package org.apache.openjpa.persistence
Class PersistenceProductDerivation
- java.lang.Object
-
- org.apache.openjpa.lib.conf.AbstractProductDerivation
-
- org.apache.openjpa.persistence.PersistenceProductDerivation
-
- All Implemented Interfaces:
OpenJPAProductDerivation
,ProductDerivation
public class PersistenceProductDerivation extends AbstractProductDerivation implements OpenJPAProductDerivation
Sets JPA specification defaults and parses JPA specification XML files. For globals, looks inopenjpa.properties
system property for the location of a file to parse. If no system property is defined, the default resource location ofMETA-INF/openjpa.xml
is used. For defaults, looks forMETA-INF/persistence.xml
. Withinpersistence.xml
, look for the named persistence unit, or if no name given, an OpenJPA unit (preferring an unnamed OpenJPA unit to a named one).- Author:
- Abe White
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PersistenceProductDerivation.ConfigurationParser
SAX handler capable of parsing an JPA persistence.xml file.static class
PersistenceProductDerivation.ConfigurationProviderImpl
Custom configuration provider.
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
_providerImplName
static Specification
ALIAS_EJB
static java.lang.String
PREFIX
static java.lang.String
RSRC_DEFAULT
static java.lang.String
RSRC_GLOBAL
static Specification
SPEC_JPA
static java.math.BigDecimal
VERSION_1_0
-
Fields inherited from interface org.apache.openjpa.conf.OpenJPAProductDerivation
TYPE_PRODUCT_STORE, TYPE_SPEC, TYPE_SPEC_STORE, TYPE_STORE
-
Fields inherited from interface org.apache.openjpa.lib.conf.ProductDerivation
TYPE_FEATURE, TYPE_PRODUCT
-
-
Constructor Summary
Constructors Constructor Description PersistenceProductDerivation()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
afterSpecificationSet(Configuration c)
Called after the specification has been set.boolean
beforeConfigurationLoad(Configuration c)
Provides the instance with the opportunity to mutateconf
before the user configuration is applied.boolean
checkPuNameCollisions(Log logger, java.lang.String puName)
This method checks to see if the providedpuName
was detected in multiple resources.java.util.List<java.lang.String>
getAnchorsInFile(java.io.File file)
Return a Listof all the anchors defined in file
.java.util.List
getAnchorsInResource(java.lang.String resource)
Return a Listof all the anchors defined in resource
.java.lang.String
getConfigurationPrefix()
Return the configuration prefix for properties of this product.java.lang.String
getDefaultResourceLocation()
Return a string identifying the default resource location for this product derivation, if one exists.java.util.Set<java.lang.String>
getSupportedQueryHints()
Return set of Query hint keys recognized by this receiver.int
getType()
Return the type of derivation.ConfigurationProvider
load(jakarta.persistence.spi.PersistenceUnitInfo pinfo, java.util.Map m)
Load configuration from the given persistence unit with the specified user properties.ConfigurationProvider
load(java.io.File file, java.lang.String anchor)
Load given file, or return null if it is not a file this receiver understands.ConfigurationProvider
load(java.lang.String rsrc, java.lang.String anchor, java.lang.ClassLoader loader)
Load the given given resource into the returned ConfigurationProvider, or return null if it is not a resource this receiver understands.ConfigurationProvider
load(java.lang.String rsrc, java.lang.String name, java.util.Map m)
Load configuration from the given resource and unit names, which may be null.ConfigurationProvider
loadDefaults(java.lang.ClassLoader loader)
Load defaults into the returned ConfigurationProvider, or return null if no defaults are found.ConfigurationProvider
loadGlobals(java.lang.ClassLoader loader)
Load globals into the returned ConfigurationProvider, or return null if no globals are found.void
putBrokerFactoryAliases(java.util.Map<java.lang.String,java.lang.String> m)
Load default alias options into the given map.void
validate()
Ensure that this derivation is valid.-
Methods inherited from class org.apache.openjpa.lib.conf.AbstractProductDerivation
beforeConfigurationClose, beforeConfigurationConstruct
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.openjpa.lib.conf.ProductDerivation
beforeConfigurationClose, beforeConfigurationConstruct
-
-
-
-
Field Detail
-
SPEC_JPA
public static final Specification SPEC_JPA
-
ALIAS_EJB
public static final Specification ALIAS_EJB
-
RSRC_GLOBAL
public static final java.lang.String RSRC_GLOBAL
- See Also:
- Constant Field Values
-
RSRC_DEFAULT
public static final java.lang.String RSRC_DEFAULT
- See Also:
- Constant Field Values
-
VERSION_1_0
public static final java.math.BigDecimal VERSION_1_0
-
PREFIX
public static final java.lang.String PREFIX
- See Also:
- Constant Field Values
-
_providerImplName
protected java.lang.String _providerImplName
-
-
Method Detail
-
putBrokerFactoryAliases
public void putBrokerFactoryAliases(java.util.Map<java.lang.String,java.lang.String> m)
Description copied from interface:OpenJPAProductDerivation
Load default alias options into the given map. Each entry maps an alias to a broker factory class name. Replace anything previously under the desired keys.- Specified by:
putBrokerFactoryAliases
in interfaceOpenJPAProductDerivation
-
getType
public int getType()
Description copied from interface:ProductDerivation
Return the type of derivation.- Specified by:
getType
in interfaceProductDerivation
-
getConfigurationPrefix
public java.lang.String getConfigurationPrefix()
Description copied from interface:ProductDerivation
Return the configuration prefix for properties of this product.- Specified by:
getConfigurationPrefix
in interfaceProductDerivation
- Overrides:
getConfigurationPrefix
in classAbstractProductDerivation
-
getSupportedQueryHints
public java.util.Set<java.lang.String> getSupportedQueryHints()
Description copied from interface:ProductDerivation
Return set of Query hint keys recognized by this receiver.- Specified by:
getSupportedQueryHints
in interfaceProductDerivation
- Overrides:
getSupportedQueryHints
in classAbstractProductDerivation
-
validate
public void validate() throws java.lang.Exception
Description copied from interface:ProductDerivation
Ensure that this derivation is valid. This action might consist of loading classes for the product this derivation represents to be sure they exist. Throw any throwable to indicate an invalid derivation. Invalid derivations will not be used.- Specified by:
validate
in interfaceProductDerivation
- Overrides:
validate
in classAbstractProductDerivation
- Throws:
java.lang.Exception
-
beforeConfigurationLoad
public boolean beforeConfigurationLoad(Configuration c)
Description copied from interface:ProductDerivation
Provides the instance with the opportunity to mutateconf
before the user configuration is applied.- Specified by:
beforeConfigurationLoad
in interfaceProductDerivation
- Overrides:
beforeConfigurationLoad
in classAbstractProductDerivation
- Returns:
- true if given Configuration has been mutated.
-
afterSpecificationSet
public boolean afterSpecificationSet(Configuration c)
Description copied from interface:ProductDerivation
Called after the specification has been set.- Specified by:
afterSpecificationSet
in interfaceProductDerivation
- Overrides:
afterSpecificationSet
in classAbstractProductDerivation
- Returns:
- true if given Configuration has been mutated.
-
load
public ConfigurationProvider load(jakarta.persistence.spi.PersistenceUnitInfo pinfo, java.util.Map m) throws java.io.IOException
Load configuration from the given persistence unit with the specified user properties.- Throws:
java.io.IOException
-
load
public ConfigurationProvider load(java.lang.String rsrc, java.lang.String name, java.util.Map m) throws java.io.IOException
Load configuration from the given resource and unit names, which may be null.- Throws:
java.io.IOException
-
load
public ConfigurationProvider load(java.lang.String rsrc, java.lang.String anchor, java.lang.ClassLoader loader) throws java.io.IOException
Description copied from interface:ProductDerivation
Load the given given resource into the returned ConfigurationProvider, or return null if it is not a resource this receiver understands. The given class loader may be null.- Specified by:
load
in interfaceProductDerivation
- Overrides:
load
in classAbstractProductDerivation
anchor
- optional named anchor within a multiple-configuration resource- Throws:
java.io.IOException
-
load
public ConfigurationProvider load(java.io.File file, java.lang.String anchor) throws java.io.IOException
Description copied from interface:ProductDerivation
Load given file, or return null if it is not a file this receiver understands.- Specified by:
load
in interfaceProductDerivation
- Overrides:
load
in classAbstractProductDerivation
anchor
- optional named anchor within a multiple-configuration file- Throws:
java.io.IOException
-
getDefaultResourceLocation
public java.lang.String getDefaultResourceLocation()
Description copied from interface:ProductDerivation
Return a string identifying the default resource location for this product derivation, if one exists. If there is no default location, returnsnull
.- Specified by:
getDefaultResourceLocation
in interfaceProductDerivation
- Overrides:
getDefaultResourceLocation
in classAbstractProductDerivation
-
getAnchorsInFile
public java.util.List<java.lang.String> getAnchorsInFile(java.io.File file) throws java.io.IOException
Description copied from interface:ProductDerivation
Return a Listof all the anchors defined in file
. The returned names are not fully-qualified, so must be used in conjunction withfile
in calls toProductDerivation.load(java.io.File, String)
. Returnsnull
or an empty list if no anchors could be found.- Specified by:
getAnchorsInFile
in interfaceProductDerivation
- Overrides:
getAnchorsInFile
in classAbstractProductDerivation
- Throws:
java.io.IOException
-
getAnchorsInResource
public java.util.List getAnchorsInResource(java.lang.String resource) throws java.lang.Exception
Description copied from interface:ProductDerivation
Return a Listof all the anchors defined in resource
. The returned names are not fully-qualified, so must be used in conjunction withresource
in calls toProductDerivation.load(java.io.File, String)
. Returnsnull
or an empty list if no anchors could be found.- Specified by:
getAnchorsInResource
in interfaceProductDerivation
- Overrides:
getAnchorsInResource
in classAbstractProductDerivation
- Throws:
java.lang.Exception
-
loadGlobals
public ConfigurationProvider loadGlobals(java.lang.ClassLoader loader) throws java.io.IOException
Description copied from interface:ProductDerivation
Load globals into the returned ConfigurationProvider, or return null if no globals are found.- Specified by:
loadGlobals
in interfaceProductDerivation
- Overrides:
loadGlobals
in classAbstractProductDerivation
- Throws:
java.io.IOException
-
loadDefaults
public ConfigurationProvider loadDefaults(java.lang.ClassLoader loader) throws java.io.IOException
Description copied from interface:ProductDerivation
Load defaults into the returned ConfigurationProvider, or return null if no defaults are found.- Specified by:
loadDefaults
in interfaceProductDerivation
- Overrides:
loadDefaults
in classAbstractProductDerivation
- Throws:
java.io.IOException
-
checkPuNameCollisions
public boolean checkPuNameCollisions(Log logger, java.lang.String puName)
This method checks to see if the providedpuName
was detected in multiple resources. If a collision is detected, a warning will be logged and this method will returntrue
.
-
-