Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Binding an Interceptor to a Component
Signed-off-by: thadumi <th.theodor.th@gmail.com>
- Loading branch information
Showing
2 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
...d_methods_using_interceptor_bindings/binding_an_interceptor_to_a_component.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
//// | ||
******************************************************************* | ||
* Copyright (c) 2019 Eclipse Foundation | ||
* | ||
* This specification document is made available under the terms | ||
* of the Eclipse Foundation Specification License v1.0, which is | ||
* available at https://www.eclipse.org/legal/efsl.php. | ||
******************************************************************* | ||
//// | ||
|
||
[[binding_an_interceptor_to_a_component]] | ||
== Binding an Interceptor to a Component | ||
|
||
An interceptor may be bound to a component by | ||
annotating the component class or a method or constructor of the | ||
component class with the interceptor binding type. | ||
|
||
In the following example, the | ||
MonitoringInterceptor is applied to the target class. It will therefore | ||
apply to all business methods of the class. | ||
|
||
@Monitored | ||
|
||
public class ShoppingCart \{ ... } | ||
|
||
|
||
|
||
In this example, the MonitoringInterceptor is | ||
applied to a single method: | ||
|
||
public class ShoppingCart \{ | ||
|
||
|
||
|
||
@Monitored | ||
|
||
public void placeOrder() \{ ... } | ||
|
||
|
||
|
||
} | ||
|
||
A component class or a method or constructor | ||
of a component class may declare multiple interceptor bindings. | ||
|
||
The set of interceptor bindings for a method | ||
or constructor are those applied to the target class combined with those | ||
applied at method level or constructor level. Note that the interceptor | ||
bindings applied to the target class may include those inherited from | ||
its superclasses. The CDI specification rules for the inheritance of | ||
type-level metadata apply to the inheritance of interceptor bindings | ||
from superclasses of the target class. See | ||
link:intercept.html#a543[See | ||
Jakarta Contexts and Dependency Injection (CDI specification), version 3.0. | ||
https://jakarta.ee/specifications/cdi/3.0/.]. | ||
|
||
An interceptor binding declared on a method | ||
or constructor replaces an interceptor binding of the same type declared | ||
at class level or inherited from a superclasslink:#a572[7]. | ||
|
||
An extension specification may define | ||
additional rules for combining interceptor bindings, such as | ||
interceptors defined via a CDI stereotype. | ||
|
||
If a component class declares or inherits a | ||
class-level interceptor binding, it must not be declared final, or have | ||
any non-static, non-private, final methods. If a component has a | ||
class-level interceptor binding and is declared final or has a | ||
non-static, non-private, final method, the container automatically | ||
detects the problem and treats it as a definition error, and causes | ||
deployment to fail. | ||
|
||
If a non-static, non-private method of a | ||
component class declares a method-level interceptor binding, neither the | ||
method nor the component class may be declared final. If a non-static, | ||
non-private, final method of a component has a method-level interceptor | ||
binding, the container automatically detects the problem and treats it | ||
as a definition error, and causes deployment to fail. |