org.apache.webbeans.component
Class AbstractOwbBean<T>

java.lang.Object
  extended by org.apache.webbeans.component.AbstractOwbBean<T>
All Implemented Interfaces:
javax.enterprise.context.spi.Contextual<T>, javax.enterprise.inject.spi.Bean<T>, OwbBean<T>
Direct Known Subclasses:
AbstractInjectionTargetBean, AbstractProducerBean, BeanManagerBean, BuildInOwbBean, EventBean, InjectionPointBean, InstanceBean, ThirdpartyBeanImpl, WebBeansInterceptor

public abstract class AbstractOwbBean<T>
extends Object
implements OwbBean<T>

Abstract implementation of the OwbBean contract.

Version:
$Rev: 1224972 $ $Date: 2011-12-27 19:30:00 +0100 (Di, 27 Dez 2011) $
See Also:
Bean

Field Summary
protected  Set<Type> apiTypes
          Api types of the bean
protected  boolean enabled
          This bean is enabled or disabled
protected  Set<Annotation> implQualifiers
          Qualifiers of the bean
protected  Annotation implScopeType
          Scope type of the bean
protected  Set<javax.enterprise.inject.spi.InjectionPoint> injectionPoints
          Beans injection points
protected  String name
          Name of the bean
protected  boolean nullable
          The bean allows nullable object
protected  String passivatingId
          This string will be used for passivating the Bean.
protected  Class<T> returnType
          Return type of the bean
protected  Class<? extends Annotation> scopeClass
          Cached scope type of the bean
protected  boolean serializable
          The bean is serializable or not
protected  boolean specializedBean
          This bean is specialized or not
protected  Set<Class<? extends Annotation>> stereoTypeClasses
          this is only for public access and will be built from stereoTypes on demand
protected  Set<Annotation> stereoTypes
          Stereotypes of the bean
protected  WebBeansType webBeansType
          Web Beans type
 
Constructor Summary
protected AbstractOwbBean(WebBeansType webBeansType, Class<T> returnType, WebBeansContext webBeansContext)
          Constructor definiton.
protected AbstractOwbBean(WebBeansType webBeanType, WebBeansContext webBeansContext)
          Creates a new instance.
 
Method Summary
 void addApiType(Class<?> apiType)
          Add new api type.
 void addInjectionPoint(javax.enterprise.inject.spi.InjectionPoint injectionPoint)
          Adds new injection point.
 void addQualifier(Annotation qualifier)
          Add new qualifier.
 void addStereoType(Annotation stereoType)
          Add new stereotype.
 T create(javax.enterprise.context.spi.CreationalContext<T> creationalContext)
          
protected abstract  T createInstance(javax.enterprise.context.spi.CreationalContext<T> creationalContext)
          Creates the instance of the bean that has a specific implementation type.
 T createNewInstance(javax.enterprise.context.spi.CreationalContext<T> creationalContext)
          Create an instance.
 void destroy(T instance, javax.enterprise.context.spi.CreationalContext<T> creationalContext)
           
 void destroyCreatedInstance(T instance, javax.enterprise.context.spi.CreationalContext<T> creationalContext)
          Destroys instance.
protected  void destroyInstance(T instance, javax.enterprise.context.spi.CreationalContext<T> creationalContext)
          Destroy the instance of the bean.
 boolean equals(Object obj)
           
 Class<?> getBeanClass()
          Get return types of the bean.
 String getId()
          get the unique Id of the bean.
 Set<Annotation> getImplQualifiers()
          Get qualifiers.
 Annotation getImplScopeType()
          Get scope type.
 List<javax.enterprise.inject.spi.InjectionPoint> getInjectionPoint(Member member)
          Gets injection points for given member.
 Set<javax.enterprise.inject.spi.InjectionPoint> getInjectionPoints()
          
protected  WebBeansLogger getLogger()
          The Logger should really only be used to log errors!
protected  BeanManagerImpl getManager()
          Gets manager instance
 String getName()
          Name of the bean.
 Set<Annotation> getOwbStereotypes()
          Gets the stereotypes.
 Set<Annotation> getQualifiers()
           
 Class<T> getReturnType()
          Gets type of the producer method/field or the bean class if it's not a producer.
 Class<? extends Annotation> getScope()
           
 Set<Class<? extends Annotation>> getStereotypes()
          
 Set<Type> getTypes()
           
 WebBeansContext getWebBeansContext()
          Get the web beans context this bean is associated with
 WebBeansType getWebBeansType()
          Get web bean type of the bean.
 int hashCode()
           
 boolean isAlternative()
          
 boolean isDependent()
          This determines if this bean is really a dependent bean, and as such always creats a freshl instance for each InjectionPoint.
 boolean isEnabled()
          Bean is enabled or not.
 boolean isNullable()
          
 boolean isPassivationCapable()
          True if passivation capable false otherwise.
 boolean isSerializable()
          Returns true if bean is capable of serializable, false otherwise.
 boolean isSpecializedBean()
          Returns true if bean is a specialized bean, false otherwise.
 void setEnabled(boolean enabled)
          Set enableed flag.
 void setImplScopeType(Annotation scopeType)
          Set scope type.
 void setName(String name)
          Set name.
 void setNullable(boolean nullable)
          Set nullable flag.
 void setSerializable(boolean serializable)
          Sets serializable flag.
 void setSpecializedBean(boolean specialized)
          Set specialized flag.
 String toString()
          
 void validatePassivationDependencies()
          If bean is passivation capable, it validate all of its dependencies.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected String name
Name of the bean


implScopeType

protected Annotation implScopeType
Scope type of the bean


scopeClass

protected Class<? extends Annotation> scopeClass
Cached scope type of the bean


implQualifiers

protected Set<Annotation> implQualifiers
Qualifiers of the bean


apiTypes

protected Set<Type> apiTypes
Api types of the bean


webBeansType

protected WebBeansType webBeansType
Web Beans type


returnType

protected Class<T> returnType
Return type of the bean


stereoTypes

protected Set<Annotation> stereoTypes
Stereotypes of the bean


stereoTypeClasses

protected Set<Class<? extends Annotation>> stereoTypeClasses
this is only for public access and will be built from stereoTypes on demand


specializedBean

protected boolean specializedBean
This bean is specialized or not


enabled

protected boolean enabled
This bean is enabled or disabled


serializable

protected boolean serializable
The bean is serializable or not


nullable

protected boolean nullable
The bean allows nullable object


injectionPoints

protected Set<javax.enterprise.inject.spi.InjectionPoint> injectionPoints
Beans injection points


passivatingId

protected String passivatingId
This string will be used for passivating the Bean. It will be created on the first use.

See Also:
getId()
Constructor Detail

AbstractOwbBean

protected AbstractOwbBean(WebBeansType webBeansType,
                          Class<T> returnType,
                          WebBeansContext webBeansContext)
Constructor definiton. Each subclass redefines its own constructor with calling this.

Parameters:
returnType - of the bean
webBeansContext -
webBeansType - web beans type

AbstractOwbBean

protected AbstractOwbBean(WebBeansType webBeanType,
                          WebBeansContext webBeansContext)
Creates a new instance.

Parameters:
webBeanType - beans type
webBeansContext -
Method Detail

getWebBeansContext

public WebBeansContext getWebBeansContext()
Get the web beans context this bean is associated with

Specified by:
getWebBeansContext in interface OwbBean<T>
Returns:
WebBeansContext this bean is associated with

getManager

protected BeanManagerImpl getManager()
Gets manager instance

Returns:
manager instance

create

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

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

createInstance

protected abstract T createInstance(javax.enterprise.context.spi.CreationalContext<T> creationalContext)
Creates the instance of the bean that has a specific implementation type. Each subclass must define its own create mechanism.

Parameters:
creationalContext - the contextual instance shall be created in
Returns:
instance of the bean

createNewInstance

public T createNewInstance(javax.enterprise.context.spi.CreationalContext<T> creationalContext)
Create an instance.

Specified by:
createNewInstance in interface OwbBean<T>
Parameters:
creationalContext - creaitonal context
Returns:
instance

destroy

public void destroy(T instance,
                    javax.enterprise.context.spi.CreationalContext<T> creationalContext)
Specified by:
destroy in interface javax.enterprise.context.spi.Contextual<T>

destroyInstance

protected void destroyInstance(T instance,
                               javax.enterprise.context.spi.CreationalContext<T> creationalContext)
Destroy the instance of the bean. Each subclass must define its own destroy mechanism.

Parameters:
instance - instance of the bean that is being destroyed
creationalContext - the contextual instance has been created in

destroyCreatedInstance

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

Specified by:
destroyCreatedInstance in interface OwbBean<T>
Parameters:
instance - instance
creationalContext - creational

getId

public String getId()
get the unique Id of the bean. This will get used as reference on passivation. Gets id of the bean.

Specified by:
getId in interface OwbBean<T>
Returns:
id of the bean

isPassivationCapable

public boolean isPassivationCapable()
Description copied from interface: OwbBean
True if passivation capable false otherwise.

Specified by:
isPassivationCapable in interface OwbBean<T>
Returns:
true if this bean is passivation capable

getBeanClass

public Class<?> getBeanClass()
Get return types of the bean. As per section 11.1 it is defined as "returns the bean class of the managed bean or session bean or of the bean that declares the producer method or field." Which means in case of a producer field or method, we need to return the class where the producer field/method is defined in.

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

getImplScopeType

public Annotation getImplScopeType()
Get scope type.

Specified by:
getImplScopeType in interface OwbBean<T>
Returns:
scope type

setImplScopeType

public void setImplScopeType(Annotation scopeType)
Set scope type.

Specified by:
setImplScopeType in interface OwbBean<T>
Parameters:
scopeType - scope type

getName

public String getName()
Name of the bean.

Specified by:
getName in interface javax.enterprise.inject.spi.Bean<T>
Returns:
name of the bean

getWebBeansType

public WebBeansType getWebBeansType()
Get web bean type of the bean.

Specified by:
getWebBeansType in interface OwbBean<T>
Returns:
web beans type
See Also:
WebBeansType

addStereoType

public void addStereoType(Annotation stereoType)
Add new stereotype.

Specified by:
addStereoType in interface OwbBean<T>
Parameters:
stereoType - new stereotype annotation

addApiType

public void addApiType(Class<?> apiType)
Add new api type.

Specified by:
addApiType in interface OwbBean<T>
Parameters:
apiType - new api type

getImplQualifiers

public Set<Annotation> getImplQualifiers()
Get qualifiers.

Specified by:
getImplQualifiers in interface OwbBean<T>
Returns:
qualifiers

getOwbStereotypes

public Set<Annotation> getOwbStereotypes()
Gets the stereotypes.

Specified by:
getOwbStereotypes in interface OwbBean<T>
Returns:
stereotypes of the bean

addQualifier

public void addQualifier(Annotation qualifier)
Add new qualifier.

Specified by:
addQualifier in interface OwbBean<T>
Parameters:
qualifier - new qualifier

setName

public void setName(String name)
Set name.

Specified by:
setName in interface OwbBean<T>
Parameters:
name - new name

getQualifiers

public Set<Annotation> getQualifiers()
Specified by:
getQualifiers 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>

getTypes

public Set<Type> getTypes()
Specified by:
getTypes in interface javax.enterprise.inject.spi.Bean<T>

getReturnType

public Class<T> getReturnType()
Gets type of the producer method/field or the bean class if it's not a producer. This basically determines the class which will get created.

Specified by:
getReturnType in interface OwbBean<T>
Returns:
type of the producer method
See Also:
getBeanClass()

setNullable

public void setNullable(boolean nullable)
Set nullable flag.

Specified by:
setNullable in interface OwbBean<T>
Parameters:
nullable - flag

setSerializable

public void setSerializable(boolean serializable)
Sets serializable flag.

Specified by:
setSerializable in interface OwbBean<T>
Parameters:
serializable - flag

isNullable

public boolean isNullable()

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

isSerializable

public boolean isSerializable()
Returns true if bean is capable of serializable, false otherwise.

Specified by:
isSerializable in interface OwbBean<T>
Returns:
true if bean is serializable

addInjectionPoint

public void addInjectionPoint(javax.enterprise.inject.spi.InjectionPoint injectionPoint)
Adds new injection point.

Specified by:
addInjectionPoint in interface OwbBean<T>
Parameters:
injectionPoint - injection point

getInjectionPoints

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

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

setSpecializedBean

public void setSpecializedBean(boolean specialized)
Set specialized flag.

Specified by:
setSpecializedBean in interface OwbBean<T>
Parameters:
specialized - flag

setEnabled

public void setEnabled(boolean enabled)
Set enableed flag.

Specified by:
setEnabled in interface OwbBean<T>
Parameters:
enabled - flag

isSpecializedBean

public boolean isSpecializedBean()
Returns true if bean is a specialized bean, false otherwise.

Specified by:
isSpecializedBean in interface OwbBean<T>
Returns:
true if bean is a specialized bean

getInjectionPoint

public List<javax.enterprise.inject.spi.InjectionPoint> getInjectionPoint(Member member)
Gets injection points for given member.

For example, if member is field, it gets all injected field's injection points of bean.

Specified by:
getInjectionPoint in interface OwbBean<T>
Parameters:
member - java member
Returns:
injection points for given member

getStereotypes

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

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

isAlternative

public boolean isAlternative()

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

isEnabled

public boolean isEnabled()
Bean is enabled or not.

Specified by:
isEnabled in interface OwbBean<T>
Returns:
true if enabled

toString

public String toString()

Overrides:
toString in class Object

getLogger

protected WebBeansLogger getLogger()
The Logger should really only be used to log errors!


isDependent

public boolean isDependent()
Description copied from interface: OwbBean
This determines if this bean is really a dependent bean, and as such always creats a freshl instance for each InjectionPoint. A BeanManagerBean is e.g. not a dependent bean.

Specified by:
isDependent in interface OwbBean<T>
Returns:
true if this is a dependent bean

validatePassivationDependencies

public void validatePassivationDependencies()
Description copied from interface: OwbBean
If bean is passivation capable, it validate all of its dependencies.

Specified by:
validatePassivationDependencies in interface OwbBean<T>

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object


Copyright © 2008-2012 The Apache Software Foundation. All Rights Reserved.