users@interceptors-spec.java.net

[interceptors-spec users] Proposed changes for the AroundConstruct interceptor

From: Marina Vatkina <marina.vatkina_at_oracle.com>
Date: Sun, 03 Feb 2013 20:05:16 -0800

To allow Java EE containers implement BV constructor validation using an
interceptor with a special priority, the Interceptors specification
needs to be extended with a new lifecycle interceptor type:
AroundConstruct - see http://java.net/jira/browse/INTERCEPTORS_SPEC-3.

The following changes are proposed to the recently published draft:

1. I section "2.2Interceptor Life Cycle"

Replace: "Interceptor methods, including PostConstruct callbacks, if
any, are invoked only after dependency injection has been completed on
both, the interceptor instances and the target instance."

With: "The AroundConstruct lifecycle callback, if any, is invoked after
the dependency injection has been completed on the interceptor instance.
All other interceptor methods, including PostConstruct callbacks, if
any, are invoked only after dependency injection has been completed on
both, the interceptor instances and the target instance."

2. In section "2.6Interceptors for Lifecycle Event Callbacks"

a) Replace:
"Interceptor methods that interpose on the target instance lifecycle
event callbacks can be defined on an interceptor class and/or directly
on the target class.

The PostConstruct and PreDestroy annotations are used to define an
interceptor method for the lifecycle callback events associated with the
target instance construction and removal."

With:
"The AroundConstruct annotation denotes lifecycle callback interceptor
methods that interpose on invocation of the target instance constructor.

The PostConstruct annotation denotes lifecycle callback interceptor
methods that are 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 can be invoked on the target instance.

The PreDestroy annotation denotes lifecycle callback interceptor methods
that interpose on with the target instance removal.

The AroundConstruct interceptor methods may be only defined on
interceptor classes. All other interceptor methods that interpose on
the target instance lifecycle event callbacks can be defined on an
interceptor class and/or directly on the target class.

b) Replace:
"Lifecycle callback interceptor methods may be defined on superclasses
of the target class or interceptor classes."

With:
"AroundConstruct lifecycle callback interceptor methods may be defined
on superclasses of interceptor classes. All other lifecycle callback
interceptor methods may be defined on superclasses of the target class
or interceptor classes."

3. In section "2.3InvocationContext"

a) Extend InvocationContext with

public Constructor getConstructor();

Note: the getMethod and getTimer methods of the InvocationContext
already required to return null for lifecycle callback interceptor
methods, so no change is required for the AroundConstruct support.

b) Add the following:
"The getConstructor method returns the constructor of the target class
for which the AroundConstruct interceptor was invoked. For
around-invoke, around-timeout and all other lifecycle callback
interceptor methods, getConstructor returns null."


c) Replace:
"For lifecycle callback interceptor methods, if there is no callback
method defined on the target class, the invocation of proceed in the
last interceptor method in the chain is a no-op[2], and null is returned"

With:
"For the AroundConstruct lifecycle callback interceptor method the
invocation of proceed in the last interceptor method in the chain causes
the target instance to be created and dependency injection on that
instance to be completed. For all other lifecycle callback interceptor
methods, if there is no callback method defined on the target class, the
invocation of proceed in the last interceptor method in the chain is a
no-op[2], and null is returned"




thanks,
-marina