|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.clazzes.util.jpa.provider.PersistenceUnitInfoImpl
public class PersistenceUnitInfoImpl
A PersistenceUnitInfo
implementation, which takes care for temporary class loader,
an application class loader and enhancer support through the aop-util-agent.
If you enable full enhancer support through the aop-util-agent by setting the
instrumentationKey
property, please call the destroy()
method when
your bundle stops.
A typical usage of this class in a blueprint context is like follows:
<bp:bean id="persistenceUnitInfo" class="org.clazzes.util.jpa.provider.PersistenceUnitInfoImpl" destroy-method="destroy"> <bp:property name="temporaryClassLoaderClass" ref="temporaryClassLoaderClass"/> <bp:property name="classLoaderHint" value="org.example.SampleClass"/> <bp:property name="nonJtaDataSource" ref="dataSource"></bp:property> <bp:property name="persistenceUnitName" value="fancymail-server"/> <bp:property name="instrumentationKey" value="jpa-util-agent-instrumentation"/> <bp:property name="managedClassNames"> <bp:list> <bp:value>org.example.entities.Entity1</bp:value> <bp:value>org.example.entities.Entity2</bp:value> <bp:value>org.example.entities.Entity3</bp:value> </bp:list> </bp:property> <bp:property name="properties"> <bp:props> <bp:prop key="openjpa.RuntimeUnenhancedClasses" value="unsupported"/> <bp:prop key="openjpa.MetaDataRepository" value="Preload=true"/> </bp:props> </bp:property> </bp:bean>
Constructor Summary | |
---|---|
PersistenceUnitInfoImpl()
|
Method Summary | |
---|---|
void |
addJarFile(java.net.URL jar)
|
void |
addManagedClassName(java.lang.String name)
Add a class name to the list of managed entites. |
void |
addMappingFileName(java.lang.String name)
|
void |
addTransformer(javax.persistence.spi.ClassTransformer transformer)
Add a class transformer to the Instrumentation instance provided
by jpa-util-agent under the key getInstrumentationKey() . |
void |
destroy()
Remove all transformers registered in addTransformer(ClassTransformer)
from the Instrumentation instance of jpa-util-agent. |
boolean |
excludeUnlistedClasses()
|
protected void |
finalize()
|
java.lang.ClassLoader |
getClassLoader()
Return the application's class loader. |
java.lang.String |
getInstrumentationKey()
|
java.util.List<java.net.URL> |
getJarFileUrls()
|
javax.sql.DataSource |
getJtaDataSource()
|
java.lang.String |
getJtaDataSourceName()
|
java.util.List<java.lang.String> |
getManagedClassNames()
Return the list of class names of managed entites. |
java.util.List<java.lang.String> |
getMappingFileNames()
|
java.lang.ClassLoader |
getNewTempClassLoader()
Instantiate a new temporary class loader, when setTemporaryClassLoaderClass(Class)
has been set. |
javax.sql.DataSource |
getNonJtaDataSource()
|
java.lang.String |
getNonJtaDataSourceName()
|
java.lang.String |
getPersistenceProviderClassName()
|
java.lang.String |
getPersistenceUnitName()
|
java.net.URL |
getPersistenceUnitRootUrl()
|
java.net.URL |
getPersistenceXmlFileUrl()
The location of the persistence.xml resource. |
java.lang.String |
getPersistenceXMLSchemaVersion()
|
java.util.Properties |
getProperties()
|
javax.persistence.SharedCacheMode |
getSharedCacheMode()
|
java.io.File |
getSourceFile()
|
javax.persistence.spi.PersistenceUnitTransactionType |
getTransactionType()
The transaction type. |
javax.persistence.ValidationMode |
getValidationMode()
|
boolean |
isDestroyed()
|
void |
setClassLoader(java.lang.ClassLoader classLoader)
Set the application class loader. |
void |
setClassLoaderHint(java.lang.Class<?> classLoaderHint)
Set the class which is used to retrieve the application class loader. |
void |
setExcludeUnlistedClasses(boolean excludeUnlisted)
|
void |
setInstrumentationKey(java.lang.String instrumentationKey)
|
void |
setJarFileUrls(java.util.List<java.net.URL> jarFileUrls)
|
void |
setJtaDataSource(javax.sql.DataSource ds)
This method and setJtaDataSourceName(String) are mutually exclusive. |
void |
setJtaDataSourceName(java.lang.String jta)
This method and setJtaDataSource(DataSource) are mutually exclusive. |
void |
setManagedClassNames(java.util.List<java.lang.String> managedClassNames)
Set the list of class names of managed entites. |
void |
setMappingFileNames(java.util.List<java.lang.String> mappingFileNames)
|
void |
setNonJtaDataSource(javax.sql.DataSource ds)
This method and setJtaDataSourceName(String) are mutually exclusive. |
void |
setNonJtaDataSourceName(java.lang.String nonJta)
This method and setNonJtaDataSource(DataSource) are mutually exclusive. |
void |
setPersistenceProviderClassName(java.lang.String providerClassName)
|
void |
setPersistenceUnitName(java.lang.String emName)
|
void |
setPersistenceUnitRootUrl(java.net.URL root)
|
void |
setPersistenceXmlFileUrl(java.net.URL url)
The location of the persistence.xml resource. |
void |
setPersistenceXMLSchemaVersion(java.lang.String version)
|
void |
setProperties(java.util.Properties props)
|
void |
setProperty(java.lang.String key,
java.lang.String value)
|
void |
setSharedCacheMode(javax.persistence.SharedCacheMode mode)
|
void |
setTemporaryClassLoaderClass(java.lang.Class temporaryClassLoaderClass)
The class of the temporary class laoder, which will be instantiated in getNewTempClassLoader() . |
void |
setTransactionType(javax.persistence.spi.PersistenceUnitTransactionType transType)
Set the transaction type. |
void |
setValidationMode(javax.persistence.ValidationMode mode)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PersistenceUnitInfoImpl()
Method Detail |
---|
public java.lang.ClassLoader getClassLoader()
getClassLoader
in interface javax.persistence.spi.PersistenceUnitInfo
setClassLoader(ClassLoader)
,
setClassLoaderHint(Class)
public java.lang.ClassLoader getNewTempClassLoader()
setTemporaryClassLoaderClass(Class)
has been set. Otherwise return the application class loader.
getNewTempClassLoader
in interface javax.persistence.spi.PersistenceUnitInfo
public java.lang.String getPersistenceUnitName()
getPersistenceUnitName
in interface javax.persistence.spi.PersistenceUnitInfo
public void setPersistenceUnitName(java.lang.String emName)
public java.lang.String getPersistenceProviderClassName()
getPersistenceProviderClassName
in interface javax.persistence.spi.PersistenceUnitInfo
public void setPersistenceProviderClassName(java.lang.String providerClassName)
public javax.persistence.spi.PersistenceUnitTransactionType getTransactionType()
PersistenceUnitTransactionType.RESOURCE_LOCAL
.
getTransactionType
in interface javax.persistence.spi.PersistenceUnitInfo
public void setTransactionType(javax.persistence.spi.PersistenceUnitTransactionType transType)
PersistenceUnitTransactionType.RESOURCE_LOCAL
.
transType
- The transaction type.PersistenceUnitTransactionType.RESOURCE_LOCAL
,
PersistenceUnitTransactionType.JTA
public java.lang.String getJtaDataSourceName()
PersistenceUnitTransactionType.JTA
.public void setJtaDataSourceName(java.lang.String jta)
setJtaDataSource(DataSource)
are mutually exclusive. You need
to specify either a JNDI name or a datasource iself.
jta
- The JNDI name of the datasource to set, when the transaction type is
PersistenceUnitTransactionType.JTA
.public javax.sql.DataSource getJtaDataSource()
getJtaDataSource
in interface javax.persistence.spi.PersistenceUnitInfo
PersistenceUnitTransactionType.JTA
.public void setJtaDataSource(javax.sql.DataSource ds)
setJtaDataSourceName(String)
are mutually exclusive. You need
to specify either a JNDI name or a datasource iself.
ds
- The datasource to use when the transaction type is
PersistenceUnitTransactionType.JTA
.public java.lang.String getNonJtaDataSourceName()
PersistenceUnitTransactionType.RESOURCE_LOCAL
.public void setNonJtaDataSourceName(java.lang.String nonJta)
setNonJtaDataSource(DataSource)
are mutually exclusive. You need
to specify either a JNDI name or a datasource iself.
jta
- The JNDI name of the datasource to set, when the transaction type is
PersistenceUnitTransactionType.RESOURCE_LOCAL
.public javax.sql.DataSource getNonJtaDataSource()
getNonJtaDataSource
in interface javax.persistence.spi.PersistenceUnitInfo
PersistenceUnitTransactionType.RESOURCE_LOCAL
.public void setNonJtaDataSource(javax.sql.DataSource ds)
setJtaDataSourceName(String)
are mutually exclusive. You need
to specify either a JNDI name or a datasource iself.
ds
- The datasource to use when the transaction type is
PersistenceUnitTransactionType.RESOURCE_LOCAL
.public java.net.URL getPersistenceUnitRootUrl()
getPersistenceUnitRootUrl
in interface javax.persistence.spi.PersistenceUnitInfo
public void setPersistenceUnitRootUrl(java.net.URL root)
public boolean excludeUnlistedClasses()
excludeUnlistedClasses
in interface javax.persistence.spi.PersistenceUnitInfo
public void setExcludeUnlistedClasses(boolean excludeUnlisted)
public java.util.List<java.lang.String> getMappingFileNames()
getMappingFileNames
in interface javax.persistence.spi.PersistenceUnitInfo
public void addMappingFileName(java.lang.String name)
public void setMappingFileNames(java.util.List<java.lang.String> mappingFileNames)
public java.util.List<java.net.URL> getJarFileUrls()
getJarFileUrls
in interface javax.persistence.spi.PersistenceUnitInfo
public void addJarFile(java.net.URL jar)
public void setJarFileUrls(java.util.List<java.net.URL> jarFileUrls)
public java.util.List<java.lang.String> getManagedClassNames()
getManagedClassNames
in interface javax.persistence.spi.PersistenceUnitInfo
public void addManagedClassName(java.lang.String name)
name
- The name of an entity.public void setManagedClassNames(java.util.List<java.lang.String> managedClassNames)
managedClassNames
- Class names of managed entites to set.public java.util.Properties getProperties()
getProperties
in interface javax.persistence.spi.PersistenceUnitInfo
public void setProperty(java.lang.String key, java.lang.String value)
public void setProperties(java.util.Properties props)
public void addTransformer(javax.persistence.spi.ClassTransformer transformer)
Add a class transformer to the Instrumentation
instance provided
by jpa-util-agent under the key getInstrumentationKey()
.
If the instrumentation key is not set or the agent has not been loaded by the JVM,
this method throws an UnsupportedOperationException
.
addTransformer
in interface javax.persistence.spi.PersistenceUnitInfo
transformer
- The class transformer to add.public java.net.URL getPersistenceXmlFileUrl()
public void setPersistenceXmlFileUrl(java.net.URL url)
public java.io.File getSourceFile()
public java.lang.String getPersistenceXMLSchemaVersion()
getPersistenceXMLSchemaVersion
in interface javax.persistence.spi.PersistenceUnitInfo
public void setPersistenceXMLSchemaVersion(java.lang.String version)
public javax.persistence.ValidationMode getValidationMode()
getValidationMode
in interface javax.persistence.spi.PersistenceUnitInfo
public void setValidationMode(javax.persistence.ValidationMode mode)
public javax.persistence.SharedCacheMode getSharedCacheMode()
getSharedCacheMode
in interface javax.persistence.spi.PersistenceUnitInfo
public void setSharedCacheMode(javax.persistence.SharedCacheMode mode)
public void setClassLoader(java.lang.ClassLoader classLoader)
setClassLoaderHint(Class)
.
classLoader
- The application class loader.public void setClassLoaderHint(java.lang.Class<?> classLoaderHint)
classLoaderHint
- A class on which to call getClassLoader()
in order to retrieve the application class loader. Please do no use an
entity class, which has to be enhanced in this place.public void setTemporaryClassLoaderClass(java.lang.Class temporaryClassLoaderClass)
getNewTempClassLoader()
.
public java.lang.String getInstrumentationKey()
Agent.getInstrumentation(String)
. If set to null
,
addTransformer(ClassTransformer)
throws an
UnsupportedOperationException
.public void setInstrumentationKey(java.lang.String instrumentationKey)
instrumentationKey
- the key for Agent.getInstrumentation(String)
to set.public void destroy() throws javax.security.auth.DestroyFailedException
addTransformer(ClassTransformer)
from the Instrumentation
instance of jpa-util-agent.
destroy
in interface javax.security.auth.Destroyable
javax.security.auth.DestroyFailedException
public boolean isDestroyed()
isDestroyed
in interface javax.security.auth.Destroyable
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |