org.hibernate.ejb
Class Ejb3Configuration

java.lang.Object
  extended by org.hibernate.ejb.Ejb3Configuration
All Implemented Interfaces:
Serializable, Referenceable

public class Ejb3Configuration
extends Object
implements Serializable, Referenceable

Allow a fine tuned configuration of an EJB 3.0 EntityManagerFactory A Ejb3Configuration object is only guaranteed to create one EntityManagerFactory. Multiple usage of #buildEntityManagerFactory() is not guaranteed. After #buildEntityManagerFactory() has been called, you no longer can change the configuration state (no class adding, no property change etc) When serialized / deserialized or retrieved from the JNDI, you no longer can change the configuration state (no class adding, no property change etc) Putting the configuration in the JNDI is an expensive operation that requires a partial serialization

Author:
Emmanuel Bernard
See Also:
Serialized Form

Constructor Summary
Ejb3Configuration()
           
 
Method Summary
 Ejb3Configuration addAnnotatedClass(Class persistentClass)
           
 void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject object)
           
 Ejb3Configuration addClass(Class persistentClass)
           
 Ejb3Configuration addFile(File xmlFile)
           
 Ejb3Configuration addFile(String xmlFile)
           
 void addFilterDefinition(FilterDefinition definition)
           
 Ejb3Configuration addInputStream(InputStream xmlInputStream)
           
 Ejb3Configuration addPackage(String packageName)
           
 Ejb3Configuration addProperties(Properties props)
           
 Ejb3Configuration addResource(String path)
           
 Ejb3Configuration addResource(String path, ClassLoader classLoader)
           
 EntityManagerFactory buildEntityManagerFactory()
           
 void buildMappings()
           
 Settings buildSettings()
           
 Ejb3Configuration configure(PersistenceMetadata metadata, Map overridesIn)
          create a factory from a parsed persistence.xml Especially the scanning of classes and additional jars is done already at this point.
 Ejb3Configuration configure(PersistenceUnitInfo info, Map integration)
          Process configuration from a PersistenceUnitInfo object; typically called by the container via PersistenceProvider.createContainerEntityManagerFactory(javax.persistence.spi.PersistenceUnitInfo, java.util.Map).
 Ejb3Configuration configure(String resource)
           
 Ejb3Configuration configure(String persistenceUnitName, Map integration)
          Build the configuration from an entity manager name and given the appropriate extra properties.
 EntityManagerFactory createEntityManagerFactory()
          Deprecated.  
 EntityManagerFactory createEntityManagerFactory(Map workingVars)
          Deprecated. use the Java Persistence API
 PersistentClass getClassMapping(String persistentClass)
           
 Iterator getClassMappings()
           
 Collection getCollectionMapping(String role)
           
 EventListeners getEventListeners()
           
 Map getFilterDefinitions()
           
 AnnotationConfiguration getHibernateConfiguration()
          This API is intended to give a read-only configuration.
 Interceptor getInterceptor()
           
 Map getNamedQueries()
           
 NamingStrategy getNamingStrategy()
           
 Properties getProperties()
           
 Reference getReference()
           
 Iterator getTableMappings()
           
 void setDataSource(DataSource ds)
          Used to inject a datasource object as the connection provider.
 void setEntityResolver(EntityResolver entityResolver)
           
 Ejb3Configuration setInterceptor(Interceptor interceptor)
           
 void setListeners(String type, Object[] listeners)
           
 void setListeners(String type, String[] listenerClasses)
           
 Ejb3Configuration setNamingStrategy(NamingStrategy namingStrategy)
           
 Ejb3Configuration setProperties(Properties properties)
           
 Ejb3Configuration setProperty(String key, String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Ejb3Configuration

public Ejb3Configuration()
Method Detail

setDataSource

public void setDataSource(DataSource ds)
Used to inject a datasource object as the connection provider. If used, be sure to not override the hibernate.connection.provider_class property


configure

public Ejb3Configuration configure(PersistenceMetadata metadata,
                                   Map overridesIn)
create a factory from a parsed persistence.xml Especially the scanning of classes and additional jars is done already at this point.

NOTE: public only for unit testing purposes; not a public API!

Parameters:
metadata - The information parsed from the persistence.xml
overridesIn - Any explicitly passed config settings
Returns:
this

configure

public Ejb3Configuration configure(String persistenceUnitName,
                                   Map integration)
Build the configuration from an entity manager name and given the appropriate extra properties. Those properties override the one get through the peristence.xml file. If the persistence unit name is not found or does not match the Persistence Provider, null is returned This method is used in a non managed environment

Parameters:
persistenceUnitName - persistence unit name
integration - properties passed to the persistence provider
Returns:
configured Ejb3Configuration or null if no persistence unit match
See Also:
HibernatePersistence.createEntityManagerFactory(String, java.util.Map)

configure

public Ejb3Configuration configure(PersistenceUnitInfo info,
                                   Map integration)
Process configuration from a PersistenceUnitInfo object; typically called by the container via PersistenceProvider.createContainerEntityManagerFactory(javax.persistence.spi.PersistenceUnitInfo, java.util.Map). In Hibernate EM, this correlates to HibernatePersistence.createContainerEntityManagerFactory(javax.persistence.spi.PersistenceUnitInfo, java.util.Map)

Parameters:
info - The persistence unit info passed in by the container (usually from processing a persistence.xml).
integration - The map of integration properties from the container to configure the provider.
Returns:
The configured EJB3Configurartion object
See Also:
HibernatePersistence.createContainerEntityManagerFactory(javax.persistence.spi.PersistenceUnitInfo, java.util.Map)

setProperty

public Ejb3Configuration setProperty(String key,
                                     String value)

createEntityManagerFactory

public EntityManagerFactory createEntityManagerFactory(Map workingVars)
Deprecated. use the Java Persistence API

create a factory from a list of properties and HibernatePersistence.CLASS_NAMES -> Collection (use to list the classes from config files HibernatePersistence.PACKAGE_NAMES -> Collection (use to list the mappings from config files HibernatePersistence.HBXML_FILES -> Collection (input streams of hbm files) HibernatePersistence.LOADED_CLASSES -> Collection (list of loaded classes)

Used by JBoss AS only


createEntityManagerFactory

public EntityManagerFactory createEntityManagerFactory()
Deprecated. 

Process configuration and build an EntityManagerFactory when the configuration is ready


buildEntityManagerFactory

public EntityManagerFactory buildEntityManagerFactory()

getReference

public Reference getReference()
                       throws NamingException
Specified by:
getReference in interface Referenceable
Throws:
NamingException

buildSettings

public Settings buildSettings()
                       throws HibernateException
Throws:
HibernateException

addProperties

public Ejb3Configuration addProperties(Properties props)

addAnnotatedClass

public Ejb3Configuration addAnnotatedClass(Class persistentClass)
                                    throws MappingException
Throws:
MappingException

configure

public Ejb3Configuration configure(String resource)
                            throws HibernateException
Throws:
HibernateException

addPackage

public Ejb3Configuration addPackage(String packageName)
                             throws MappingException
Throws:
MappingException

addFile

public Ejb3Configuration addFile(String xmlFile)
                          throws MappingException
Throws:
MappingException

addClass

public Ejb3Configuration addClass(Class persistentClass)
                           throws MappingException
Throws:
MappingException

addFile

public Ejb3Configuration addFile(File xmlFile)
                          throws MappingException
Throws:
MappingException

buildMappings

public void buildMappings()

getClassMappings

public Iterator getClassMappings()

getEventListeners

public EventListeners getEventListeners()

getTableMappings

public Iterator getTableMappings()

getClassMapping

public PersistentClass getClassMapping(String persistentClass)

getCollectionMapping

public Collection getCollectionMapping(String role)

setEntityResolver

public void setEntityResolver(EntityResolver entityResolver)

getNamedQueries

public Map getNamedQueries()

getInterceptor

public Interceptor getInterceptor()

getProperties

public Properties getProperties()

setInterceptor

public Ejb3Configuration setInterceptor(Interceptor interceptor)

setProperties

public Ejb3Configuration setProperties(Properties properties)

getFilterDefinitions

public Map getFilterDefinitions()

addFilterDefinition

public void addFilterDefinition(FilterDefinition definition)

addAuxiliaryDatabaseObject

public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject object)

getNamingStrategy

public NamingStrategy getNamingStrategy()

setNamingStrategy

public Ejb3Configuration setNamingStrategy(NamingStrategy namingStrategy)

setListeners

public void setListeners(String type,
                         String[] listenerClasses)

setListeners

public void setListeners(String type,
                         Object[] listeners)

getHibernateConfiguration

public AnnotationConfiguration getHibernateConfiguration()
This API is intended to give a read-only configuration. It is sueful when working with SchemaExport or any Configuration based tool. DO NOT update configuration through it.


addInputStream

public Ejb3Configuration addInputStream(InputStream xmlInputStream)
                                 throws MappingException
Throws:
MappingException

addResource

public Ejb3Configuration addResource(String path)
                              throws MappingException
Throws:
MappingException

addResource

public Ejb3Configuration addResource(String path,
                                     ClassLoader classLoader)
                              throws MappingException
Throws:
MappingException


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.