Class UnitOfWorkAwareProxyFactory


  • public class UnitOfWorkAwareProxyFactory
    extends Object
    A factory for creating proxies for components that use Hibernate data access objects outside Jersey resources.

    A created proxy will be aware of the UnitOfWork annotation on the original class methods and will open a Hibernate session with a transaction around them.

    • Constructor Detail

      • UnitOfWorkAwareProxyFactory

        public UnitOfWorkAwareProxyFactory​(String name,
                                           org.hibernate.SessionFactory sessionFactory)
      • UnitOfWorkAwareProxyFactory

        public UnitOfWorkAwareProxyFactory​(com.github.benmanes.caffeine.cache.Caffeine<Object,​Object> proxyCacheBuilder,
                                           String name,
                                           org.hibernate.SessionFactory sessionFactory)
      • UnitOfWorkAwareProxyFactory

        public UnitOfWorkAwareProxyFactory​(HibernateBundle<?>... bundles)
      • UnitOfWorkAwareProxyFactory

        public UnitOfWorkAwareProxyFactory​(com.github.benmanes.caffeine.cache.Caffeine<Object,​Object> proxyCacheBuilder,
                                           HibernateBundle<?>... bundles)
    • Method Detail

      • create

        public <T> T create​(Class<T> clazz)
        Creates a new @UnitOfWork aware proxy of a class with the default constructor.
        Type Parameters:
        T - the type of the class
        Parameters:
        clazz - the specified class definition
        Returns:
        a new proxy
      • create

        public <T> T create​(Class<T> clazz,
                            Class<?> constructorParamType,
                            Object constructorArguments)
        Creates a new @UnitOfWork aware proxy of a class with an one-parameter constructor.
        Type Parameters:
        T - the type of the class
        Parameters:
        clazz - the specified class definition
        constructorParamType - the type of the constructor parameter
        constructorArguments - the argument passed to the constructor
        Returns:
        a new proxy
      • create

        public <T> T create​(Class<T> clazz,
                            Class<?>[] constructorParamTypes,
                            Object[] constructorArguments)
        Creates a new @UnitOfWork aware proxy of a class with a complex constructor.
        Type Parameters:
        T - the type of the class
        Parameters:
        clazz - the specified class definition
        constructorParamTypes - the types of the constructor parameters
        constructorArguments - the arguments passed to the constructor
        Returns:
        a new proxy
      • createProxyClass

        protected <T> Class<? extends T> createProxyClass​(Class<T> classToProxy)
      • newAspect

        public UnitOfWorkAspect newAspect​(Map<String,​org.hibernate.SessionFactory> sessionFactories)
        Parameters:
        sessionFactories -
        Returns:
        a new aspect