org.springframework.data.repository.cdi

## Class CdiRepositoryBean<T>

- java.lang.Object
- - org.springframework.data.repository.cdi.CdiRepositoryBean<T>

All Implemented Interfaces:
  javax.enterprise.context.spi.Contextual<T>, javax.enterprise.inject.spi.Bean<T>, javax.enterprise.inject.spi.PassivationCapable

    public abstract class CdiRepositoryBean<T>
    extends Object
    implements javax.enterprise.inject.spi.Bean<T>, javax.enterprise.inject.spi.PassivationCapable

Base class for `Bean` wrappers.

Author:
  Dirk Mahler, Oliver Gierke, Mark Paluchs, Peter Rietzler, Jens Schauder, Christoph Strobl, Ariel Carrera

### Constructor Summary

Constructors
Constructor and Description
`CdiRepositoryBean(Set<Annotation> qualifiers, Class<T> repositoryType, javax.enterprise.inject.spi.BeanManager beanManager)` Creates a new `CdiRepositoryBean`.
`CdiRepositoryBean(Set<Annotation> qualifiers, Class<T> repositoryType, javax.enterprise.inject.spi.BeanManager beanManager, CdiRepositoryContext context)` Creates a new `CdiRepositoryBean`.
`CdiRepositoryBean(Set<Annotation> qualifiers, Class<T> repositoryType, javax.enterprise.inject.spi.BeanManager beanManager, Optional<CustomRepositoryImplementationDetector> detector)` Creates a new `CdiRepositoryBean`.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`protected void` `applyConfiguration(RepositoryFactorySupport repositoryFactory)` Applies the configuration from `CdiRepositoryConfiguration` to `RepositoryFactorySupport` by looking up the actual configuration.
`protected static void` `applyConfiguration(RepositoryFactorySupport repositoryFactory, CdiRepositoryConfiguration configuration)` Applies the configuration from `CdiRepositoryConfiguration` to `RepositoryFactorySupport` by looking up the actual configuration.
`T` `create(javax.enterprise.context.spi.CreationalContext<T> creationalContext)`
`protected T` `create(javax.enterprise.context.spi.CreationalContext<T> creationalContext, Class<T> repositoryType)` Creates the actual component instance.
`protected T` `create(javax.enterprise.context.spi.CreationalContext<T> creationalContext, Class<T> repositoryType, Optional<Object> customImplementation)` Deprecated. since 2.1, override `create(CreationalContext, Class)` in which you create a repository factory and call `#create(RepositoryFactorySupport, Class, RepositoryFragments)`.
`protected static <T> T` `create(RepositoryFactorySupport repositoryFactory, Class<T> repositoryType, RepositoryComposition.RepositoryFragments repositoryFragments)` Creates the actual repository instance.
`protected T` `create(Supplier<? extends RepositoryFactorySupport> factorySupplier, Class<T> repositoryType)` Creates the actual component instance given a `repository factory supplier` and the repository `type`.
`void` `destroy(T instance, javax.enterprise.context.spi.CreationalContext<T> creationalContext)`
`Class<?>` `getBeanClass()`
`protected <S> S` `getDependencyInstance(javax.enterprise.inject.spi.Bean<S> bean)` Returns an instance of an the given `Bean`.
`protected <S> S` `getDependencyInstance(javax.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.
`String` `getId()`
`Set<javax.enterprise.inject.spi.InjectionPoint>` `getInjectionPoints()`
`String` `getName()`
`Set<Annotation>` `getQualifiers()`
`protected RepositoryComposition.RepositoryFragments` `getRepositoryFragments(Class<T> repositoryType)` Lookup repository fragments for a `repository interface`.
`Class<? extends Annotation>` `getScope()`
`Set<Class<? extends Annotation>>` `getStereotypes()`
`Set<Type>` `getTypes()`
`void` `initialize()` Forces the initialization of bean target.
`boolean` `isAlternative()`
`boolean` `isNullable()`
`protected CdiRepositoryConfiguration` `lookupConfiguration(javax.enterprise.inject.spi.BeanManager beanManager, Set<Annotation> qualifiers)` Looks up an instance of a `CdiRepositoryConfiguration`.
`String` `toString()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Constructor Detail

#### CdiRepositoryBean

    public CdiRepositoryBean(Set<Annotation> qualifiers,
                             Class<T> repositoryType,
                             javax.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,
                             javax.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,
                             javax.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 Detail

#### getTypes

    public Set<Type> getTypes()

Specified by:
  `getTypes` in interface `javax.enterprise.inject.spi.Bean<T>`

#### getDependencyInstance

    protected <S> S getDependencyInstance(javax.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:
  `Bean.getTypes()`

#### getDependencyInstance

    protected <S> S getDependencyInstance(javax.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:
  `Bean.getTypes()`

#### initialize

    public final void initialize()

Forces the initialization of bean target.

#### create

    public final T create(javax.enterprise.context.spi.CreationalContext<T> creationalContext)

Specified by:
  `create` in interface `javax.enterprise.context.spi.Contextual<T>`

#### destroy

    public void destroy(T instance,
                        javax.enterprise.context.spi.CreationalContext<T> creationalContext)

Specified by:
  `destroy` in interface `javax.enterprise.context.spi.Contextual<T>`

#### getQualifiers

    public Set<Annotation> getQualifiers()

Specified by:
  `getQualifiers` in interface `javax.enterprise.inject.spi.Bean<T>`

#### getName

    public String getName()

Specified by:
  `getName` in interface `javax.enterprise.inject.spi.Bean<T>`

#### getStereotypes

    public Set<Class<? extends Annotation>> getStereotypes()

Specified by:
  `getStereotypes` in interface `javax.enterprise.inject.spi.Bean<T>`

#### getBeanClass

    public Class<?> getBeanClass()

Specified by:
  `getBeanClass` in interface `javax.enterprise.inject.spi.Bean<T>`

#### isAlternative

    public boolean isAlternative()

Specified by:
  `isAlternative` in interface `javax.enterprise.inject.spi.Bean<T>`

#### isNullable

    public boolean isNullable()

Specified by:
  `isNullable` in interface `javax.enterprise.inject.spi.Bean<T>`

#### getInjectionPoints

    public Set<javax.enterprise.inject.spi.InjectionPoint> getInjectionPoints()

Specified by:
  `getInjectionPoints` in interface `javax.enterprise.inject.spi.Bean<T>`

#### getScope

    public Class<? extends Annotation> getScope()

Specified by:
  `getScope` in interface `javax.enterprise.inject.spi.Bean<T>`

#### getId

    public String getId()

Specified by:
  `getId` in interface `javax.enterprise.inject.spi.PassivationCapable`

#### create

    protected T create(javax.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

#### create

    @Deprecated
    protected T create(javax.enterprise.context.spi.CreationalContext<T> creationalContext,
                                   Class<T> repositoryType,
                                   Optional<Object> customImplementation)

Deprecated. since 2.1, override `create(CreationalContext, Class)` in which you create a repository factory and call `#create(RepositoryFactorySupport, Class, RepositoryFragments)`.
Creates the actual component instance.

Parameters:
  `creationalContext` - will never be null.
  `repositoryType` - will never be null.
  `customImplementation` - can be null.
Returns:

#### lookupConfiguration

    protected CdiRepositoryConfiguration lookupConfiguration(javax.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`