Skip to content

Commit

Permalink
Added interceptor_methods_for_lifecycle_event_callbacks
Browse files Browse the repository at this point in the history
Fixed interception_environment's level

Signed-off-by: thadumi <th.theodor.th@gmail.com>
  • Loading branch information
thadumi committed Mar 22, 2020
1 parent 94ad89b commit fda4487
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
////

[[interceptor_environment]]
== Interceptor Environment
=== Interceptor Environment

An interceptor class shares the enterprise
naming context of its associated target class. Annotations and/or XML
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ interceptor chain complete successfully. Around-construct lifecycle
callback interceptor methods should therefore exercise caution when
invoking methods of the target instance since dependency injection on
the target instance will not have been completed.

include::interceptor_environment.adoc[]
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() \{

...

}

}

Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ include::terminology.adoc[]

include::definition_of_interceptor_classes_and_interceptor_methods.adoc[]

include::interceptor_life_cycle.adoc[]

include::interceptor_environment.adoc[]
include::interceptor_life_cycle/interceptor_life_cycle.adoc[]

include::invocation_context.adoc[]

include::exceptions.adoc[]

include::business_method_interceptor_methods.adoc[+]
include::business_method_interceptor_methods.adoc[]

include::interceptor_methods_for_lifecycle_event_callbacks/interceptor_methods_for_lifecycle_event_callbacks.adoc[]

0 comments on commit fda4487

Please sign in to comment.