Class BeanBuilder<T>
A builder class for creating immutable beans. The builder can create
PassivationCapable beans, using
Annotateds.createTypeId(AnnotatedType) to generate the id.
The builder can read from an AnnotatedType and have any attribute
modified. This class is not thread-safe, but the bean created by calling
create() is.
It is advised that a new bean builder is instantiated for each bean created.
- Author:
- Stuart Douglas, Pete Muir
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBeanBuilder(javax.enterprise.inject.spi.BeanManager beanManager) Instantiate a new bean builder. -
Method Summary
Modifier and TypeMethodDescriptionaddQualifier(Annotation qualifier) Add to the qualifiers used for bean creation.addQualifiers(Annotation... qualifiers) Add to the qualifiers used for bean creation.addQualifiers(Collection<Annotation> qualifiers) Add to the qualifiers used for bean creation.Add to the type closure used for bean creation.Add to the type closure used for bean creation.addTypes(Collection<Type> types) Add to the type closure used for bean creation.alternative(boolean alternative) Define that the created bean will (or will not) be an alternative.Define the bean class used for bean creation.beanLifecycle(ContextualLifecycle<T> beanLifecycle) Define theContextualLifecycleused for bean creation.javax.enterprise.inject.spi.Bean<T>create()Use the bean builder's current state to define the bean.Class<?>The bean class currently defined for bean creation.TheContextualLifecyclecurrently defined for bean creation.javax.enterprise.inject.spi.BeanManagerThe bean manager in use.getId()The id currently defined for bean creation.Set<javax.enterprise.inject.spi.InjectionPoint>The injection points currently defined for bean creation.getName()The name of the bean currently defined for bean creation.Qualifiers currently defined for bean creation.Class<? extends Annotation>getScope()Scope currently defined for bean creation.Set<Class<? extends Annotation>>Stereotypes currently defined for bean creation.The string used whenObject.toString()is called on the bean.getTypes()Type closure currently defined for bean creation.Define the id used for bean creation.injectionPoints(Set<javax.enterprise.inject.spi.InjectionPoint> injectionPoints) Define the injection points used for bean creation.booleanWhether the created bean will be an alternative.booleanWhether the created bean will be nullable.booleanWhether the created bean will be passivation capable.Define the name of the bean used for bean creation.nullable(boolean nullable) Define that the created bean will (or will not) be nullable.passivationCapable(boolean passivationCapable) Define that the created bean will (or will not) be passivation capable.qualifiers(Annotation... qualifiers) Define the qualifiers used for bean creation.qualifiers(Set<Annotation> qualifiers) Define the qualifiers used for bean creation.readFromType(javax.enterprise.inject.spi.AnnotatedType<T> type) Read theAnnotatedType, creating a bean from the class and it's annotations.scope(Class<? extends Annotation> scope) Define the scope used for bean creation.stereotypes(Set<Class<? extends Annotation>> stereotypes) Define the stereotypes used for bean creation.Define the string used whenObject.toString()is called on the bean.Define the type closure used for bean creation.Define the type closure used for bean creation.
-
Constructor Details
-
BeanBuilder
public BeanBuilder(javax.enterprise.inject.spi.BeanManager beanManager) Instantiate a new bean builder.- Parameters:
beanManager- the bean manager to use for creating injection targets and determining if annotations are qualifiers, scopes or stereotypes.
-
-
Method Details
-
readFromType
Read the
AnnotatedType, creating a bean from the class and it's annotations.By default the bean lifecycle will wrap the result of calling
BeanManager.createInjectionTarget(AnnotatedType).BeanBuilderdoes not support reading members of the class to create producers or observer methods.- Parameters:
type- the type to read
-
create
Use the bean builder's current state to define the bean.
- Returns:
- the bean
-
getQualifiers
Qualifiers currently defined for bean creation.- Returns:
- the qualifiers current defined
-
qualifiers
Define the qualifiers used for bean creation.- Parameters:
qualifiers- the qualifiers to use
-
qualifiers
Define the qualifiers used for bean creation.- Parameters:
qualifiers- the qualifiers to use
-
addQualifier
Add to the qualifiers used for bean creation.- Parameters:
qualifiers- the additional qualifier to use
-
addQualifiers
Add to the qualifiers used for bean creation.- Parameters:
qualifiers- the additional qualifiers to use
-
addQualifiers
Add to the qualifiers used for bean creation.- Parameters:
qualifiers- the additional qualifiers to use
-
getScope
Scope currently defined for bean creation.- Returns:
- the scope currently defined
-
scope
Define the scope used for bean creation.- Parameters:
scope- the scope to use
-
getStereotypes
Stereotypes currently defined for bean creation.- Returns:
- the stereotypes currently defined
-
stereotypes
Define the stereotypes used for bean creation.- Parameters:
stereotypes- the stereotypes to use
-
getTypes
Type closure currently defined for bean creation.- Returns:
- the type closure currently defined
-
types
Define the type closure used for bean creation.- Parameters:
types- the type closure to use
-
types
Define the type closure used for bean creation.- Parameters:
types- the type closure to use
-
addType
Add to the type closure used for bean creation.- Parameters:
type- additional type to use
-
addTypes
Add to the type closure used for bean creation.- Parameters:
types- the additional types to use
-
addTypes
Add to the type closure used for bean creation.- Parameters:
types- the additional types to use
-
isAlternative
public boolean isAlternative()Whether the created bean will be an alternative.- Returns:
trueif the created bean will be an alternative, otherwisefalse
-
alternative
Define that the created bean will (or will not) be an alternative.- Parameters:
alternative-trueif the created bean should be an alternative, otherwisefalse
-
isNullable
public boolean isNullable()Whether the created bean will be nullable.- Returns:
trueif the created bean will be nullable, otherwisefalse
-
nullable
Define that the created bean will (or will not) be nullable.- Parameters:
nullable-trueif the created bean should be nullable, otherwisefalse
-
getBeanLifecycle
TheContextualLifecyclecurrently defined for bean creation.- Returns:
- the bean lifecycle currently defined
-
beanLifecycle
Define theContextualLifecycleused for bean creation.- Parameters:
beanLifecycle- theContextualLifecycleto use for bean creation.
-
getBeanClass
The bean class currently defined for bean creation.- Returns:
- the bean class currently defined.
-
beanClass
Define the bean class used for bean creation.- Parameters:
beanClass- the bean class to use
-
getBeanManager
public javax.enterprise.inject.spi.BeanManager getBeanManager()The bean manager in use. This cannot be changed for thisBeanBuilder.- Returns:
- the bean manager in use
-
getName
The name of the bean currently defined for bean creation.- Returns:
- the name of the bean or
nullif the bean has no name
-
name
Define the name of the bean used for bean creation.- Parameters:
name- the name of the bean to use ornullif the bean should have no name
-
isPassivationCapable
public boolean isPassivationCapable()Whether the created bean will be passivation capable.- Returns:
trueif the created bean will be passivation capable, otherwisefalse
-
passivationCapable
Define that the created bean will (or will not) be passivation capable.- Parameters:
nullable-trueif the created bean should be passivation capable, otherwisefalse
-
getId
The id currently defined for bean creation.- Returns:
- the id currently defined.
-
id
Define the id used for bean creation.- Parameters:
id- the id to use
-
getInjectionPoints
The injection points currently defined for bean creation.- Returns:
- the injection points currently defined.
-
injectionPoints
public BeanBuilder<T> injectionPoints(Set<javax.enterprise.inject.spi.InjectionPoint> injectionPoints) Define the injection points used for bean creation.- Parameters:
injectionPoints- the injection points to use
-
toString
Define the string used whenObject.toString()is called on the bean.- Parameters:
toString- the string to use
-
getToString
The string used whenObject.toString()is called on the bean.- Returns:
- the string currently defined
-