Package org.eclipse.persistence.jpa.rs
Class PersistenceFactoryBase
java.lang.Object
org.eclipse.persistence.jpa.rs.PersistenceFactoryBase
- All Implemented Interfaces:
PersistenceContextFactory
Manages the PersistenceContexts that are used by a JPA-RS deployment. Provides a single point to bootstrap
and look up PersistenceContexts.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddReplacePersistenceContext(PersistenceContext persistenceContext) bootstrapPersistenceContext(String name, EntityManagerFactory emf, URI baseURI, String version, boolean replace) Bootstrap a PersistenceContext based on an pre-existing EntityManagerFactory.voidclose()Stop the factory.voidClose the PersistenceContext of a given name and clean it out of our list of PersistenceContexts.voidclosePersistenceContext(String name, String version) Close the PersistenceContext and clean it out of our list of PersistenceContexts.createProperties(DynamicClassLoader dcl, Map<String, ?> originalProperties) Provide an initial set of properties for bootstrapping PersistenceContexts.get(String persistenceUnitName, URI defaultURI, String version, Map<String, Object> initializationProperties) Gets existing persistence context or create new based on given parameters if it doesn't exist.getDynamicPersistenceContext(String name, String version) Gets cached persistence context by its name and JPARS version.Returns names of all currently cached persistence contexts.
-
Field Details
-
dynamicPersistenceContexts
-
-
Constructor Details
-
PersistenceFactoryBase
public PersistenceFactoryBase()
-
-
Method Details
-
bootstrapPersistenceContext
public PersistenceContext bootstrapPersistenceContext(String name, EntityManagerFactory emf, URI baseURI, 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. SeeServiceVersionfor 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:
closein interfacePersistenceContextFactory
-
closePersistenceContext
Close the PersistenceContext of a given name and clean it out of our list of PersistenceContexts.- Specified by:
closePersistenceContextin interfacePersistenceContextFactory- Parameters:
name- name of the persistence context to close.
-
closePersistenceContext
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 Map<String,Object> createProperties(DynamicClassLoader dcl, Map<String, ?> originalProperties) Provide an initial set of properties for bootstrapping PersistenceContexts. -
get
public PersistenceContext get(String persistenceUnitName, URI defaultURI, String version, Map<String, Object> initializationProperties) Gets existing persistence context or create new based on given parameters if it doesn't exist.- Specified by:
getin interfacePersistenceContextFactory
-
getPersistenceContextNames
Returns names of all currently cached persistence contexts.- Specified by:
getPersistenceContextNamesin interfacePersistenceContextFactory
-
getDynamicPersistenceContext
Gets cached persistence context by its name and JPARS version.- Parameters:
name- persistent unit name.version- JPARS version. SeeServiceVersionfor more details.- Returns:
- persistence context or null if doesn't exist.
-
addReplacePersistenceContext
-