users@javaee-spec.java.net

[javaee-spec users] [jsr342-experts] Fwd: [interceptors-spec users] AroundConstruct interceptor

From: Linda DeMichiel <linda.demichiel_at_oracle.com>
Date: Wed, 06 Feb 2013 14:30:57 -0800

The message below outlines the proposal for AroundConstruct interceptor
support, for inclusion in the Interceptors spec Maintenance Release.

You can post any feedback here or on the http://java.net/projects/interceptors-spec/
project.

thanks,

-Linda


-------- Original Message --------
Subject: [interceptors-spec users] AroundConstruct interceptor
Date: Tue, 05 Feb 2013 10:41:01 -0800
From: Marina Vatkina <marina.vatkina_at_oracle.com>
Reply-To: marina.vatkina_at_oracle.com
To: jsr345-experts_at_ejb-spec.java.net, users_at_interceptors-spec.java.net, Pete Muir <pmuir_at_redhat.com>,
Emmanuel Bernard <emmanuel_at_hibernate.org>

This is the extended description of the proposal:

1. AroundConsruct interceptor

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

The AroundConstruct interceptor methods may be only defined on
interceptor classes and/or superclasses of interceptor classes.

When the AroundConstruct lifecycle callback, if any, is invoked the
following rules apply:
     * The AroundConstruct lifecycle callback is invoked after the
dependency injection has been completed on the interceptor instance.
Injection of the target component into interceptor instances that are
invoked during the AroundConstruct lifecycle callback, is not supported.
     * The target instance is created and its constructor injection is
performed, if any, when the last interceptor method in the
AroundConstruct interceptor chain invokes the InvocationContext.proceed
method.
     * The AroundConstruct interceptor method can access the constructed
instance using InvocationContext.getTarget method after the
InvocationContext.proceed completes.
     * An AroundConstruct lifecycle callback interceptor method should
not invoke any business methods of the target instance.
     * The dependency injection on the target instance is not completed
until after invocation of all interceptor methods in the AroundConstruct
interceptor chain complete successfully.
     * The PostConstruct lifecycle callback, if any, is invoked after
the dependency injection has been completed on the target instance.

If the AroundConstruct lifecycle callback is not associated with the
target instance, all interceptor methods, including PostConstruct
callbacks, if any, are invoked after dependency injection has been
completed on both, the interceptor instances and the target instance.


2. Extending InvocationContext interface

a) The InvocationContext interface will be extended with the
getConstructor method:

     public Constructor getConstructor();

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.


b) The getTarget method description will be modified as follows:

The getTarget method returns the associated target instance; for the
AroundConstruct lifecycle callback interceptor method, getTarget returns
null if called before proceed method returns.

c) No changes are required for the getMethod and getTimer methods of the
InvocationContext as they are already required to return null for
lifecycle callback interceptor methods

Best,
-marina