Package org.eclipse.persistence.jpa.rs
Class PersistenceFactoryBase
- java.lang.Object
-
- org.eclipse.persistence.jpa.rs.PersistenceFactoryBase
-
- All Implemented Interfaces:
PersistenceContextFactory
public class PersistenceFactoryBase extends java.lang.Object implements PersistenceContextFactory
Manages the PersistenceContexts that are used by a JPA-RS deployment. Provides a single point to bootstrap and look up PersistenceContexts.- Author:
- tware
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.util.Set<PersistenceContext>>
dynamicPersistenceContexts
-
Constructor Summary
Constructors Constructor Description PersistenceFactoryBase()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addReplacePersistenceContext(PersistenceContext persistenceContext)
PersistenceContext
bootstrapPersistenceContext(java.lang.String name, EntityManagerFactory emf, java.net.URI baseURI, java.lang.String version, boolean replace)
Bootstrap a PersistenceContext based on an pre-existing EntityManagerFactory.void
close()
Stop the factory.void
closePersistenceContext(java.lang.String name)
Close the PersistenceContext of a given name and clean it out of our list of PersistenceContexts.void
closePersistenceContext(java.lang.String name, java.lang.String version)
Close the PersistenceContext and clean it out of our list of PersistenceContexts.protected static java.util.Map<java.lang.String,java.lang.Object>
createProperties(DynamicClassLoader dcl, java.util.Map<java.lang.String,?> originalProperties)
Provide an initial set of properties for bootstrapping PersistenceContexts.PersistenceContext
get(java.lang.String persistenceUnitName, java.net.URI defaultURI, java.lang.String version, java.util.Map<java.lang.String,java.lang.Object> initializationProperties)
Gets existing persistence context or create new based on given parameters if it doesn't exist.PersistenceContext
getDynamicPersistenceContext(java.lang.String name, java.lang.String version)
Gets cached persistence context by its name and JPARS version.java.util.Set<java.lang.String>
getPersistenceContextNames()
Returns names of all currently cached persistence contexts.
-
-
-
Field Detail
-
dynamicPersistenceContexts
protected final java.util.Map<java.lang.String,java.util.Set<PersistenceContext>> dynamicPersistenceContexts
-
-
Method Detail
-
bootstrapPersistenceContext
public PersistenceContext bootstrapPersistenceContext(java.lang.String name, EntityManagerFactory emf, java.net.URI baseURI, java.lang.String version, boolean replace)
Bootstrap a PersistenceContext based on an pre-existing EntityManagerFactory.- Parameters:
name
- persistence context nameemf
- entity manager factorybaseURI
- base URIversion
- JPARS version. SeeServiceVersion
for more details.replace
- Indicates that existing persistence context with given name and version must be replaced with the newly created one. If false passed the newly created context is not added to cache at all.- Returns:
- newly created persistence context
-
close
public void close()
Stop the factory. Remove all the PersistenceContexts.- Specified by:
close
in interfacePersistenceContextFactory
-
closePersistenceContext
public void closePersistenceContext(java.lang.String name)
Close the PersistenceContext of a given name and clean it out of our list of PersistenceContexts.- Specified by:
closePersistenceContext
in interfacePersistenceContextFactory
- Parameters:
name
- name of the persistence context to close.
-
closePersistenceContext
public void closePersistenceContext(java.lang.String name, java.lang.String version)
Close the PersistenceContext and clean it out of our list of PersistenceContexts.- Parameters:
name
- name of the persistence context to close.version
- persistence context version
-
createProperties
protected static java.util.Map<java.lang.String,java.lang.Object> createProperties(DynamicClassLoader dcl, java.util.Map<java.lang.String,?> originalProperties)
Provide an initial set of properties for bootstrapping PersistenceContexts.- Parameters:
dcl
-originalProperties
-- Returns:
-
get
public PersistenceContext get(java.lang.String persistenceUnitName, java.net.URI defaultURI, java.lang.String version, java.util.Map<java.lang.String,java.lang.Object> initializationProperties)
Gets existing persistence context or create new based on given parameters if it doesn't exist.- Specified by:
get
in interfacePersistenceContextFactory
-
getPersistenceContextNames
public java.util.Set<java.lang.String> getPersistenceContextNames()
Returns names of all currently cached persistence contexts.- Specified by:
getPersistenceContextNames
in interfacePersistenceContextFactory
-
getDynamicPersistenceContext
public PersistenceContext getDynamicPersistenceContext(java.lang.String name, java.lang.String version)
Gets cached persistence context by its name and JPARS version.- Parameters:
name
- persistent unit name.version
- JPARS version. SeeServiceVersion
for more details.- Returns:
- persistence context or null if doesn't exist.
-
addReplacePersistenceContext
protected void addReplacePersistenceContext(PersistenceContext persistenceContext)
-
-