Class ImmutableBean<T>

java.lang.Object
org.infinispan.cdi.common.util.AbstractImmutableBean<T>
org.infinispan.cdi.common.util.ImmutableBean<T>
All Implemented Interfaces:
Contextual<T>, Bean<T>, BeanAttributes<T>
Direct Known Subclasses:
ImmutablePassivationCapableBean

public class ImmutableBean<T> extends AbstractImmutableBean<T> implements Bean<T>

A base class for implementing Bean. The attributes are immutable, and collections are defensively copied on instantiation. It uses the defaults from the specification for properties if not specified.

This bean delegates it's lifecycle to the callbacks on the provided ContextualLifecycle.

Author:
Stuart Douglas, Pete Muir
See Also:
  • Constructor Details

    • ImmutableBean

      public ImmutableBean(Class<?> beanClass, String name, Set<Annotation> qualifiers, Class<? extends Annotation> scope, Set<Class<? extends Annotation>> stereotypes, Set<Type> types, boolean alternative, boolean nullable, Set<InjectionPoint> injectionPoints, ContextualLifecycle<T> contextualLifecycle, String toString)
      Create a new, immutable bean. All arguments passed as collections are defensively copied.
      Parameters:
      beanClass - The Bean class, may not be null
      name - The bean name
      qualifiers - The bean's qualifiers, if null, a singleton set of Default is used
      scope - The bean's scope, if null, the default scope of Dependent is used
      stereotypes - The bean's stereotypes, if null, an empty set is used
      types - The bean's types, if null, the beanClass and Object will be used
      alternative - True if the bean is an alternative
      nullable - True if the bean is nullable
      injectionPoints - the bean's injection points, if null an empty set is used
      contextualLifecycle - Handler for create(CreationalContext) and destroy(Object, CreationalContext)
      toString - the string representation of the bean, if null the built in representation is used, which states the bean class and qualifiers
      Throws:
      IllegalArgumentException - if the beanClass is null
  • Method Details

    • create

      public T create(CreationalContext<T> arg0)
      Description copied from interface: Contextual
      Create a new instance of the contextual type. Instances should use the given CreationalContext when obtaining contextual references to inject, in order to ensure that any dependent objects are associated with the contextual instance that is being created. An implementation may call CreationalContext.push(Object) between instantiation and injection to help the container minimize the use of client proxy objects.
      Specified by:
      create in interface Contextual<T>
      Parameters:
      arg0 - the context in which this instance is being created
      Returns:
      the contextual instance
    • destroy

      public void destroy(T arg0, CreationalContext<T> arg1)
      Description copied from interface: Contextual
      Destroy an instance of the contextual type. Implementations should call CreationalContext.release() to allow the container to destroy dependent objects of the contextual instance.
      Specified by:
      destroy in interface Contextual<T>
      Parameters:
      arg0 - the contextual instance to destroy
      arg1 - the context in which this instance was created