org.datanucleus.jpa
Class EntityManagerFactoryImpl

java.lang.Object
  extended by org.datanucleus.jpa.EntityManagerFactoryImpl
All Implemented Interfaces:
javax.persistence.EntityManagerFactory

public class EntityManagerFactoryImpl
extends java.lang.Object
implements javax.persistence.EntityManagerFactory

EntityManagerFactory implementation. Caches the "persistence-unit" MetaData information when encountered (in J2SE mode).

Version:
$Revision: 1.1 $

Field Summary
protected static org.datanucleus.util.Localiser LOCALISER
          Localiser for messages.
 
Constructor Summary
EntityManagerFactoryImpl()
          Constructor.
EntityManagerFactoryImpl(javax.persistence.spi.PersistenceUnitInfo unitInfo, java.util.Map overridingProps)
          Constructor when working in a J2EE environment.
EntityManagerFactoryImpl(java.lang.String unitName, java.util.Map overridingProps)
          Constructor when working in a J2SE environment.
 
Method Summary
 void close()
          Method to close the factory.
 javax.persistence.EntityManager createEntityManager()
          Method to create an entity manager.
 javax.persistence.EntityManager createEntityManager(java.util.Map overridingProps)
          Method to create an entity manager with the specified properties.
 Cache getCache()
          Accessor for the second level cache.
 java.util.Map getProperties()
          Get the properties and associated values that are in effect for the entity manager factory.
 java.util.Set<java.lang.String> getSupportedProperties()
          Get the names of the properties that are supported for use with the entity manager factory.
protected  javax.jdo.PersistenceManagerFactory initialisePMF(org.datanucleus.metadata.PersistenceUnitMetaData unitMetaData, java.util.Map overridingProps)
          Method to initialise a PersistenceManagerFactory that will control the persistence.
 boolean isContainerManaged()
          Accessor for whether the EMF is managed by a container.
 boolean isOpen()
          Accessor for whether the factory is open
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCALISER

protected static final org.datanucleus.util.Localiser LOCALISER
Localiser for messages.

Constructor Detail

EntityManagerFactoryImpl

public EntityManagerFactoryImpl()
Constructor.


EntityManagerFactoryImpl

public EntityManagerFactoryImpl(javax.persistence.spi.PersistenceUnitInfo unitInfo,
                                java.util.Map overridingProps)
Constructor when working in a J2EE environment.

Parameters:
unitInfo - The "persistent-unit" info
overridingProps - factory properties overriding those in the "persistence-unit"

EntityManagerFactoryImpl

public EntityManagerFactoryImpl(java.lang.String unitName,
                                java.util.Map overridingProps)
Constructor when working in a J2SE environment.

Parameters:
unitName - Name of the "persistent-unit" to use
overridingProps - factory properties overriding those in the "persistence-unit"
Method Detail

isContainerManaged

public boolean isContainerManaged()
Accessor for whether the EMF is managed by a container.

Returns:
Whether managed by a container

close

public void close()
Method to close the factory.

Specified by:
close in interface javax.persistence.EntityManagerFactory

isOpen

public boolean isOpen()
Accessor for whether the factory is open

Specified by:
isOpen in interface javax.persistence.EntityManagerFactory
Returns:
Whether it is open

createEntityManager

public javax.persistence.EntityManager createEntityManager()
Method to create an entity manager.

Specified by:
createEntityManager in interface javax.persistence.EntityManagerFactory
Returns:
The Entity Manager

createEntityManager

public javax.persistence.EntityManager createEntityManager(java.util.Map overridingProps)
Method to create an entity manager with the specified properties. This creates a new underlying PersistenceManagerFactory since each PMF is locked when created to stop config changes.

Specified by:
createEntityManager in interface javax.persistence.EntityManagerFactory
Parameters:
overridingProps - Properties to use for this manager
Returns:
The Entity Manager

initialisePMF

protected javax.jdo.PersistenceManagerFactory initialisePMF(org.datanucleus.metadata.PersistenceUnitMetaData unitMetaData,
                                                            java.util.Map overridingProps)
Method to initialise a PersistenceManagerFactory that will control the persistence. If the unitMetaData is null will simply create a default PMF without initialising any MetaData etc. If there is a unitMetaData then all metadata for that unit will be loaded/initialised.

Parameters:
unitMetaData - The "persistence-unit" metadata (if any)
overridingProps - Properties to override all others
Returns:
The PersistenceManagerFactory

getProperties

public java.util.Map getProperties()
Get the properties and associated values that are in effect for the entity manager factory. Changing the contents of the map does not change the configuration in effect.

Returns:
properties

getSupportedProperties

public java.util.Set<java.lang.String> getSupportedProperties()
Get the names of the properties that are supported for use with the entity manager factory. These correspond to properties that may be passed to the methods of the EntityManagerFactory interface that take a properties argument. These include all standard properties as well as vendor-specific properties supported by the provider. These properties may or may not currently be in effect.

Returns:
properties and hints

getCache

public Cache getCache()
Accessor for the second level cache.

Returns:
Level 2 cache


Copyright © 2009. All Rights Reserved.