org.objectweb.easybeans.persistence.xml
Class JPersistenceUnitInfo

java.lang.Object
  extended by org.objectweb.easybeans.persistence.xml.JPersistenceUnitInfo
All Implemented Interfaces:
PersistenceUnitInfo

public class JPersistenceUnitInfo
extends java.lang.Object
implements PersistenceUnitInfo

Implementation of the PersistenceUnitInfo interface. It is given to the persistence provider to create entity managers.

Author:
Florent Benoit

Field Summary
private  java.lang.ClassLoader classLoader
          ClassLoader that the provider may use to load any classes, resources, or open URLs.
private  java.util.List<javax.persistence.spi.ClassTransformer> classTransformers
          List of Class Transformers.
private  boolean excludeUnlistedClasses
          Whether classes in the root of the persistence unit that have not been explicitly listed are to be included in the set of managed classes.
private  java.util.List<java.net.URL> jarFiles
          The list of JAR file URLs that the persistence provider must look in to find the entity classes that must be managed by EntityManagers of this name.
private  javax.sql.DataSource jtaDataSource
          JTA-enabled data source.
private  java.lang.String jtaDataSourceName
          JTA-enabled data source name.
private  java.util.List<java.lang.String> managedClassNames
          The list of the names of the classes that the persistence provider must add it to its set of managed classes.
private  java.util.List<java.lang.String> mappingFileNames
          The list of mapping file names that the persistence provider must load to determine the mappings for the entity classes.
private  javax.sql.DataSource nonJtaDataSource
          The non-JTA-enabled data source.
private  java.lang.String nonJtaDataSourceName
          The non-JTA-enabled data source name.
private  javax.persistence.spi.PersistenceProvider persistenceProvider
          Persistence provider (instantiated object).
private  java.lang.String persistenceProviderClassName
          Persistence provider implementation class name.
private  java.lang.String persistenceUnitName
          Name of the persistence unit.
private  java.net.URL persistenceUnitRootUrl
          URL for the jar file or directory that is the root of the persistence unit.
private  java.net.URL persistenceXmlFileUrl
          URL object that points to the persistence.xml file.
private  java.util.Properties properties
          Properties object that may contain vendor-specific properties contained in the persistence.xml file.
private  java.lang.ClassLoader tempClassLoader
          ClassLoader that the provider may use to temporarily load any classes, resources, or open URLs.
private  PersistenceUnitTransactionType transactionType
          Transaction type of the entity managers created by the EntityManagerFactory.
 
Constructor Summary
JPersistenceUnitInfo()
          Default constructor.
 
Method Summary
 void addClass(java.lang.String className)
          Adds a class that the persistence provider must add it to its set of managed classes.
 void addJarFile(java.net.URL jarFile)
          Adds a jar file to the list of JAR file URLs that the persistence provider must look in to find the entity classes that must be managed by EntityManagers of this name.
 void addMappingFileName(java.lang.String mappingFileName)
          Adds a filename to the list of mapping file names.
 void addTransformer(javax.persistence.spi.ClassTransformer transformer)
          Add a transformer supplied by the provider that will be called for every new class definition or class redefinition that gets loaded by the loader returned by the PersistenceInfo.getClassLoader method.
 boolean excludeUnlistedClasses()
           
 java.lang.ClassLoader getClassLoader()
           
 java.util.List<java.net.URL> getJarFiles()
           
 java.util.List<java.net.URL> getJarFileUrls()
           
 javax.sql.DataSource getJtaDataSource()
           
 java.lang.String getJtaDataSourceName()
          Gets the jta datasource name.
 java.util.List<java.lang.String> getManagedClassNames()
           
 java.util.List<java.lang.String> getMappingFileNames()
           
 java.lang.ClassLoader getNewTempClassLoader()
          Return a new instance of a ClassLoader that the provider may use to temporarily load any classes, resources, or open URLs.
 javax.sql.DataSource getNonJtaDataSource()
           
 java.lang.String getNonJtaDataSourceName()
          Gets the non jta datasource name.
 javax.persistence.spi.PersistenceProvider getPersistenceProvider()
           
 java.lang.String getPersistenceProviderClassName()
           
 java.lang.String getPersistenceUnitName()
           
 java.net.URL getPersistenceUnitRootUrl()
           
 java.net.URL getPersistenceXmlFileUrl()
           
 java.util.Properties getProperties()
           
 PersistenceUnitTransactionType getTransactionType()
           
 void setClassLoader(java.lang.ClassLoader classLoader)
          Sets the classloader.
 void setExcludeUnlistedClasses(boolean excludeUnlistedClasses)
          Sets the boolean defining if the persistence unit that have not been explicitly listed are to be included in the set of managed classes.
 void setJtaDataSource(javax.sql.DataSource jtaDataSource)
          Sets the JTA-enabled data source.
 void setJtaDataSourceName(java.lang.String jtaDataSourceName)
          Sets the JTA-enabled data source name.
 void setNonJtaDataSource(javax.sql.DataSource nonJtaDataSource)
          Sets the non-JTA-enabled data source.
 void setNonJtaDataSourceName(java.lang.String nonJtaDataSourceName)
          Sets the non-JTA-enabled data source name.
 void setPersistenceProvider(javax.persistence.spi.PersistenceProvider persistenceProvider)
          Sets the persistence provider object.
 void setPersistenceProviderClassName(java.lang.String persistenceProviderClassName)
          Sets the persistence provider implementation class name.
 void setPersistenceUnitName(java.lang.String persistenceUnitName)
          Sets the name of the persistence unit.
 void setPersistenceUnitRootUrl(java.net.URL persistenceUnitRootUrl)
          Sets the URL for the jar file or directory that is the root of the persistence unit.
 void setPersistenceXmlFileUrl(java.net.URL persistenceXmlFileUrl)
          Sets the URL object that points to the persistence.xml file.
 void setProperties(java.util.Properties properties)
          Sets the properties use by this unit.
 void setTransactionType(PersistenceUnitTransactionType transactionType)
          Sets the transaction type of the entity managers created by the EntityManagerFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

persistenceUnitName

private java.lang.String persistenceUnitName
Name of the persistence unit. Corresponds to the <name> element in the persistence.xml file.


persistenceProviderClassName

private java.lang.String persistenceProviderClassName
Persistence provider implementation class name.


transactionType

private PersistenceUnitTransactionType transactionType
Transaction type of the entity managers created by the EntityManagerFactory. The transaction type corresponds to the transaction-type attribute in the persistence.xml file.


jtaDataSource

private javax.sql.DataSource jtaDataSource
JTA-enabled data source.


nonJtaDataSource

private javax.sql.DataSource nonJtaDataSource
The non-JTA-enabled data source.


jtaDataSourceName

private java.lang.String jtaDataSourceName
JTA-enabled data source name.


nonJtaDataSourceName

private java.lang.String nonJtaDataSourceName
The non-JTA-enabled data source name.


mappingFileNames

private java.util.List<java.lang.String> mappingFileNames
The list of mapping file names that the persistence provider must load to determine the mappings for the entity classes.


jarFiles

private java.util.List<java.net.URL> jarFiles
The list of JAR file URLs that the persistence provider must look in to find the entity classes that must be managed by EntityManagers of this name.


persistenceUnitRootUrl

private java.net.URL persistenceUnitRootUrl
URL for the jar file or directory that is the root of the persistence unit. (If the persistence unit is rooted in the WEB-INF/classes directory, this will be the URL of that directory.)


managedClassNames

private java.util.List<java.lang.String> managedClassNames
The list of the names of the classes that the persistence provider must add it to its set of managed classes. Each name corresponds to a named <class> element in the persistence.xml file.


excludeUnlistedClasses

private boolean excludeUnlistedClasses
Whether classes in the root of the persistence unit that have not been explicitly listed are to be included in the set of managed classes. This value corresponds to the <exclude-unlisted-classes> element in the persistence.xml file.


properties

private java.util.Properties properties
Properties object that may contain vendor-specific properties contained in the persistence.xml file.


classLoader

private java.lang.ClassLoader classLoader
ClassLoader that the provider may use to load any classes, resources, or open URLs.


tempClassLoader

private java.lang.ClassLoader tempClassLoader
ClassLoader that the provider may use to temporarily load any classes, resources, or open URLs.


persistenceXmlFileUrl

private java.net.URL persistenceXmlFileUrl
URL object that points to the persistence.xml file.


classTransformers

private java.util.List<javax.persistence.spi.ClassTransformer> classTransformers
List of Class Transformers. Transformer is called when the Container invokes at class-(re)definition time


persistenceProvider

private javax.persistence.spi.PersistenceProvider persistenceProvider
Persistence provider (instantiated object).

Constructor Detail

JPersistenceUnitInfo

public JPersistenceUnitInfo()
Default constructor.

Method Detail

setClassLoader

public void setClassLoader(java.lang.ClassLoader classLoader)
Sets the classloader.

Parameters:
classLoader - that the provider may use to load any classes, resources, or open URLs.

setPersistenceUnitName

public void setPersistenceUnitName(java.lang.String persistenceUnitName)
Sets the name of the persistence unit.

Parameters:
persistenceUnitName - the given name

getPersistenceUnitName

public java.lang.String getPersistenceUnitName()
Specified by:
getPersistenceUnitName in interface PersistenceUnitInfo
Returns:
The name of the Persistence unit that is being created. Corresponds to the <name> element in persistence.xml

addJarFile

public void addJarFile(java.net.URL jarFile)
Adds a jar file to the list of JAR file URLs that the persistence provider must look in to find the entity classes that must be managed by EntityManagers of this name.

Parameters:
jarFile - URL of the jar file

setJtaDataSource

public void setJtaDataSource(javax.sql.DataSource jtaDataSource)
Sets the JTA-enabled data source.

Parameters:
jtaDataSource - given datasource.

setNonJtaDataSource

public void setNonJtaDataSource(javax.sql.DataSource nonJtaDataSource)
Sets the non-JTA-enabled data source.

Parameters:
nonJtaDataSource - given datasource.

setJtaDataSourceName

public void setJtaDataSourceName(java.lang.String jtaDataSourceName)
Sets the JTA-enabled data source name.

Parameters:
jtaDataSourceName - given name.

setNonJtaDataSourceName

public void setNonJtaDataSourceName(java.lang.String nonJtaDataSourceName)
Sets the non-JTA-enabled data source name.

Parameters:
nonJtaDataSourceName - given name.

addMappingFileName

public void addMappingFileName(java.lang.String mappingFileName)
Adds a filename to the list of mapping file names.

Parameters:
mappingFileName - name of the mapping file to add.

setPersistenceProviderClassName

public void setPersistenceProviderClassName(java.lang.String persistenceProviderClassName)
Sets the persistence provider implementation class name.

Parameters:
persistenceProviderClassName - name of the class.

setPersistenceProvider

public void setPersistenceProvider(javax.persistence.spi.PersistenceProvider persistenceProvider)
Sets the persistence provider object.

Parameters:
persistenceProvider - the persistence provider object used.

setPersistenceXmlFileUrl

public void setPersistenceXmlFileUrl(java.net.URL persistenceXmlFileUrl)
Sets the URL object that points to the persistence.xml file.

Parameters:
persistenceXmlFileUrl - URL pointing to persistence.xml file

setProperties

public void setProperties(java.util.Properties properties)
Sets the properties use by this unit.

Parameters:
properties - object with key/value.

getPersistenceProviderClassName

public java.lang.String getPersistenceProviderClassName()
Specified by:
getPersistenceProviderClassName in interface PersistenceUnitInfo
Returns:
The name of the persistence provider implementation class. Corresponds to the <provider> element in persistence.xml

getPersistenceProvider

public javax.persistence.spi.PersistenceProvider getPersistenceProvider()
Returns:
The persistence provider implementation object.

getJtaDataSource

public javax.sql.DataSource getJtaDataSource()
Specified by:
getJtaDataSource in interface PersistenceUnitInfo
Returns:
the JTA-enabled data source to be used by the persistence provider. The data source corresponds to the named <jta-data-source> element in persistence.xml

getNonJtaDataSource

public javax.sql.DataSource getNonJtaDataSource()
Specified by:
getNonJtaDataSource in interface PersistenceUnitInfo
Returns:
The non-JTA-enabled data source to be used by the persistence provider when outside the container, or inside the container when accessing data outside the global transaction. The data source corresponds to the named <non-jta-data-source> element in persistence.xml

getMappingFileNames

public java.util.List<java.lang.String> getMappingFileNames()
Specified by:
getMappingFileNames in interface PersistenceUnitInfo
Returns:
The list of mapping file names that the persistence provider must load to determine the mappings for the entity classes. The mapping files must be in the standard XML mapping format, be uniquely named and be resource-loadable from the application classpath. This list will not include the entity-mappings.xml file if one was specified. Each mapping file name corresponds to a <mapping-file> element in persistence.xml

getJarFiles

public java.util.List<java.net.URL> getJarFiles()
Returns:
The list of JAR file URLs that the persistence provider must look in to find the entity classes that must be managed by EntityManagers of this name. The persistence archive jar itself will always be the last entry in the list. Each jar file URL corresponds to a named <jar-file> element in persistence.xml

getProperties

public java.util.Properties getProperties()
Specified by:
getProperties in interface PersistenceUnitInfo
Returns:
Properties object that may contain vendor-specific properties contained in the persistence.xml file. Each property corresponds to a <property> element in persistence.xml

getClassLoader

public java.lang.ClassLoader getClassLoader()
Specified by:
getClassLoader in interface PersistenceUnitInfo
Returns:
ClassLoader that the provider may use to load any classes, resources, or open URLs.

getPersistenceXmlFileUrl

public java.net.URL getPersistenceXmlFileUrl()
Returns:
URL object that points to the persistence.xml file; useful for providers that may need to re-read the persistence.xml file. If no persistence.xml file is present in the persistence archive, null is returned.

getJtaDataSourceName

public java.lang.String getJtaDataSourceName()
Gets the jta datasource name.

Returns:
jta datasource name.

getNonJtaDataSourceName

public java.lang.String getNonJtaDataSourceName()
Gets the non jta datasource name.

Returns:
non jta datasource name

getTransactionType

public PersistenceUnitTransactionType getTransactionType()
Specified by:
getTransactionType in interface PersistenceUnitInfo
Returns:
The transaction type of the entity managers created by the EntityManagerFactory. The transaction type corresponds to the transaction-type attribute in the persistence.xml file.

setTransactionType

public void setTransactionType(PersistenceUnitTransactionType transactionType)
Sets the transaction type of the entity managers created by the EntityManagerFactory.

Parameters:
transactionType - The transaction type corresponds to the transaction-type attribute in the persistence.xml file.

getJarFileUrls

public java.util.List<java.net.URL> getJarFileUrls()
Specified by:
getJarFileUrls in interface PersistenceUnitInfo
Returns:
The list of JAR file URLs that the persistence provider must examine for managed classes of the persistence unit. Each jar file URL corresponds to a named <jar-file> element in the persistence.xml file.

setPersistenceUnitRootUrl

public void setPersistenceUnitRootUrl(java.net.URL persistenceUnitRootUrl)
Sets the URL for the jar file or directory that is the root of the persistence unit.

Parameters:
persistenceUnitRootUrl - root url of persistence unit

getPersistenceUnitRootUrl

public java.net.URL getPersistenceUnitRootUrl()
Specified by:
getPersistenceUnitRootUrl in interface PersistenceUnitInfo
Returns:
The URL for the jar file or directory that is the root of the persistence unit. (If the persistence unit is rooted in the WEB-INF/classes directory, this will be the URL of that directory.)

addClass

public void addClass(java.lang.String className)
Adds a class that the persistence provider must add it to its set of managed classes.

Parameters:
className - name of the class

getManagedClassNames

public java.util.List<java.lang.String> getManagedClassNames()
Specified by:
getManagedClassNames in interface PersistenceUnitInfo
Returns:
The list of the names of the classes that the persistence provider must add it to its set of managed classes. Each name corresponds to a named <class> element in the persistence.xml file.

setExcludeUnlistedClasses

public void setExcludeUnlistedClasses(boolean excludeUnlistedClasses)
Sets the boolean defining if the persistence unit that have not been explicitly listed are to be included in the set of managed classes.

Parameters:
excludeUnlistedClasses - true/false

excludeUnlistedClasses

public boolean excludeUnlistedClasses()
Specified by:
excludeUnlistedClasses in interface PersistenceUnitInfo
Returns:
Whether classes in the root of the persistence unit that have not been explicitly listed are to be included in the set of managed classes. This value corresponds to the <exclude-unlisted-classes> element in the persistence.xml file.

addTransformer

public void addTransformer(javax.persistence.spi.ClassTransformer transformer)
Add a transformer supplied by the provider that will be called for every new class definition or class redefinition that gets loaded by the loader returned by the PersistenceInfo.getClassLoader method. The transformer has no effect on the result returned by the PersistenceInfo.getTempClassLoader method. Classes are only transformed once within the same classloading scope, regardless of how many persistence units they may be a part of.

Specified by:
addTransformer in interface PersistenceUnitInfo
Parameters:
transformer - A provider-supplied transformer that the Container invokes at class-(re)definition time

getNewTempClassLoader

public java.lang.ClassLoader getNewTempClassLoader()
Return a new instance of a ClassLoader that the provider may use to temporarily load any classes, resources, or open URLs. The scope and classpath of this loader is exactly the same as that of the loader returned by PersistenceInfo.getClassLoader. None of the classes loaded by this class loader will be visible to application components. The container does not use or maintain references to this class loader after returning it to the provider.

Specified by:
getNewTempClassLoader in interface PersistenceUnitInfo
Returns:
Temporary ClassLoader with same visibility as current loader