Class CdiRepositoryBean<T>
java.lang.Object
org.springframework.data.repository.cdi.CdiRepositoryBean<T>
- All Implemented Interfaces:
jakarta.enterprise.context.spi.Contextual<T>,jakarta.enterprise.inject.spi.Bean<T>,jakarta.enterprise.inject.spi.BeanAttributes<T>,jakarta.enterprise.inject.spi.PassivationCapable
public abstract class CdiRepositoryBean<T>
extends Object
implements jakarta.enterprise.inject.spi.Bean<T>, jakarta.enterprise.inject.spi.PassivationCapable
Base class for
Bean wrappers.- Author:
- Dirk Mahler, Oliver Gierke, Mark Paluchs, Peter Rietzler, Jens Schauder, Christoph Strobl, Ariel Carrera, Xeno Amess, Johannes Englmeier
-
Constructor Summary
ConstructorsConstructorDescriptionCdiRepositoryBean(Set<Annotation> qualifiers, Class<T> repositoryType, jakarta.enterprise.inject.spi.BeanManager beanManager) Creates a newCdiRepositoryBean.CdiRepositoryBean(Set<Annotation> qualifiers, Class<T> repositoryType, jakarta.enterprise.inject.spi.BeanManager beanManager, Optional<CustomRepositoryImplementationDetector> detector) Creates a newCdiRepositoryBean.CdiRepositoryBean(Set<Annotation> qualifiers, Class<T> repositoryType, jakarta.enterprise.inject.spi.BeanManager beanManager, CdiRepositoryContext context) Creates a newCdiRepositoryBean. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyConfiguration(RepositoryFactorySupport repositoryFactory) Applies the configuration fromCdiRepositoryConfigurationtoRepositoryFactorySupportby looking up the actual configuration.protected static voidapplyConfiguration(RepositoryFactorySupport repositoryFactory, CdiRepositoryConfiguration configuration) Applies the configuration fromCdiRepositoryConfigurationtoRepositoryFactorySupportby looking up the actual configuration.final Tprotected abstract Tcreate(jakarta.enterprise.context.spi.CreationalContext<T> creationalContext, Class<T> repositoryType) Creates the actual component instance.protected Tcreate(Supplier<? extends RepositoryFactorySupport> factorySupplier, Class<T> repositoryType) Creates the actual component instance given arepository factory supplierand the repositorytype.protected static <T> Tcreate(RepositoryFactorySupport repositoryFactory, Class<T> repositoryType, RepositoryComposition.RepositoryFragments repositoryFragments) Creates the actual repository instance.voidClass<?>protected <S> SgetDependencyInstance(jakarta.enterprise.inject.spi.Bean<S> bean) Returns an instance of an the givenBean.protected <S> SgetDependencyInstance(jakarta.enterprise.inject.spi.Bean<S> bean, Class<?> type) Returns an instance of an the givenBeanand allows to be specific about the type that is about to be created.getId()Set<jakarta.enterprise.inject.spi.InjectionPoint>getName()getRepositoryFragments(Class<T> repositoryType) Lookup repository fragments for arepository interface.Class<? extends Annotation>getScope()Set<Class<? extends Annotation>>getTypes()final voidForces the initialization of bean target.booleanbooleanprotected CdiRepositoryConfigurationlookupConfiguration(jakarta.enterprise.inject.spi.BeanManager beanManager, Set<Annotation> qualifiers) Looks up an instance of aCdiRepositoryConfiguration.toString()
-
Constructor Details
-
CdiRepositoryBean
public CdiRepositoryBean(Set<Annotation> qualifiers, Class<T> repositoryType, jakarta.enterprise.inject.spi.BeanManager beanManager) Creates a newCdiRepositoryBean.- Parameters:
qualifiers- must not be null.repositoryType- has to be an interface must not be null.beanManager- the CDIBeanManager, must not be null.
-
CdiRepositoryBean
public CdiRepositoryBean(Set<Annotation> qualifiers, Class<T> repositoryType, jakarta.enterprise.inject.spi.BeanManager beanManager, Optional<CustomRepositoryImplementationDetector> detector) Creates a newCdiRepositoryBean.- Parameters:
qualifiers- must not be null.repositoryType- has to be an interface must not be null.beanManager- the CDIBeanManager, must not be null.detector- detector for the custom repository implementationsCustomRepositoryImplementationDetector.
-
CdiRepositoryBean
public CdiRepositoryBean(Set<Annotation> qualifiers, Class<T> repositoryType, jakarta.enterprise.inject.spi.BeanManager beanManager, CdiRepositoryContext context) Creates a newCdiRepositoryBean.- Parameters:
qualifiers- must not be null.repositoryType- has to be an interface must not be null.beanManager- the CDIBeanManager, must not be null.context- CDI context encapsulating class loader, metadata scanning and fragment detection.- Since:
- 2.1
-
-
Method Details
-
getTypes
- Specified by:
getTypesin interfacejakarta.enterprise.inject.spi.BeanAttributes<T>
-
getDependencyInstance
protected <S> S getDependencyInstance(jakarta.enterprise.inject.spi.Bean<S> bean) Returns an instance of an the givenBean.- Parameters:
bean- theBeanabout to create an instance for.- Returns:
- the actual component instance.
- See Also:
-
BeanAttributes.getTypes()
-
getDependencyInstance
Returns an instance of an the givenBeanand allows to be specific about the type that is about to be created.- Parameters:
bean- theBeanabout to create an instance for.type- the expected type of the component instance created for thatBean. We need to hand this parameter explicitly as theBeanmight carry multiple types but the primary one might not be the first, i.e. the one returned byBean.getBeanClass().- Returns:
- the actual component instance.
- See Also:
-
BeanAttributes.getTypes()
-
initialize
public final void initialize()Forces the initialization of bean target. -
create
- Specified by:
createin interfacejakarta.enterprise.context.spi.Contextual<T>
-
destroy
public void destroy(T instance, jakarta.enterprise.context.spi.CreationalContext<T> creationalContext) - Specified by:
destroyin interfacejakarta.enterprise.context.spi.Contextual<T>
-
getQualifiers
- Specified by:
getQualifiersin interfacejakarta.enterprise.inject.spi.BeanAttributes<T>
-
getName
- Specified by:
getNamein interfacejakarta.enterprise.inject.spi.BeanAttributes<T>
-
getStereotypes
- Specified by:
getStereotypesin interfacejakarta.enterprise.inject.spi.BeanAttributes<T>
-
getBeanClass
- Specified by:
getBeanClassin interfacejakarta.enterprise.inject.spi.Bean<T>
-
isAlternative
public boolean isAlternative()- Specified by:
isAlternativein interfacejakarta.enterprise.inject.spi.BeanAttributes<T>
-
isNullable
public boolean isNullable() -
getInjectionPoints
- Specified by:
getInjectionPointsin interfacejakarta.enterprise.inject.spi.Bean<T>
-
getScope
- Specified by:
getScopein interfacejakarta.enterprise.inject.spi.BeanAttributes<T>
-
getId
- Specified by:
getIdin interfacejakarta.enterprise.inject.spi.PassivationCapable
-
create
protected abstract T create(jakarta.enterprise.context.spi.CreationalContext<T> creationalContext, Class<T> repositoryType) Creates the actual component instance.- Parameters:
creationalContext- will never be null.repositoryType- will never be null.- Returns:
-
create
protected T create(Supplier<? extends RepositoryFactorySupport> factorySupplier, Class<T> repositoryType) Creates the actual component instance given arepository factory supplierand the repositorytype. This method is an utility for to create a repository. This method will obtain arepository factoryand configure it withCdiRepositoryConfiguration.- Parameters:
factorySupplier- must not be null.repositoryType- must not be null.- Returns:
- Since:
- 2.1
-
getRepositoryFragments
Lookup repository fragments for arepository interface.- Parameters:
repositoryType- must not be null.- Returns:
- the
RepositoryComposition.RepositoryFragments. - Since:
- 2.1
-
lookupConfiguration
protected CdiRepositoryConfiguration lookupConfiguration(jakarta.enterprise.inject.spi.BeanManager beanManager, Set<Annotation> qualifiers) Looks up an instance of aCdiRepositoryConfiguration. In case the instance cannot be found within the CDI scope, a default configuration is used.- Returns:
- an available CdiRepositoryConfiguration instance or a default configuration.
-
applyConfiguration
Applies the configuration fromCdiRepositoryConfigurationtoRepositoryFactorySupportby looking up the actual configuration.- Parameters:
repositoryFactory- will never be null.- Since:
- 2.1
-
applyConfiguration
protected static void applyConfiguration(RepositoryFactorySupport repositoryFactory, CdiRepositoryConfiguration configuration) Applies the configuration fromCdiRepositoryConfigurationtoRepositoryFactorySupportby looking up the actual configuration.- Parameters:
repositoryFactory- will never be null.configuration- will never be null.- Since:
- 2.1
-
create
protected static <T> T create(RepositoryFactorySupport repositoryFactory, Class<T> repositoryType, RepositoryComposition.RepositoryFragments repositoryFragments) Creates the actual repository instance.- Parameters:
repositoryType- will never be null.repositoryFragments- will never be null.- Returns:
-
toString
-