public class PersistenceUnitInfoBean extends Object implements PersistenceUnitInfo
PersistenceUnitInfo implementation that can be
constructed by hand.PersistenceUnitInfo| Modifier and Type | Class and Description |
|---|---|
static interface |
PersistenceUnitInfoBean.DataSourceProvider
A functional interface
indicating that its implementations can supply
DataSources. |
| Constructor and Description |
|---|
PersistenceUnitInfoBean(String persistenceUnitName,
URL persistenceUnitRootUrl,
Collection<? extends String> managedClassNames,
PersistenceUnitInfoBean.DataSourceProvider dataSourceProvider,
Properties properties)
Creates a new
PersistenceUnitInfoBean using as many
defaults as reasonably possible. |
PersistenceUnitInfoBean(String persistenceUnitName,
URL persistenceUnitRootUrl,
String persistenceXMLSchemaVersion,
String persistenceProviderClassName,
ClassLoader classLoader,
Supplier<? extends ClassLoader> tempClassLoaderSupplier,
Consumer<? super ClassTransformer> classTransformerConsumer,
boolean excludeUnlistedClasses,
Collection<? extends URL> jarFileUrls,
Collection<? extends String> managedClassNames,
Collection<? extends String> mappingFileNames,
String jtaDataSourceName,
String nonJtaDataSourceName,
PersistenceUnitInfoBean.DataSourceProvider dataSourceProvider,
Properties properties,
SharedCacheMode sharedCacheMode,
PersistenceUnitTransactionType transactionType,
ValidationMode validationMode)
Creates a new
PersistenceUnitInfoBean. |
| Modifier and Type | Method and Description |
|---|---|
void |
addTransformer(ClassTransformer classTransformer) |
boolean |
excludeUnlistedClasses() |
static Collection<? extends PersistenceUnitInfoBean> |
fromPersistence(Persistence persistence,
ClassLoader classLoader,
Supplier<? extends ClassLoader> tempClassLoaderSupplier,
URL rootUrl,
Map<? extends String,? extends Set<? extends Class<?>>> unlistedClasses,
PersistenceUnitInfoBean.DataSourceProvider dataSourceProvider)
Given a
Persistence (a Java object representation of a
META-INF/persistence.xml resource), a URL
representing the root of all persistence units, a Map
of unlisted managed classes (entity classes, mapped
superclasses and so on) indexed by persistence unit name, and a
PersistenceUnitInfoBean.DataSourceProvider that can provide DataSource
instances, returns a Collection of PersistenceUnitInfoBean instances representing all the
persistence units in play. |
static PersistenceUnitInfoBean |
fromPersistenceUnit(Persistence.PersistenceUnit persistenceUnit,
ClassLoader classLoader,
Supplier<? extends ClassLoader> tempClassLoaderSupplier,
URL rootUrl,
Map<? extends String,? extends Set<? extends Class<?>>> unlistedClasses,
PersistenceUnitInfoBean.DataSourceProvider dataSourceProvider)
Given a
Persistence.PersistenceUnit (a Java object representation
of a <persistence-unit> element in a META-INF/persistence.xml resource), a ClassLoader for
loading JPA classes and resources, a Supplier of ClassLoader instances for helping to implement the PersistenceUnitInfo.getNewTempClassLoader() method, a URL representing the persistence unit's root, a Map of
unlisted managed classes (entity classes, mapped superclasses
and so on) indexed by persistence unit name, and a PersistenceUnitInfoBean.DataSourceProvider that can provide DataSource
instances, returns a PersistenceUnitInfoBean
representing the persistence unit in question. |
static PersistenceUnitInfoBean |
fromPersistenceUnit(Persistence.PersistenceUnit persistenceUnit,
URL rootUrl,
Map<? extends String,? extends Set<? extends Class<?>>> unlistedClasses,
PersistenceUnitInfoBean.DataSourceProvider dataSourceProvider)
Given a
Persistence.PersistenceUnit (a Java object representation
of a <persistence-unit> element in a META-INF/persistence.xml resource), a URL representing
the persistence unit's root, a Map of unlisted managed
classes (entity classes, mapped superclasses and so on) indexed
by persistence unit name, and a PersistenceUnitInfoBean.DataSourceProvider that
can supply DataSource instances, returns a PersistenceUnitInfoBean representing the persistence unit in
question. |
ClassLoader |
getClassLoader() |
List<URL> |
getJarFileUrls() |
DataSource |
getJtaDataSource() |
List<String> |
getManagedClassNames() |
List<String> |
getMappingFileNames() |
ClassLoader |
getNewTempClassLoader() |
DataSource |
getNonJtaDataSource() |
String |
getPersistenceProviderClassName() |
String |
getPersistenceUnitName() |
URL |
getPersistenceUnitRootUrl() |
String |
getPersistenceXMLSchemaVersion() |
Properties |
getProperties() |
SharedCacheMode |
getSharedCacheMode() |
PersistenceUnitTransactionType |
getTransactionType() |
ValidationMode |
getValidationMode() |
public PersistenceUnitInfoBean(String persistenceUnitName, URL persistenceUnitRootUrl, Collection<? extends String> managedClassNames, PersistenceUnitInfoBean.DataSourceProvider dataSourceProvider, Properties properties)
PersistenceUnitInfoBean using as many
defaults as reasonably possible.persistenceUnitName - the name of the persistence unit
this PersistenceUnitInfoBean represents; must not be
nullpersistenceUnitRootUrl - the URL identifying the
root of the persistence unit this PersistenceUnitInfoBean represents; must not be nullmanagedClassNames - a Collection of
fully-qualified class names identifying JPA-managed classes
(such as entity classes, mapped superclasses and the like); may
be null. The Collection is copied and no
reference to it is retained.dataSourceProvider - a PersistenceUnitInfoBean.DataSourceProvider capable
of supplying DataSource instances; must not be nullproperties - a Properties object representing the
properties of the persistence unit represented by this PersistenceUnitInfoBean; may be null. A reference is
retained to this object.NullPointerException - if persistenceUnitName,
persistenceUnitRootUrl or dataSourceProvider is
nullPersistenceUnitInfoBean(String, URL, String, String,
ClassLoader, Supplier, Consumer, boolean, Collection,
Collection, Collection, String, String, DataSourceProvider,
Properties, SharedCacheMode, PersistenceUnitTransactionType,
ValidationMode)public PersistenceUnitInfoBean(String persistenceUnitName, URL persistenceUnitRootUrl, String persistenceXMLSchemaVersion, String persistenceProviderClassName, ClassLoader classLoader, Supplier<? extends ClassLoader> tempClassLoaderSupplier, Consumer<? super ClassTransformer> classTransformerConsumer, boolean excludeUnlistedClasses, Collection<? extends URL> jarFileUrls, Collection<? extends String> managedClassNames, Collection<? extends String> mappingFileNames, String jtaDataSourceName, String nonJtaDataSourceName, PersistenceUnitInfoBean.DataSourceProvider dataSourceProvider, Properties properties, SharedCacheMode sharedCacheMode, PersistenceUnitTransactionType transactionType, ValidationMode validationMode)
PersistenceUnitInfoBean.persistenceUnitName - the name of the persistence unit
this PersistenceUnitInfoBean represents; must not be
nullpersistenceUnitRootUrl - the URL identifying the
root of the persistence unit this PersistenceUnitInfoBean represents; must not be nullpersistenceXMLSchemaVersion - a String
representation of the version of JPA being supported; may be
null in which case "2.2" will be used insteadpersistenceProviderClassName - the fully-qualified class
name of a PersistenceProvider implementation; may be
null in which case a default will be usedclassLoader - a ClassLoader to be returned by the
getClassLoader() method; may be nulltempClassLoaderSupplier - a Supplier of ClassLoader instances to be used by the getNewTempClassLoader() method; may be nullclassTransformerConsumer - a Consumer of any
ClassTransformers that may be added via a JPA
provider's invocation of the addTransformer(ClassTransformer) method; may be null
in which case no action will be takenexcludeUnlistedClasses - if true, then any
automatically discovered managed classes not explicitly
contained in managedClassNames will be excluded from
considerationjarFileUrls - a Collection of URLs
identifying .jar files containing managed classes; may
be null. The Collection is copied and no
reference to it is retained.managedClassNames - a Collection of
fully-qualified class names identifying JPA-managed classes
(such as entity classes, mapped superclasses and the like); may
be null. The Collection is copied and no
reference to it is retained.mappingFileNames - a Collection of classpath
resource names identifying JPA mapping files; may be null. The Collection is copied and no reference to it
is retained.jtaDataSourceName - the name of a data source that may be
enrolled in JTA-compliant transactions; may be nullnonJtaDataSourceName - the name of a data source that
should not be enrolled in JTA-compliant transactions; may be
nulldataSourceProvider - a PersistenceUnitInfoBean.DataSourceProvider capable
of supplying DataSource instances; must not be nullproperties - a Properties object representing the
properties of the persistence unit represented by this PersistenceUnitInfoBean; may be null. A reference is
retained to this object.sharedCacheMode - the SharedCacheMode this PersistenceUnitInfoBean will use; may be null in which
case SharedCacheMode.UNSPECIFIED will be used insteadtransactionType - the PersistenceUnitTransactionType this PersistenceUnitInfoBean will use; may be null in which
case PersistenceUnitTransactionType.JTA will be used
insteadvalidationMode - the ValidationMode this PersistenceUnitInfoBean will use; may be null in which
case ValidationMode.AUTO will be used insteadNullPointerException - if persistenceUnitName,
persistenceUnitRootUrl or dataSourceProvider is
nullgetPersistenceUnitName(),
getPersistenceUnitRootUrl(),
getPersistenceXMLSchemaVersion(),
getPersistenceProviderClassName(),
getClassLoader(),
getNewTempClassLoader(),
excludeUnlistedClasses(),
getJarFileUrls(),
getManagedClassNames(),
getMappingFileNames(),
getJtaDataSource(),
getNonJtaDataSource(),
getProperties(),
getSharedCacheMode(),
getTransactionType(),
getValidationMode()public List<URL> getJarFileUrls()
getJarFileUrls in interface PersistenceUnitInfopublic URL getPersistenceUnitRootUrl()
getPersistenceUnitRootUrl in interface PersistenceUnitInfopublic List<String> getManagedClassNames()
getManagedClassNames in interface PersistenceUnitInfopublic boolean excludeUnlistedClasses()
excludeUnlistedClasses in interface PersistenceUnitInfopublic SharedCacheMode getSharedCacheMode()
getSharedCacheMode in interface PersistenceUnitInfopublic ValidationMode getValidationMode()
getValidationMode in interface PersistenceUnitInfopublic Properties getProperties()
getProperties in interface PersistenceUnitInfopublic ClassLoader getClassLoader()
getClassLoader in interface PersistenceUnitInfopublic String getPersistenceXMLSchemaVersion()
getPersistenceXMLSchemaVersion in interface PersistenceUnitInfopublic ClassLoader getNewTempClassLoader()
getNewTempClassLoader in interface PersistenceUnitInfopublic void addTransformer(ClassTransformer classTransformer)
addTransformer in interface PersistenceUnitInfopublic String getPersistenceUnitName()
getPersistenceUnitName in interface PersistenceUnitInfopublic String getPersistenceProviderClassName()
getPersistenceProviderClassName in interface PersistenceUnitInfopublic PersistenceUnitTransactionType getTransactionType()
getTransactionType in interface PersistenceUnitInfopublic final DataSource getJtaDataSource()
getJtaDataSource in interface PersistenceUnitInfopublic final DataSource getNonJtaDataSource()
getNonJtaDataSource in interface PersistenceUnitInfopublic List<String> getMappingFileNames()
getMappingFileNames in interface PersistenceUnitInfopublic static final Collection<? extends PersistenceUnitInfoBean> fromPersistence(Persistence persistence, ClassLoader classLoader, Supplier<? extends ClassLoader> tempClassLoaderSupplier, URL rootUrl, Map<? extends String,? extends Set<? extends Class<?>>> unlistedClasses, PersistenceUnitInfoBean.DataSourceProvider dataSourceProvider) throws MalformedURLException
Persistence (a Java object representation of a
META-INF/persistence.xml resource), a URL
representing the root of all persistence units, a Map
of unlisted managed classes (entity classes, mapped
superclasses and so on) indexed by persistence unit name, and a
PersistenceUnitInfoBean.DataSourceProvider that can provide DataSource
instances, returns a Collection of PersistenceUnitInfoBean instances representing all the
persistence units in play.
This method never returns null.
persistence - a Persistence containing bootstrap
information from which persistence units and their
configuration may be deduced; may be null in which case
an empty Collection
will be returnedclassLoader - a ClassLoader that the resulting
PersistenceUnitInfoBean instances will use; may be
nulltempClassLoaderSupplier - a Supplier of a ClassLoader that will be used to implement the PersistenceUnitInfo.getNewTempClassLoader() method; may be
nullrootUrl - the URL representing the root of all
persistence units; must not be nullunlistedClasses - a Map of managed classes indexed
by persistence unit name whose values might not be explicitly
listed in a Persistence.PersistenceUnit; may be nulldataSourceProvider - a PersistenceUnitInfoBean.DataSourceProvider; must
not be nullnull Collection of PersistenceUnitInfoBean instancesMalformedURLException - if a URL could not be
constructedNullPointerException - if rootUrl or dataSourceProvider is nullfromPersistenceUnit(Persistence.PersistenceUnit,
ClassLoader, Supplier, URL, Map, DataSourceProvider),
PersistenceUnitInfopublic static final PersistenceUnitInfoBean fromPersistenceUnit(Persistence.PersistenceUnit persistenceUnit, URL rootUrl, Map<? extends String,? extends Set<? extends Class<?>>> unlistedClasses, PersistenceUnitInfoBean.DataSourceProvider dataSourceProvider) throws MalformedURLException
Persistence.PersistenceUnit (a Java object representation
of a <persistence-unit> element in a META-INF/persistence.xml resource), a URL representing
the persistence unit's root, a Map of unlisted managed
classes (entity classes, mapped superclasses and so on) indexed
by persistence unit name, and a PersistenceUnitInfoBean.DataSourceProvider that
can supply DataSource instances, returns a PersistenceUnitInfoBean representing the persistence unit in
question.
This method never returns null.
This method calls the fromPersistenceUnit(Persistence.PersistenceUnit, ClassLoader,
Supplier, URL, Map, DataSourceProvider) method using the
return value of the Thread.getContextClassLoader()
method as the ClassLoader.
persistenceUnit - a Persistence.PersistenceUnit; must not be
nullrootUrl - the URL representing the root of the
persistence unit; must not be nullunlistedClasses - a Map of managed classes indexed
by persistence unit name whose values might not be explicitly
listed in the supplied Persistence.PersistenceUnit; may be nulldataSourceProvider - a PersistenceUnitInfoBean.DataSourceProvider; must not
be nullnull PersistenceUnitInfoBeanMalformedURLException - if a URL could not be
constructedNullPointerException - if persistenceUnit,
rootUrl or dataSourceProvider is nullfromPersistenceUnit(Persistence.PersistenceUnit,
ClassLoader, Supplier, URL, Map, DataSourceProvider),
Persistence.PersistenceUnit,
PersistenceUnitInfopublic static final PersistenceUnitInfoBean fromPersistenceUnit(Persistence.PersistenceUnit persistenceUnit, ClassLoader classLoader, Supplier<? extends ClassLoader> tempClassLoaderSupplier, URL rootUrl, Map<? extends String,? extends Set<? extends Class<?>>> unlistedClasses, PersistenceUnitInfoBean.DataSourceProvider dataSourceProvider) throws MalformedURLException
Persistence.PersistenceUnit (a Java object representation
of a <persistence-unit> element in a META-INF/persistence.xml resource), a ClassLoader for
loading JPA classes and resources, a Supplier of ClassLoader instances for helping to implement the PersistenceUnitInfo.getNewTempClassLoader() method, a URL representing the persistence unit's root, a Map of
unlisted managed classes (entity classes, mapped superclasses
and so on) indexed by persistence unit name, and a PersistenceUnitInfoBean.DataSourceProvider that can provide DataSource
instances, returns a PersistenceUnitInfoBean
representing the persistence unit in question.
This method never returns null.
persistenceUnit - a Persistence.PersistenceUnit; must not be
nullclassLoader - a ClassLoader that the resulting
PersistenceUnitInfoBean will use; may be nulltempClassLoaderSupplier - a Supplier of a ClassLoader that will be used to implement the PersistenceUnitInfo.getNewTempClassLoader() method; may be
nullrootUrl - the URL representing the root of the
persistence unit; must not be nullunlistedClasses - a Map of managed classes indexed
by persistence unit name whose values might not be explicitly
listed in the supplied Persistence.PersistenceUnit; may be nulldataSourceProvider - a PersistenceUnitInfoBean.DataSourceProvider; must
not be nullnull PersistenceUnitInfoBeanMalformedURLException - if a URL could not be
constructedNullPointerException - if persistenceUnit or
rootUrl is nullPersistence.PersistenceUnit,
PersistenceUnitInfoCopyright © 2018–2019 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms.