Package io.dropwizard.hibernate
Class UnitOfWorkAwareProxyFactory
- java.lang.Object
-
- io.dropwizard.hibernate.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
UnitOfWorkAwareProxyFactory.MethodInterceptor
-
Constructor Summary
Constructors Constructor Description UnitOfWorkAwareProxyFactory(com.github.benmanes.caffeine.cache.Caffeine<Object,Object> proxyCacheBuilder, HibernateBundle<?>... bundles)
UnitOfWorkAwareProxyFactory(com.github.benmanes.caffeine.cache.Caffeine<Object,Object> proxyCacheBuilder, String name, org.hibernate.SessionFactory sessionFactory)
UnitOfWorkAwareProxyFactory(HibernateBundle<?>... bundles)
UnitOfWorkAwareProxyFactory(String name, org.hibernate.SessionFactory sessionFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
create(Class<T> clazz)
Creates a new @UnitOfWork aware proxy of a class with the default constructor.<T> T
create(Class<T> clazz, Class<?>[] constructorParamTypes, Object[] constructorArguments)
Creates a new @UnitOfWork aware proxy of a class with a complex constructor.<T> T
create(Class<T> clazz, Class<?> constructorParamType, Object constructorArguments)
Creates a new @UnitOfWork aware proxy of a class with an one-parameter constructor.protected <T> Class<? extends T>
createProxyClass(Class<T> classToProxy)
UnitOfWorkAspect
newAspect()
UnitOfWorkAspect
newAspect(Map<String,org.hibernate.SessionFactory> sessionFactories)
-
-
-
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 definitionconstructorParamType
- the type of the constructor parameterconstructorArguments
- 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 definitionconstructorParamTypes
- the types of the constructor parametersconstructorArguments
- the arguments passed to the constructor- Returns:
- a new proxy
-
newAspect
public UnitOfWorkAspect newAspect()
- Returns:
- a new aspect
-
newAspect
public UnitOfWorkAspect newAspect(Map<String,org.hibernate.SessionFactory> sessionFactories)
- Parameters:
sessionFactories
-- Returns:
- a new aspect
-
-