public class BeanBuilder<T> extends Object
A builder class for creating immutable beans. The builder can create
PassivationCapable
beans.
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.
Constructor and Description |
---|
BeanBuilder(javax.enterprise.inject.spi.BeanManager beanManager)
Instantiate a new bean builder.
|
Modifier and Type | Method and Description |
---|---|
BeanBuilder<T> |
addQualifier(java.lang.annotation.Annotation qualifier)
Add to the qualifiers used for bean creation.
|
BeanBuilder<T> |
addQualifiers(java.lang.annotation.Annotation... qualifiers)
Add to the qualifiers used for bean creation.
|
BeanBuilder<T> |
addQualifiers(Collection<java.lang.annotation.Annotation> qualifiers)
Add to the qualifiers used for bean creation.
|
BeanBuilder<T> |
addType(Type type)
Add to the type closure used for bean creation.
|
BeanBuilder<T> |
addTypes(Collection<Type> types)
Add to the type closure used for bean creation.
|
BeanBuilder<T> |
addTypes(Type... types)
Add to the type closure used for bean creation.
|
BeanBuilder<T> |
alternative(boolean alternative)
Define that the created bean will (or will not) be an alternative.
|
BeanBuilder<T> |
beanClass(Class<?> beanClass)
Define the bean class used for bean creation.
|
BeanBuilder<T> |
beanLifecycle(ContextualLifecycle<T> beanLifecycle)
Define the
ContextualLifecycle used for bean creation. |
javax.enterprise.inject.spi.Bean<T> |
create()
Use the bean builder's current state to define the bean.
|
Class<?> |
getBeanClass()
The bean class currently defined for bean creation.
|
ContextualLifecycle<T> |
getBeanLifecycle()
The
ContextualLifecycle currently defined for bean creation. |
javax.enterprise.inject.spi.BeanManager |
getBeanManager()
The bean manager in use.
|
String |
getId()
The id currently defined for bean creation.
|
Set<javax.enterprise.inject.spi.InjectionPoint> |
getInjectionPoints()
The injection points currently defined for bean creation.
|
String |
getName()
The name of the bean currently defined for bean creation.
|
Set<java.lang.annotation.Annotation> |
getQualifiers()
Qualifiers currently defined for bean creation.
|
Class<? extends java.lang.annotation.Annotation> |
getScope()
Scope currently defined for bean creation.
|
Set<Class<? extends java.lang.annotation.Annotation>> |
getStereotypes()
Stereotypes currently defined for bean creation.
|
String |
getToString()
The string used when
Object.toString() is called on the bean. |
Set<Type> |
getTypes()
Type closure currently defined for bean creation.
|
BeanBuilder<T> |
id(String id)
Define the id used for bean creation.
|
BeanBuilder<T> |
injectionPoints(Set<javax.enterprise.inject.spi.InjectionPoint> injectionPoints)
Define the injection points used for bean creation.
|
boolean |
isAlternative()
Whether the created bean will be an alternative.
|
boolean |
isNullable()
Whether the created bean will be nullable.
|
boolean |
isPassivationCapable()
Whether the created bean will be passivation capable.
|
BeanBuilder<T> |
name(String name)
Define the name of the bean used for bean creation.
|
BeanBuilder<T> |
nullable(boolean nullable)
Define that the created bean will (or will not) be nullable.
|
BeanBuilder<T> |
passivationCapable(boolean passivationCapable)
Define that the created bean will (or will not) be passivation capable.
|
BeanBuilder<T> |
qualifiers(java.lang.annotation.Annotation... qualifiers)
Define the qualifiers used for bean creation.
|
BeanBuilder<T> |
qualifiers(Set<java.lang.annotation.Annotation> qualifiers)
Define the qualifiers used for bean creation.
|
BeanBuilder<T> |
readFromType(javax.enterprise.inject.spi.AnnotatedType<T> type)
Read the
AnnotatedType , creating a bean from the class and it's
annotations. |
BeanBuilder<T> |
scope(Class<? extends java.lang.annotation.Annotation> scope)
Define the scope used for bean creation.
|
BeanBuilder<T> |
stereotypes(Set<Class<? extends java.lang.annotation.Annotation>> stereotypes)
Define the stereotypes used for bean creation.
|
BeanBuilder<T> |
toString(String toString)
Define the string used when
Object.toString() is called on the bean. |
BeanBuilder<T> |
types(Set<Type> types)
Define the type closure used for bean creation.
|
BeanBuilder<T> |
types(Type... types)
Define the type closure used for bean creation.
|
public BeanBuilder(javax.enterprise.inject.spi.BeanManager beanManager)
beanManager
- the bean manager to use for creating injection targets
and determining if annotations are qualifiers, scopes or
stereotypes.public BeanBuilder<T> readFromType(javax.enterprise.inject.spi.AnnotatedType<T> type)
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)
.
BeanBuilder
does not support reading members of the class
to create producers or observer methods.
type
- the type to readpublic javax.enterprise.inject.spi.Bean<T> create()
Use the bean builder's current state to define the bean.
public Set<java.lang.annotation.Annotation> getQualifiers()
public BeanBuilder<T> qualifiers(Set<java.lang.annotation.Annotation> qualifiers)
qualifiers
- the qualifiers to usepublic BeanBuilder<T> qualifiers(java.lang.annotation.Annotation... qualifiers)
qualifiers
- the qualifiers to usepublic BeanBuilder<T> addQualifier(java.lang.annotation.Annotation qualifier)
qualifier
- the additional qualifier to usepublic BeanBuilder<T> addQualifiers(java.lang.annotation.Annotation... qualifiers)
qualifiers
- the additional qualifiers to usepublic BeanBuilder<T> addQualifiers(Collection<java.lang.annotation.Annotation> qualifiers)
qualifiers
- the additional qualifiers to usepublic Class<? extends java.lang.annotation.Annotation> getScope()
public BeanBuilder<T> scope(Class<? extends java.lang.annotation.Annotation> scope)
scope
- the scope to usepublic Set<Class<? extends java.lang.annotation.Annotation>> getStereotypes()
public BeanBuilder<T> stereotypes(Set<Class<? extends java.lang.annotation.Annotation>> stereotypes)
stereotypes
- the stereotypes to usepublic Set<Type> getTypes()
public BeanBuilder<T> types(Set<Type> types)
types
- the type closure to usepublic BeanBuilder<T> types(Type... types)
types
- the type closure to usepublic BeanBuilder<T> addType(Type type)
type
- additional type to usepublic BeanBuilder<T> addTypes(Type... types)
types
- the additional types to usepublic BeanBuilder<T> addTypes(Collection<Type> types)
types
- the additional types to usepublic boolean isAlternative()
true
if the created bean will be an alternative,
otherwise false
public BeanBuilder<T> alternative(boolean alternative)
alternative
- true
if the created bean should be an
alternative, otherwise false
public boolean isNullable()
true
if the created bean will be nullable, otherwise
false
public BeanBuilder<T> nullable(boolean nullable)
nullable
- true
if the created bean should be nullable,
otherwise false
public ContextualLifecycle<T> getBeanLifecycle()
ContextualLifecycle
currently defined for bean creation.public BeanBuilder<T> beanLifecycle(ContextualLifecycle<T> beanLifecycle)
ContextualLifecycle
used for bean creation.beanLifecycle
- the ContextualLifecycle
to use for bean
creation.public Class<?> getBeanClass()
public BeanBuilder<T> beanClass(Class<?> beanClass)
beanClass
- the bean class to usepublic javax.enterprise.inject.spi.BeanManager getBeanManager()
BeanBuilder
.public String getName()
null
if the bean has no namepublic BeanBuilder<T> name(String name)
name
- the name of the bean to use or null
if the bean
should have no namepublic boolean isPassivationCapable()
true
if the created bean will be passivation capable,
otherwise false
public BeanBuilder<T> passivationCapable(boolean passivationCapable)
passivationCapable
- true
if the created bean should be
passivation capable, otherwise false
public String getId()
public BeanBuilder<T> id(String id)
id
- the id to usepublic Set<javax.enterprise.inject.spi.InjectionPoint> getInjectionPoints()
public BeanBuilder<T> injectionPoints(Set<javax.enterprise.inject.spi.InjectionPoint> injectionPoints)
injectionPoints
- the injection points to usepublic BeanBuilder<T> toString(String toString)
Object.toString()
is called on the bean.toString
- the string to usepublic String getToString()
Object.toString()
is called on the bean.Copyright © 2014 The Apache Software Foundation. All rights reserved.