-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added interceptor_methods_for_lifecycle_event_callbacks
Fixed interception_environment's level Signed-off-by: thadumi <th.theodor.th@gmail.com>
- Loading branch information
Showing
4 changed files
with
157 additions
and
5 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
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
150 changes: 150 additions & 0 deletions
150
...ifecycle_event_callbacks/interceptor_methods_for_lifecycle_event_callbacks.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,150 @@ | ||
//// | ||
******************************************************************* | ||
* 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. | ||
******************************************************************* | ||
//// | ||
|
||
== Interceptor Methods for Lifecycle Event Callbacks | ||
|
||
image:intercept-4.png[image] | ||
|
||
The AroundConstruct annotation specifies a | ||
lifecycle callback interceptor method that interposes on the invocation | ||
of the target instance’s constructor. | ||
|
||
The PostConstruct annotation specifies a | ||
lifecycle callback interceptor method that is invoked after the target | ||
instance has been constructed and dependency injection on that instance | ||
has been completed, but before any business method or other event, such | ||
as a timer event, is invoked on the target instance. | ||
|
||
The PreDestroy annotation specifies a | ||
lifecycle callback interceptor method that interposes on the target | ||
instance’s removal by the container. | ||
|
||
Extension specifications are permitted to | ||
define additional lifecycle events and lifecycle callback interceptor | ||
methods types. | ||
|
||
Around-construct interceptor methods may be | ||
only declared in interceptor classes and/or superclasses of interceptor | ||
classes. Around-construct interceptor methods must not be declared in | ||
the target class or in its superclasses. | ||
|
||
All other lifecycle callback interceptor | ||
methods can be declared in an interceptor class, superclass of an | ||
interceptor class, in the target class, and/or in a superclass of the | ||
target class. | ||
|
||
A single lifecycle callback interceptor | ||
method may be used to interpose on multiple lifecycle callback events. | ||
|
||
A given class may not have more than one | ||
lifecycle callback interceptor method for the same lifecycle event. Any | ||
subset or combination of lifecycle callback annotations may otherwise be | ||
specified on methods declared in a given class. | ||
|
||
Lifecycle callback interceptor methods are | ||
invoked in an unspecified security context. Lifecycle callback | ||
interceptor methods are invoked in a transaction context determined by | ||
their target class and/or methodlink:#a571[5]. | ||
|
||
Lifecycle callback interceptor methods can | ||
have _public_ , _private_ , _protected_ , or _package_ level access. A | ||
lifecycle callback interceptor method must not be declared as abstract | ||
or _final_ . A lifecycle callback interceptor method must not be | ||
declared as _static_ except in an application client. | ||
|
||
Lifecycle callback interceptor methods | ||
declared in an interceptor class or superclass of an interceptor class | ||
must have one of the following signatures: | ||
|
||
void <METHOD>(InvocationContext) | ||
|
||
Object <METHOD>(InvocationContext) | ||
|
||
Note: A lifecycle callback interceptor method | ||
may be declared to throw checked exceptions including the | ||
java.lang.Exception if the same interceptor method interposes on | ||
business or timeout methods in addition to lifecycle events. If such an | ||
interceptor method returns a value, the value is ignored by the | ||
container when the method is invoked to interpose on a lifecycle event. | ||
|
||
Lifecycle callback interceptor methods | ||
declared in a target class or in a superclass of a target class must | ||
have the following signature: | ||
|
||
void <METHOD>() | ||
|
||
The following example declares lifecycle | ||
callback interceptor methods in both the interceptor class and the | ||
target class. Rules for interceptor ordering are described in | ||
link:intercept.html#a446[See Interceptor Ordering]. | ||
|
||
public class MyInterceptor \{ | ||
|
||
... | ||
|
||
@PostConstruct | ||
|
||
public void someMethod(InvocationContext | ||
ctx) \{ | ||
|
||
... | ||
|
||
ctx.proceed(); | ||
|
||
... | ||
|
||
} | ||
|
||
@PreDestroy | ||
|
||
public void | ||
someOtherMethod(InvocationContext ctx) \{ | ||
|
||
... | ||
|
||
ctx.proceed(); | ||
|
||
... | ||
|
||
} | ||
|
||
} | ||
|
||
|
||
|
||
@Interceptors(MyInterceptor.class) | ||
|
||
@Stateful | ||
|
||
public class ShoppingCartBean implements | ||
ShoppingCart \{ | ||
|
||
private float total; | ||
|
||
private Vector productCodes; | ||
|
||
... | ||
|
||
public int someShoppingMethod() \{ | ||
|
||
... | ||
|
||
} | ||
|
||
|
||
|
||
@PreDestroy void endShoppingCart() \{ | ||
|
||
... | ||
|
||
} | ||
|
||
} | ||
|
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