Class PersistenceFactoryBase

  • All Implemented Interfaces:
    PersistenceContextFactory

    public class PersistenceFactoryBase
    extends 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
    • Constructor Detail

      • PersistenceFactoryBase

        public PersistenceFactoryBase()
    • Method Detail

      • bootstrapPersistenceContext

        public PersistenceContext bootstrapPersistenceContext​(String name,
                                                              jakarta.persistence.EntityManagerFactory emf,
                                                              URI baseURI,
                                                              String version,
                                                              boolean replace)
        Bootstrap a PersistenceContext based on an pre-existing EntityManagerFactory.
        Parameters:
        name - persistence context name
        emf - entity manager factory
        baseURI - base URI
        version - JPARS version. See ServiceVersion 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
      • closePersistenceContext

        public void closePersistenceContext​(String name)
        Close the PersistenceContext of a given name and clean it out of our list of PersistenceContexts.
        Specified by:
        closePersistenceContext in interface PersistenceContextFactory
        Parameters:
        name - name of the persistence context to close.
      • closePersistenceContext

        public void closePersistenceContext​(String name,
                                            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 Map<String,​Object> createProperties​(DynamicClassLoader dcl,
                                                                   Map<String,​?> originalProperties)
        Provide an initial set of properties for bootstrapping PersistenceContexts.
        Parameters:
        dcl -
        originalProperties -
        Returns:
      • getDynamicPersistenceContext

        public PersistenceContext getDynamicPersistenceContext​(String name,
                                                               String version)
        Gets cached persistence context by its name and JPARS version.
        Parameters:
        name - persistent unit name.
        version - JPARS version. See ServiceVersion for more details.
        Returns:
        persistence context or null if doesn't exist.
      • addReplacePersistenceContext

        protected void addReplacePersistenceContext​(PersistenceContext persistenceContext)