Top Description Methods
javax.enterprise.context.spi

public Interface Contextual<T>

Known Direct Subinterfaces
javax.enterprise.inject.spi.Bean
Type Parameters
<T>
type of the instance
Imports
javax.enterprise.inject.CreationException

Defines operations to create and destroy contextual instances of a certain type. Any implementation of Contextual is called a contextual type. In particular, all beans are contextual types.

Authors
Gavin King, Nicklas Karlsson, Pete Muir
See Also
javax.enterprise.inject.spi.Bean

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

the contextual instance
create
(CreationalContext<T>
the context in which this instance is being created
creationalContext
)

Create a new instance of the contextual type.

public void
destroy(T
the contextual instance to destroy
instance
,
CreationalContext<T>
the context in which this instance was created
creationalContext
)

Destroy an instance of the contextual type.

Method Detail

createback to summary
public T create(CreationalContext<T> creationalContext)

Create a new instance of the contextual type. Instances should use the given javax.enterprise.context.spi.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 javax.enterprise.context.spi.CreationalContext#push(Object) between instantiation and injection to help the container minimize the use of client proxy objects.

Parameters
creationalContext:CreationalContext<T>

the context in which this instance is being created

Returns:T

the contextual instance

Exceptions
CreationException:
if a checked exception occurs while creating the instance
destroyback to summary
public void destroy(T instance, CreationalContext<T> creationalContext)

Destroy an instance of the contextual type. Implementations should call javax.enterprise.context.spi.CreationalContext#release() to allow the container to destroy dependent objects of the contextual instance.

Parameters
instance:T

the contextual instance to destroy

creationalContext:CreationalContext<T>

the context in which this instance was created