-
Notifications
You must be signed in to change notification settings - Fork 81
CDI-580 Allow interceptors and decorators to be applied to the return value of a producer #315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* | ||
* @return self | ||
*/ | ||
InterceptionProxyFactory<T> ignoreFinalMethods(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this will mean that you cannot call the final methods on the proxy (correct me if I am wrong). I think it is worth mentioning this at least in javadoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
* @return a new {@link InterceptionProxyFactory} to create proxies for an instance of T | ||
* @since 2.0 | ||
*/ | ||
<T> InterceptionProxyFactory<T> createInterceptionFactory(CreationalContext<T> ctx, Class<T> clazz); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If anyone can refresh my mind, I know we talked about built-in beans, but what was the reason behind a BM method? I would guess Extensions, is that right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To get it for custom bean create method
|
||
=== Apply interceptor and decorators programmatically | ||
|
||
Contextual instances of bean having interceptors binding or defined decorators are provided by the container as a proxy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The term proxy
is undefined from the spec point of view. The spec defines client proxy
but it's not related to interceptors and decorators. I believe the wording should follow section 7.2. Container invocations and interception
and use terms like contextual reference
and business method invocation
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I'll try to rework with this vocabulary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a second thought if we go in that direction (no mention of proxy) we should perhaps find another name for InterceptionProxyFactory
interface, something like ContextualReferenceFactory
or InterceptedInstanceFactory
?
wdyt @mkouba ?
|
||
An `InterceptionProxyFactory` can be obtain be calling `BeanManager.createInterceptionFactory` as defined in <<bm_obtain_interception_proxy_factory>> | ||
|
||
The container must also provide an instance of `InterceptionProxyFactory` for every producer methods injecting this interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is supposed to be about the built in beans, it sounds rather confusing. I suggest this instead:
The container must also provide an InterceptionProxyFactory built-in bean. Therefore, another way to use this interface is to inject the built-in bean directly as a parameter of a producer method.
Or something similar which will specifically mention the built in bean.
|
||
An `InterceptionProxyFactory` can be obtain be calling `BeanManager.createInterceptionFactory` as defined in <<bm_obtain_interception_proxy_factory>> | ||
|
||
The container must also provide an instance of `InterceptionProxyFactory` for every producer methods injecting this interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must provide a built-in bean with bean type javax.enterprise.inject.spi.InterceptionProxyFactory
, qualifier @Default
and "injectable only in a producer method parameter" (needs rewording).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok.
An `InterceptionProxyFactory` can be obtain be calling `BeanManager.createInterceptionFactory` as defined in <<bm_obtain_interception_proxy_factory>> | ||
|
||
The container must also provide an instance of `InterceptionProxyFactory` for every producer methods injecting this interface. | ||
This allow creation of produced instances having interceptors and decorators applied to them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this sounds somewhat clumsy, how about:
Either approach will allow to apply interceptors and decorators to beans created via producers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
b16232c
to
3435b22
Compare
This new version remove the term proxy from Javadoc and doc to mention enhancement of instance by making method invocation business method invocation as defined in section 7.2.
Other suggestion are welcome. |
80f2a26
to
87ed559
Compare
… value of a producer method Also works for custom beans create()
…d to the return value of a producer method Adding clarification on ingnoreFinalMethods javadoc Add reference to InterceptionProxyFactory in Decorators and Interceptors chapters Add also reference to Producer interface and Javadoc
…d to the return value of a producer method remove reference to proxy in javadoc and spec doc.
… value of a producer method changed Interface name. removed mention of decorators add precsion regarding unproxyable bean types
I think we should specifically mention in the spec that this feature enables the interceptor with |
… value of a producer method chnage wording and add mention for @AroundInvoke
Martin and Matej Feedback
* `configure()` returns an `AnnotatedTypeConfigurator` (as defined in <<annotated_type_configurator>>) initialized with the instance type to easily apply specific interceptor binding to apply when enhancing the instance. | ||
The method always return the same `AnnotatedTypeConfigurator` | ||
* `createInterceptedInstance()` returns an enhanced version of the instance for which each method invocations will be a business method invocation. | ||
The method can be only called once, subsequent calls will throw an exception. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't have enough time to go through this PR. This sentence is too general.
CDI-580 Allow interceptors and decorators to be applied to the return value of a producer method
Also works for custom beans create()