Top Description Methods
javax.enterprise.inject.spi.configurator

public Interface BeanConfigurator<T>

Type Parameters
<T>
the class of the bean instance
Imports
java.lang.annotation.Annotation, java.lang.reflect.Type, java.util.Set, java.util.function.BiConsumer, .Function, javax.enterprise.context.spi.Contextual, .CreationalContext, javax.enterprise.inject.Instance, javax.enterprise.inject.spi.AfterBeanDiscovery, .AnnotatedType, .Bean, .BeanAttributes, .InjectionPoint, .PassivationCapable, javax.enterprise.util.TypeLiteral

This API is an helper to configure a new Bean instance. CDI container must provides an implementation of this interface. This builder is not thread safe and shall not be used concurrently.
Authors
Martin Kouba, Antoine Sabot-Durand
Since
2.0
See Also
AfterBeanDiscovery#addBean()

Method Summary

Modifier and TypeMethod and Description
public BeanConfigurator<T>

Returns:

self
addInjectionPoint
(InjectionPoint
the injectionPoint to add
injectionPoint
)

Add an InjectionPoint to the configured bean

public BeanConfigurator<T>

Returns:

self
addInjectionPoints
(InjectionPoint...
the injectionPoints to add
injectionPoints
)

Add InjectionPoints to the configured bean

public BeanConfigurator<T>

Returns:

self
addInjectionPoints
(Set<InjectionPoint>
the injectionPoints to add
injectionPoints
)

Add InjectionPoints to the configured bean

public BeanConfigurator<T>

Returns:

self
addQualifier
(Annotation
qualifier to add
qualifier
)

Add a qualifier to the configured bean

public BeanConfigurator<T>

Returns:

self
addQualifiers
(Annotation...
qualifiers to add
qualifiers
)

Add qualifiers to the bean.

public BeanConfigurator<T>

Returns:

self
addQualifiers
(Set<Annotation>
qualifiers to add
qualifiers
)

Add qualifiers to the bean.

public BeanConfigurator<T>

Returns:

self
addStereotype
(Class<? extends Annotation>
stereotype to add
stereotype
)

Add a stereotype to the configured bean

public BeanConfigurator<T>

Returns:

self
addStereotypes
(Set<Class<? extends Annotation>>
stereotypes to add
stereotypes
)

Add stereotypes to the configured bean

public BeanConfigurator<T>

Returns:

self
addTransitiveTypeClosure
(Type
to build the closure from
type
)

Adds an unrestricted set of bean types for the given type as if it represented a bean class of a managed bean.

public BeanConfigurator<T>

Returns:

self
addType
(Type
the type to add
type
)

Add a type to the bean types

public BeanConfigurator<T>

Returns:

self
addType
(TypeLiteral<?>
the type to add
typeLiteral
)

Add a type to the bean types

public BeanConfigurator<T>

Returns:

self
addTypes
(Type...
types to add
types
)

Add types to the bean types

public BeanConfigurator<T>

Returns:

self
addTypes
(Set<Type>
types to add
types
)

Add types to the bean types

public BeanConfigurator<T>

Returns:

self
alternative
(boolean
value for alternative property
value
)

Change the alternative status of the configured bean.

public BeanConfigurator<T>

Returns:

self
beanClass
(Class<?>
class of the configured bean
beanClass
)

Set the class of the configured Bean.

public <U extends T> BeanConfigurator<U>

Returns:

self
createWith
(Function<CreationalContext<U>, U>
the callback to create the instance
callback
)

Set a callback to create a bean instance.

public BeanConfigurator<T>

Returns:

self
destroyWith
(BiConsumer<T, CreationalContext<T>>
the callback to destroy the instance
callback
)

Set a callback to destroy a bean instance.

public BeanConfigurator<T>

Returns:

self
disposeWith
(BiConsumer<T, Instance<Object>>
the callback to dispose the instance
callback
)

Set a callback to destroy a bean instance.

public BeanConfigurator<T>

Returns:

self
id
(String
for
id
)

Make the configured bean implements PassivationCapable and its Id for passivation.

public BeanConfigurator<T>

Returns:

self
injectionPoints
(InjectionPoint...
the injectionPoints for the configured bean
injectionPoints
)

Replace InjectionPoints for the configured bean

public BeanConfigurator<T>

Returns:

self
injectionPoints
(Set<InjectionPoint>
the injectionPoints for the configured bean
injectionPoints
)

Replace InjectionPoints for the configured bean

public BeanConfigurator<T>

Returns:

self
name
(String
name for the configured bean
name
)

Set the name of the configured bean

public <U extends T> BeanConfigurator<U>

Returns:

self
produceWith
(Function<Instance<Object>, U>
the callback to create the instance
callback
)

Set a callback to create a bean instance.

public BeanConfigurator<T>

Returns:

self
qualifiers
(Annotation...
qualifiers for the build bean
qualifiers
)

Replace all qualifiers.

public BeanConfigurator<T>

Returns:

self
qualifiers
(Set<Annotation>
for the configured bean
qualifiers
)

Replace all qualifiers.

public <U extends T> BeanConfigurator<U>

Returns:

self
read
(AnnotatedType<U>
class to read information from
type
)

Read the information from the given annotated type.

public BeanConfigurator<T>

Returns:

self
read
(BeanAttributes<?>
beanAttributes to read information from
beanAttributes
)

Read the information from the given bean attributes.

public BeanConfigurator<T>

Returns:

self
scope
(Class<? extends Annotation>
new scope for the configured bean
scope
)

Replace Bean scope

public BeanConfigurator<T>

Returns:

self
stereotypes
(Set<Class<? extends Annotation>>
for the configured bean
stereotypes
)

Replace stereotypes on the configured bean

public BeanConfigurator<T>

Returns:

self
types
(Type...
the types of the configured bean
types
)

Replace bean types

public BeanConfigurator<T>

Returns:

self
types
(Set<Type>
the types of the configured bean
types
)

Replace bean types

Method Detail

addInjectionPointback to summary
public BeanConfigurator<T> addInjectionPoint(InjectionPoint injectionPoint)

Add an InjectionPoint to the configured bean

Parameters
injectionPoint:InjectionPoint

the injectionPoint to add

Returns:BeanConfigurator<T>

self

addInjectionPointsback to summary
public BeanConfigurator<T> addInjectionPoints(InjectionPoint... injectionPoints)

Add InjectionPoints to the configured bean

Parameters
injectionPoints:InjectionPoint[]

the injectionPoints to add

Returns:BeanConfigurator<T>

self

addInjectionPointsback to summary
public BeanConfigurator<T> addInjectionPoints(Set<InjectionPoint> injectionPoints)

Add InjectionPoints to the configured bean

Parameters
injectionPoints:Set<InjectionPoint>

the injectionPoints to add

Returns:BeanConfigurator<T>

self

addQualifierback to summary
public BeanConfigurator<T> addQualifier(Annotation qualifier)

Add a qualifier to the configured bean

Parameters
qualifier:Annotation

qualifier to add

Returns:BeanConfigurator<T>

self

addQualifiersback to summary
public BeanConfigurator<T> addQualifiers(Annotation... qualifiers)

Add qualifiers to the bean.

Parameters
qualifiers:Annotation[]

qualifiers to add

Returns:BeanConfigurator<T>

self

addQualifiersback to summary
public BeanConfigurator<T> addQualifiers(Set<Annotation> qualifiers)

Add qualifiers to the bean.

Parameters
qualifiers:Set<Annotation>

qualifiers to add

Returns:BeanConfigurator<T>

self

addStereotypeback to summary
public BeanConfigurator<T> addStereotype(Class<? extends Annotation> stereotype)

Add a stereotype to the configured bean

Parameters
stereotype:Class<? extends Annotation>

stereotype to add

Returns:BeanConfigurator<T>

self

addStereotypesback to summary
public BeanConfigurator<T> addStereotypes(Set<Class<? extends Annotation>> stereotypes)

Add stereotypes to the configured bean

Parameters
stereotypes:Set<Class<? extends Annotation>>

stereotypes to add

Returns:BeanConfigurator<T>

self

addTransitiveTypeClosureback to summary
public BeanConfigurator<T> addTransitiveTypeClosure(Type type)

Adds an unrestricted set of bean types for the given type as if it represented a bean class of a managed bean. Illegal bean types are omitted.

Parameters
type:Type

to build the closure from

Returns:BeanConfigurator<T>

self

addTypeback to summary
public BeanConfigurator<T> addType(Type type)

Add a type to the bean types

Parameters
type:Type

the type to add

Returns:BeanConfigurator<T>

self

addTypeback to summary
public BeanConfigurator<T> addType(TypeLiteral<?> typeLiteral)

Add a type to the bean types

Parameters
typeLiteral:TypeLiteral<?>

the type to add

Returns:BeanConfigurator<T>

self

addTypesback to summary
public BeanConfigurator<T> addTypes(Type... types)

Add types to the bean types

Parameters
types:Type[]

types to add

Returns:BeanConfigurator<T>

self

addTypesback to summary
public BeanConfigurator<T> addTypes(Set<Type> types)

Add types to the bean types

Parameters
types:Set<Type>

types to add

Returns:BeanConfigurator<T>

self

alternativeback to summary
public BeanConfigurator<T> alternative(boolean value)

Change the alternative status of the configured bean. By default the configured bean is not an alternative.

Parameters
value:boolean

value for alternative property

Returns:BeanConfigurator<T>

self

beanClassback to summary
public BeanConfigurator<T> beanClass(Class<?> beanClass)

Set the class of the configured Bean. If not set, the extension class is used.

Parameters
beanClass:Class<?>

class of the configured bean

Returns:BeanConfigurator<T>

self

createWithback to summary
public <U extends T> BeanConfigurator<U> createWith(Function<CreationalContext<U>, U> callback)

Set a callback to create a bean instance.

Parameters
callback:Function<CreationalContext<U>, U>

the callback to create the instance

Returns:BeanConfigurator<U>

self

See Also
Contextual#create(CreationalContext)
destroyWithback to summary
public BeanConfigurator<T> destroyWith(BiConsumer<T, CreationalContext<T>> callback)

Set a callback to destroy a bean instance.

If no destroy callback is specified, a NOOP callback is automatically set.

Parameters
callback:BiConsumer<T, CreationalContext<T>>

the callback to destroy the instance

Returns:BeanConfigurator<T>

self

disposeWithback to summary
public BeanConfigurator<T> disposeWith(BiConsumer<T, Instance<Object>> callback)

Set a callback to destroy a bean instance.

If no dispose callback is specified, a NOOP callback is automatically set.

The Instance argument might be used to simulate disposer method parameter injection. All dependent scoped bean instances obtained from Instance during the callback execution are destroyed when the execution completes.

Parameters
callback:BiConsumer<T, Instance<Object>>

the callback to dispose the instance

Returns:BeanConfigurator<T>

self

idback to summary
public BeanConfigurator<T> id(String id)

Make the configured bean implements PassivationCapable and its Id for passivation.

Parameters
id:String

for

Returns:BeanConfigurator<T>

self

See Also
PassivationCapable#getId()
injectionPointsback to summary
public BeanConfigurator<T> injectionPoints(InjectionPoint... injectionPoints)

Replace InjectionPoints for the configured bean

Parameters
injectionPoints:InjectionPoint[]

the injectionPoints for the configured bean

Returns:BeanConfigurator<T>

self

injectionPointsback to summary
public BeanConfigurator<T> injectionPoints(Set<InjectionPoint> injectionPoints)

Replace InjectionPoints for the configured bean

Parameters
injectionPoints:Set<InjectionPoint>

the injectionPoints for the configured bean

Returns:BeanConfigurator<T>

self

nameback to summary
public BeanConfigurator<T> name(String name)

Set the name of the configured bean

Parameters
name:String

name for the configured bean

Returns:BeanConfigurator<T>

self

produceWithback to summary
public <U extends T> BeanConfigurator<U> produceWith(Function<Instance<Object>, U> callback)

Set a callback to create a bean instance.

The Instance argument might be used to simulate producer method parameter injection. However, dependent scoped bean instances obtained from Instance during the callback execution remain managed until the produced bean instance is destroyed. Therefore, applications are encouraged to always destroy unneeded dependent scoped bean instances obtained from Instance.

Parameters
callback:Function<Instance<Object>, U>

the callback to create the instance

Returns:BeanConfigurator<U>

self

qualifiersback to summary
public BeanConfigurator<T> qualifiers(Annotation... qualifiers)

Replace all qualifiers.

Parameters
qualifiers:Annotation[]

qualifiers for the build bean

Returns:BeanConfigurator<T>

self

qualifiersback to summary
public BeanConfigurator<T> qualifiers(Set<Annotation> qualifiers)

Replace all qualifiers.

Parameters
qualifiers:Set<Annotation>

for the configured bean

Returns:BeanConfigurator<T>

self

readback to summary
public <U extends T> BeanConfigurator<U> read(AnnotatedType<U> type)

Read the information from the given annotated type. All relevant information is overwritten.

Parameters
type:AnnotatedType<U>

class to read information from

Returns:BeanConfigurator<U>

self

readback to summary
public BeanConfigurator<T> read(BeanAttributes<?> beanAttributes)

Read the information from the given bean attributes. All relevant information is overwritten.

Parameters
beanAttributes:BeanAttributes<?>

beanAttributes to read information from

Returns:BeanConfigurator<T>

self

scopeback to summary
public BeanConfigurator<T> scope(Class<? extends Annotation> scope)

Replace Bean scope

Parameters
scope:Class<? extends Annotation>

new scope for the configured bean

Returns:BeanConfigurator<T>

self

stereotypesback to summary
public BeanConfigurator<T> stereotypes(Set<Class<? extends Annotation>> stereotypes)

Replace stereotypes on the configured bean

Parameters
stereotypes:Set<Class<? extends Annotation>>

for the configured bean

Returns:BeanConfigurator<T>

self

typesback to summary
public BeanConfigurator<T> types(Type... types)

Replace bean types

Parameters
types:Type[]

the types of the configured bean

Returns:BeanConfigurator<T>

self

typesback to summary
public BeanConfigurator<T> types(Set<Type> types)

Replace bean types

Parameters
types:Set<Type>

the types of the configured bean

Returns:BeanConfigurator<T>

self