Interface SyntheticBeanBuilder<T>
-
- Type Parameters:
T
- the bean class of this synthetic bean
public interface SyntheticBeanBuilder<T>
Builder for synthetic beans. Instances are not reusable. For each synthetic bean, new instance must be created bySyntheticComponents.addBean(Class)
.- Since:
- 4.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description SyntheticBeanBuilder<T>
alternative(boolean isAlternative)
Marks this synthetic bean as an alternative if desired.SyntheticBeanBuilder<T>
createWith(java.lang.Class<? extends SyntheticBeanCreator<T>> creatorClass)
Sets the class of the synthetic bean creation function.SyntheticBeanBuilder<T>
disposeWith(java.lang.Class<? extends SyntheticBeanDisposer<T>> disposerClass)
Sets the class of the synthetic bean destruction function.SyntheticBeanBuilder<T>
name(java.lang.String beanName)
Sets the bean name of this synthetic bean.SyntheticBeanBuilder<T>
priority(int priority)
Sets a priority of this synthetic bean.SyntheticBeanBuilder<T>
qualifier(AnnotationInfo qualifierAnnotation)
Adds given annotation to the set of qualifiers of this synthetic bean.SyntheticBeanBuilder<T>
qualifier(java.lang.annotation.Annotation qualifierAnnotation)
Adds given annotation to the set of qualifiers of this synthetic bean.SyntheticBeanBuilder<T>
qualifier(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Adds a marker annotation of given type to the set of qualifiers of this synthetic bean.SyntheticBeanBuilder<T>
scope(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation)
Sets the scope of this synthetic bean to given scope type.SyntheticBeanBuilder<T>
stereotype(ClassInfo stereotypeAnnotation)
AddsstereotypeAnnotation
to the set of stereotypes of this synthetic bean.SyntheticBeanBuilder<T>
stereotype(java.lang.Class<? extends java.lang.annotation.Annotation> stereotypeAnnotation)
AddsstereotypeAnnotation
to the set of stereotypes of this synthetic bean.SyntheticBeanBuilder<T>
type(ClassInfo type)
Addstype
to the set of bean types of this synthetic bean.SyntheticBeanBuilder<T>
type(Type type)
Addstype
to the set of bean types of this synthetic bean.SyntheticBeanBuilder<T>
type(java.lang.Class<?> type)
Addstype
to the set of bean types of this synthetic bean.SyntheticBeanBuilder<T>
withParam(java.lang.String key, boolean value)
Adds aboolean
-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, boolean[] value)
Adds aboolean
array-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, double value)
Adds adouble
-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, double[] value)
Adds adouble
array-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, int value)
Adds anint
-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, int[] value)
Adds anint
array-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, long value)
Adds along
-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, long[] value)
Adds along
array-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, AnnotationInfo value)
Adds an annotation-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, AnnotationInfo[] value)
Adds an annotation array-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, ClassInfo value)
Adds aClass
-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, ClassInfo[] value)
Adds aClass
array-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, java.lang.annotation.Annotation value)
Adds an annotation-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, java.lang.annotation.Annotation[] value)
Adds an annotation array-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, java.lang.Class<?> value)
Adds aClass
-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, java.lang.Class<?>[] value)
Adds aClass
array-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, java.lang.Enum<?> value)
Adds an enum-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, java.lang.Enum<?>[] value)
Adds an enum array-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, java.lang.String value)
Adds aString
-valued parameter to the parameter map.SyntheticBeanBuilder<T>
withParam(java.lang.String key, java.lang.String[] value)
Adds aString
array-valued parameter to the parameter map.
-
-
-
Method Detail
-
type
SyntheticBeanBuilder<T> type(java.lang.Class<?> type)
Addstype
to the set of bean types of this synthetic bean. This method may be called multiple times to add multiple bean types.If not called, the set of bean types of this synthetic bean will be a singleton set containing
java.lang.Object
.- Parameters:
type
- the bean type, must not benull
- Returns:
- this
SyntheticBeanBuilder
-
type
SyntheticBeanBuilder<T> type(ClassInfo type)
Addstype
to the set of bean types of this synthetic bean. This method may be called multiple times to add multiple bean types.If not called, the set of bean types of this synthetic bean will be a singleton set containing
java.lang.Object
.- Parameters:
type
- the bean type, must not benull
- Returns:
- this
SyntheticBeanBuilder
-
type
SyntheticBeanBuilder<T> type(Type type)
Addstype
to the set of bean types of this synthetic bean. This method may be called multiple times to add multiple bean types.If not called, the set of bean types of this synthetic bean will be a singleton set containing
java.lang.Object
.- Parameters:
type
- the bean type, must not benull
- Returns:
- this
SyntheticBeanBuilder
-
qualifier
SyntheticBeanBuilder<T> qualifier(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Adds a marker annotation of given type to the set of qualifiers of this synthetic bean. This method may be called multiple times to add multiple qualifiers.If not called, this synthetic bean will have the
@Default
qualifier (and the@Any
qualifier that all beans have).- Parameters:
annotationType
- the type of the marker annotation, must not benull
- Returns:
- this
SyntheticBeanBuilder
-
qualifier
SyntheticBeanBuilder<T> qualifier(AnnotationInfo qualifierAnnotation)
Adds given annotation to the set of qualifiers of this synthetic bean. This method may be called multiple times to add multiple qualifiers.If not called, this synthetic bean will have the
@Default
qualifier (and the@Any
qualifier that all beans have).- Parameters:
qualifierAnnotation
- the annotation, must not benull
- Returns:
- this
SyntheticBeanBuilder
-
qualifier
SyntheticBeanBuilder<T> qualifier(java.lang.annotation.Annotation qualifierAnnotation)
Adds given annotation to the set of qualifiers of this synthetic bean. This method may be called multiple times to add multiple qualifiers.If not called, this synthetic bean will have the
@Default
qualifier (and the@Any
qualifier that all beans have).- Parameters:
qualifierAnnotation
- the annotation, must not benull
- Returns:
- this
SyntheticBeanBuilder
-
scope
SyntheticBeanBuilder<T> scope(java.lang.Class<? extends java.lang.annotation.Annotation> scopeAnnotation)
Sets the scope of this synthetic bean to given scope type.If not called, this synthetic bean will be
@Dependent
.- Parameters:
scopeAnnotation
- the scope type, must not benull
- Returns:
- this
SyntheticBeanBuilder
- Throws:
java.lang.IllegalStateException
- if this method is called multiple times
-
alternative
SyntheticBeanBuilder<T> alternative(boolean isAlternative)
Marks this synthetic bean as an alternative if desired. To make this synthetic bean an enabled alternative, call bothalternative(true)
andpriority(some priority)
.If this synthetic bean is an alternative, not setting a priority means that it is not enabled, which is equivalent to not registering it at all.
If not called, this synthetic bean will not be an alternative.
- Parameters:
isAlternative
- whether this synthetic bean should be an alternative- Returns:
- this
SyntheticBeanBuilder
- Throws:
java.lang.IllegalStateException
- if this method is called multiple times
-
priority
SyntheticBeanBuilder<T> priority(int priority)
Sets a priority of this synthetic bean. To make this synthetic bean an enabled alternative, call bothalternative(true)
andpriority(some priority)
.If this synthetic bean is an alternative, not setting a priority means that it is not enabled, which is equivalent to not registering it at all.
If not called, this synthetic bean will not have a priority. If this synthetic bean is not an alternative, the priority is ignored.
- Parameters:
priority
- the priority of this synthetic bean- Returns:
- this
SyntheticBeanBuilder
- Throws:
java.lang.IllegalStateException
- if this method is called multiple times
-
name
SyntheticBeanBuilder<T> name(java.lang.String beanName)
Sets the bean name of this synthetic bean. IfbeanName
isnull
, this synthetic bean will not have a name.If not called, this synthetic bean will not have a name.
- Parameters:
beanName
- the bean name of this synthetic bean- Returns:
- this
SyntheticBeanBuilder
- Throws:
java.lang.IllegalStateException
- if this method is called multiple times
-
stereotype
SyntheticBeanBuilder<T> stereotype(java.lang.Class<? extends java.lang.annotation.Annotation> stereotypeAnnotation)
AddsstereotypeAnnotation
to the set of stereotypes of this synthetic bean. This method may be called multiple times to add multiple stereotypes.If not called, this synthetic bean will have no stereotype.
- Parameters:
stereotypeAnnotation
- the stereotype, must not benull
- Returns:
- this
SyntheticBeanBuilder
-
stereotype
SyntheticBeanBuilder<T> stereotype(ClassInfo stereotypeAnnotation)
AddsstereotypeAnnotation
to the set of stereotypes of this synthetic bean. This method may be called multiple times to add multiple stereotypes.If not called, this synthetic bean will have no stereotype.
- Parameters:
stereotypeAnnotation
- the stereotype, must not benull
- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, boolean value)
Adds aboolean
-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, boolean[] value)
Adds aboolean
array-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, int value)
Adds anint
-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, int[] value)
Adds anint
array-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, long value)
Adds along
-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, long[] value)
Adds along
array-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, double value)
Adds adouble
-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, double[] value)
Adds adouble
array-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, java.lang.String value)
Adds aString
-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, java.lang.String[] value)
Adds aString
array-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, java.lang.Enum<?> value)
Adds an enum-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, java.lang.Enum<?>[] value)
Adds an enum array-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, java.lang.Class<?> value)
Adds aClass
-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, ClassInfo value)
Adds aClass
-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.When looked up from the parameter map in the creation/destruction function, the value will be an instance of
Class
, not aClassInfo
.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, java.lang.Class<?>[] value)
Adds aClass
array-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, ClassInfo[] value)
Adds aClass
array-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.When looked up from the parameter map in the creation/destruction function, the values will be instances of
Class
, notClassInfo
.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, AnnotationInfo value)
Adds an annotation-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.When looked up from the parameter map in the creation/destruction function, the value will be an instance of the annotation type, not an
AnnotationInfo
.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, java.lang.annotation.Annotation value)
Adds an annotation-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, AnnotationInfo[] value)
Adds an annotation array-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.When looked up from the parameter map in the creation/destruction function, the values will be instances of the corresponding annotation types, not
AnnotationInfo
.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
withParam
SyntheticBeanBuilder<T> withParam(java.lang.String key, java.lang.annotation.Annotation[] value)
Adds an annotation array-valued parameter to the parameter map. The parameter map is passed to the creation and destruction functions when a bean instance is created/destroyed.- Parameters:
key
- the parameter key, must not benull
value
- the parameter value- Returns:
- this
SyntheticBeanBuilder
-
createWith
SyntheticBeanBuilder<T> createWith(java.lang.Class<? extends SyntheticBeanCreator<T>> creatorClass)
Sets the class of the synthetic bean creation function. CDI container will create an instance of the creation function every time when it needs to obtain an instance of the synthetic bean. The class must bepublic
and have apublic
zero-parameter constructor; it must not be a bean.If not called, the synthetic bean registration will fail.
- Parameters:
creatorClass
- the creation function class, must not benull
- Returns:
- this
SyntheticBeanBuilder
- Throws:
java.lang.IllegalStateException
- if this method is called multiple times
-
disposeWith
SyntheticBeanBuilder<T> disposeWith(java.lang.Class<? extends SyntheticBeanDisposer<T>> disposerClass)
Sets the class of the synthetic bean destruction function. CDI container will create an instance of the destruction function every time when it needs to destruction an instance of the synthetic bean. The class must bepublic
and have apublic
zero-parameter constructor; it must not be a bean.If not called, a noop destruction function will be used.
- Parameters:
disposerClass
- the destruction function class, must not benull
- Returns:
- this
SyntheticBeanBuilder
- Throws:
java.lang.IllegalStateException
- if this method is called multiple times
-
-