[[spi_ee]]

== Portable extensions in Jakarta EE

[[bean_ee]]
 
=== The `Bean` interface in Jakarta EE
 
When Running in Jakarta EE, the container must extend the rules defined in <<bean>> for managed bean to Jakarta Enterprise Bean session bean.

[[interceptor_ee]]

==== The `Interceptor` interface in Jakarta EE

When Running in Jakarta EE, the container must extend the rules defined in <<interceptor>> and must also ensure that
 
`PRE_PASSIVATE`, `POST_ACTIVATE` and `AROUND_TIMEOUT` InterceptorType values are linked to Jakarta Enterprise Bean lifecycle callback or timeout method.


[[injectiontarget_ee]]

=== `InjectionTarget` interface in Jakarta EE

When running in Jakarta EE, the container must extend the rules defined for `InjectionTarget` in <<injectiontarget>> and must also ensure that:

* when `inject()` is called, The container performs Jakarta EE component environment injection, according to the semantics required by the Jakarta EE platform specification, sets the value of all injected fields, and calls all initializer methods, as defined in <<fields_initializer_methods_ee>>.
* `@PostConstruct` callback is called according to the semantics required by the Jakarta EE platform specification.
* `@PreDestroy` callback is called according to the semantics required by the Jakarta EE platform specification.


[[beanmanager_ee]]

=== The `BeanManager` object in Jakarta EE

[[provider_ee]]

==== Obtaining a reference to the CDI container in Jakarta EE

A Jakarta EE container is required to provide a CDI provider that will allow access to the current container for any Jakarta EE application or Jakarta EE module which contains enabled beans.

Jakarta EE Components may obtain an instance of `BeanManager` from JNDI by looking up the name `java:comp/BeanManager`.

[[bm_wrap_expressionfactory]]

==== Wrapping a Unified EL `ExpressionFactory`

The method `BeanManager.wrapExpressionFactory()` returns a wrapper `javax.el.ExpressionFactory` that delegates `MethodExpression` and `ValueExpression` creation to the given `ExpressionFactory`. When a Unified EL expression is evaluated using a `MethodExpression` or `ValueExpression` returned by the wrapper `ExpressionFactory`, the rules defined in <<dependent_scope_el>> are enforced by the container.

[source, java]
----
public ExpressionFactory wrapExpressionFactory(ExpressionFactory expressionFactory);
----

[[alternative_metadata_sources_ee]]

=== Alternative metadata sources and Jakarta Enterprise Bean

When running in Jakarta EE, the container must extend the rules defined in <<alternative_metadata_sources>> and ensure that:

* when an `AnnotatedType` represents an Jakarta Enterprise Bean session bean class, `Annotated.getTypeClosure()` must returns the Jakarta Enterprise Bean session bean types as defined in <<session_bean_types>>.

[[init_events_ee]]

=== Addition to Container lifecycle events in Jakarta EE

[[process_annotated_type_ee]]

==== `ProcessAnnotatedType` event in Jakarta EE

When running in Jakarta EE, the container must extend the rules defined in <<process_annotated_type>> to Jakarta EE component and Jakarta Enterprise Bean session bean classes.

[[process_injection_point_ee]]

==== `ProcessInjectionPoint` event and Jakarta Enterprise Bean

When running in Jakarta EE, the container must also fire an event for every injection point of every Jakarta EE component class supporting injection that may be instantiated by the container at runtime, including every managed bean declared using `@ManagedBean`, Jakarta Enterprise Bean session or message-driven bean.

[[process_injection_target_ee]]

==== `ProcessInjectionTarget` event and Jakarta Enterprise Bean

When running in Jakarta EE, the container must also fire an event for every Jakarta EE component class supporting injection that may be instantiated by the container at runtime, including every managed bean declared using `@ManagedBean`, Jakarta Enterprise Bean session or message-driven bean.

The container must extend the rules defined in <<process_injection_target>> for managed bean to Jakarta Enterprise Bean session bean and other Jakarta EE component class supporting injection.

For example, this observer decorates the `InjectionTarget` for all servlets.

[source, java]
----
<T extends Servlet> void decorateServlet(@Observes ProcessInjectionTarget<T> pit) {
    pit.setInjectionTarget( decorate( pit.getInjectionTarget() ) );
}
----


[[process_bean_attributes_ee]]

==== `ProcessBeanAttributes` event and Jakarta Enterprise Bean

When running in Jakarta EE, the container must extend the rules defined in <<process_bean_attributes>> to Jakarta Enterprise Bean session bean.


[[process_bean_ee]]

==== `ProcessBean` event and Jakarta Enterprise Bean

In addition to definition given in <<process_bean>> the following apply:

* For a session bean with bean class `X`, the container must raise an event of type `ProcessSessionBean<X>`.

Resources are considered to be producer fields.

When running in Jakarta EE, the interface `javax.enterprise.inject.spi.ProcessBean` is also a supertype of `javax.enterprise.inject.spi.ProcessSession` :

[source, java]
----
public interface ProcessSessionBean<X>
        extends ProcessManagedBean<Object> {
    public String getEjbName();
    public SessionBeanType getSessionBeanType();
}
----

* `getEjbName()` returns the Jakarta Enterprise Bean name of the session bean.
* `getSessionBeanType()` returns a `javax.enterprise.inject.spi.SessionBeanType` representing the kind of session bean.

[source, java]
----
public enum SessionBeanType { STATELESS, STATEFUL, SINGLETON }
----
