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 Details

    • CdiRepositoryBean

      public CdiRepositoryBean(Set<Annotation> qualifiers, Class<T> repositoryType, jakarta.enterprise.inject.spi.BeanManager beanManager)
      Creates a new CdiRepositoryBean.
      Parameters:
      qualifiers - must not be null.
      repositoryType - has to be an interface must not be null.
      beanManager - the CDI BeanManager, must not be null.
    • CdiRepositoryBean

      public CdiRepositoryBean(Set<Annotation> qualifiers, Class<T> repositoryType, jakarta.enterprise.inject.spi.BeanManager beanManager, Optional<CustomRepositoryImplementationDetector> detector)
      Creates a new CdiRepositoryBean.
      Parameters:
      qualifiers - must not be null.
      repositoryType - has to be an interface must not be null.
      beanManager - the CDI BeanManager, must not be null.
      detector - detector for the custom repository implementations CustomRepositoryImplementationDetector.
    • CdiRepositoryBean

      public CdiRepositoryBean(Set<Annotation> qualifiers, Class<T> repositoryType, jakarta.enterprise.inject.spi.BeanManager beanManager, CdiRepositoryContext context)
      Creates a new CdiRepositoryBean.
      Parameters:
      qualifiers - must not be null.
      repositoryType - has to be an interface must not be null.
      beanManager - the CDI BeanManager, must not be null.
      context - CDI context encapsulating class loader, metadata scanning and fragment detection.
      Since:
      2.1
  • Method Details

    • getTypes

      public Set<Type> getTypes()
      Specified by:
      getTypes in interface jakarta.enterprise.inject.spi.BeanAttributes<T>
    • getDependencyInstance

      protected <S> S getDependencyInstance(jakarta.enterprise.inject.spi.Bean<S> bean)
      Returns an instance of an the given Bean.
      Parameters:
      bean - the Bean about to create an instance for.
      Returns:
      the actual component instance.
      See Also:
      • BeanAttributes.getTypes()
    • getDependencyInstance

      protected <S> S getDependencyInstance(jakarta.enterprise.inject.spi.Bean<S> bean, Class<?> type)
      Returns an instance of an the given Bean and allows to be specific about the type that is about to be created.
      Parameters:
      bean - the Bean about to create an instance for.
      type - the expected type of the component instance created for that Bean. We need to hand this parameter explicitly as the Bean might carry multiple types but the primary one might not be the first, i.e. the one returned by Bean.getBeanClass().
      Returns:
      the actual component instance.
      See Also:
      • BeanAttributes.getTypes()
    • initialize

      public final void initialize()
      Forces the initialization of bean target.
    • create

      public final T create(jakarta.enterprise.context.spi.CreationalContext<T> creationalContext)
      Specified by:
      create in interface jakarta.enterprise.context.spi.Contextual<T>
    • destroy

      public void destroy(T instance, jakarta.enterprise.context.spi.CreationalContext<T> creationalContext)
      Specified by:
      destroy in interface jakarta.enterprise.context.spi.Contextual<T>
    • getQualifiers

      public Set<Annotation> getQualifiers()
      Specified by:
      getQualifiers in interface jakarta.enterprise.inject.spi.BeanAttributes<T>
    • getName

      public String getName()
      Specified by:
      getName in interface jakarta.enterprise.inject.spi.BeanAttributes<T>
    • getStereotypes

      public Set<Class<? extends Annotation>> getStereotypes()
      Specified by:
      getStereotypes in interface jakarta.enterprise.inject.spi.BeanAttributes<T>
    • getBeanClass

      public Class<?> getBeanClass()
      Specified by:
      getBeanClass in interface jakarta.enterprise.inject.spi.Bean<T>
    • isAlternative

      public boolean isAlternative()
      Specified by:
      isAlternative in interface jakarta.enterprise.inject.spi.BeanAttributes<T>
    • isNullable

      public boolean isNullable()
    • getInjectionPoints

      public Set<jakarta.enterprise.inject.spi.InjectionPoint> getInjectionPoints()
      Specified by:
      getInjectionPoints in interface jakarta.enterprise.inject.spi.Bean<T>
    • getScope

      public Class<? extends Annotation> getScope()
      Specified by:
      getScope in interface jakarta.enterprise.inject.spi.BeanAttributes<T>
    • getId

      public String getId()
      Specified by:
      getId in interface jakarta.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 a repository factory supplier and the repository type. This method is an utility for to create a repository. This method will obtain a repository factory and configure it with CdiRepositoryConfiguration.
      Parameters:
      factorySupplier - must not be null.
      repositoryType - must not be null.
      Returns:
      Since:
      2.1
    • getRepositoryFragments

      protected RepositoryComposition.RepositoryFragments getRepositoryFragments(Class<T> repositoryType)
      Lookup repository fragments for a repository 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 a CdiRepositoryConfiguration. 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

      protected void applyConfiguration(RepositoryFactorySupport repositoryFactory)
      Applies the configuration from CdiRepositoryConfiguration to RepositoryFactorySupport by 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 from CdiRepositoryConfiguration to RepositoryFactorySupport by 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

      public String toString()
      Overrides:
      toString in class Object