Class EntityManagerFactoryProxy


  • public class EntityManagerFactoryProxy
    extends java.lang.Object
    Create a proxy for EntityManagerFactory and register all created proxies. Provide static method to reload a proxied factory.

    This class must run in App classloader.

    Author:
    Jiri Bubnik
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static EntityManagerFactoryProxy getWrapper​(java.lang.String persistenceUnitName)
      Create new wrapper for persistenceUnitName and hold it's instance for future use.
      javax.persistence.EntityManagerFactory proxy​(java.lang.Object builder, javax.persistence.EntityManagerFactory factory, java.lang.String persistenceUnitName, javax.persistence.spi.PersistenceUnitInfo info, java.util.Map properties)
      Create a proxy for EntityManagerFactory.
      static void refreshProxiedFactories()
      Refresh all known wrapped factories.
      void refreshProxiedFactory()
      Refresh a single persistence unit - replace the wrapped EntityManagerFactory with fresh instance.
      void refreshProxiedFactoryVersion43OrGreater()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EntityManagerFactoryProxy

        public EntityManagerFactoryProxy()
    • Method Detail

      • getWrapper

        public static EntityManagerFactoryProxy getWrapper​(java.lang.String persistenceUnitName)
        Create new wrapper for persistenceUnitName and hold it's instance for future use.
        Parameters:
        persistenceUnitName - key to the wrapper
        Returns:
        existing wrapper or new instance (never null)
      • refreshProxiedFactories

        public static void refreshProxiedFactories()
        Refresh all known wrapped factories.
      • refreshProxiedFactoryVersion43OrGreater

        public void refreshProxiedFactoryVersion43OrGreater()
      • refreshProxiedFactory

        public void refreshProxiedFactory()
                                   throws java.lang.NoSuchMethodException,
                                          java.lang.reflect.InvocationTargetException,
                                          java.lang.IllegalAccessException,
                                          java.lang.NoSuchFieldException
        Refresh a single persistence unit - replace the wrapped EntityManagerFactory with fresh instance.
        Throws:
        java.lang.NoSuchMethodException
        java.lang.reflect.InvocationTargetException
        java.lang.IllegalAccessException
        java.lang.NoSuchFieldException
      • proxy

        public javax.persistence.EntityManagerFactory proxy​(java.lang.Object builder,
                                                            javax.persistence.EntityManagerFactory factory,
                                                            java.lang.String persistenceUnitName,
                                                            javax.persistence.spi.PersistenceUnitInfo info,
                                                            java.util.Map properties)
        Create a proxy for EntityManagerFactory.
        Parameters:
        factory - initial factory to delegate method calls to.
        info - definition to cache for factory reload
        properties - properties to cache for factory reload
        Returns:
        the proxy