-
Notifications
You must be signed in to change notification settings - Fork 45
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
Use CDI_FULL test group to exclude @Interceptors tests #262
Comments
Note that you might need to annotate more than just tests with |
I have found tests that are using the interceptors element of the beans.xml that I need to add. What is the issue with around invoke? What is the full set of features from the interceptors spec we are not supporting in lite? |
It is easier to define the other way around. What we do support is:
Everything else is CDI Full only. |
Why do we move interceptors to CDI Full? I recall interceptor support is required in CDI Lite. |
@Emily-Jiang we are not moving them all, please read the issue carefully - interceptors are supported in Lite but not in all forms. For instance |
ah, my apologies. I missed some context. For |
I don't think we have ever specified it in detail. Which we should, IMHO. So there's a couple of interceptor kinds:
Interceptors may be declared:
Interceptor classes can be associated with target classes using:
Interceptors may be enabled using:
Interceptors may be disabled using:
Did I miss anything? This seems to be a 5-dimensional matrix, so hard to convert to a 2D format :-) I'll try anyway. ✔️ means "part of CDI Lite"
I don't know what to think of |
Well, it seems @ExcludeDefaultInterceptors and @ExcludeClassInterceptors should be an X in terms of Lite since they are related to @interceptors. |
I don't see that stated for |
Had to look it up. We don't even seem to use Spec says the following about default interceptors:
|
@Ladicek to answer your question marks:
|
According to the spec, By the way, all of the |
Thanks @manovotn, I wasn't thinking, obviously I marked lifecycle callbacks on interceptor class as ✔️. The single remaining item is @Emily-Jiang I wish |
I personally find this feature a bit useless and TBH I've only seen a very few usages during the many years of CDI development. And while the conceptual clarity is a nice thing it will add unnecessary complexity to the implementation. If you need to "intercept" all/some methods of the target class it's probably better to use the regular language constructs instead of CDI interceptors, for example: import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
public class Foo {
String ping() {
return monitor(() -> "foo");
}
void log() {
monitor(() -> null);
}
<T> T monitor(Callable<T> action) {
long start = System.nanoTime();
try {
return action.call();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
System.out.println("Took: " + TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start));
}
}
} You'll definitely get better performance, type-safety and there's no need for reflection along the way. And if you really need a dedicated CDI interceptor then nested classes seem to be an easy solution: public class Foo {
@Monitored
String ping() {
return "foo";
}
@Monitored
void log() {
}
@Target({ TYPE, METHOD })
@Retention(RUNTIME)
@InterceptorBinding
pullic @interface Monitored {}
@Monitored
@Priority(1)
@Interceptor
public static Monitor {
@AroundInvoke
Object monitor(InvocationContext ctx) throws Exception {
// ...
}
}
} |
@Ladicek @starksm64 since the PR was merged, can we consider this issue resolved? Or is there anything else to do? |
I think we are good to close this. |
@manovotn @starksm64 @Ladicek what was the final decision on Are included with the |
@graemerocher you are right, this isn't supposed to be in Lite. I must have missed this one (and possibly others?), it was lots and lots of tests...
Which means this TCK test can be rewritten to use the standard interceptor with bindings. |
@manovotn thanks for the clarification. There seem to be several cases, like this one as well: |
Yeah, most of the reworks I did were focused around The one you mentioned will need to be marked Full and we'll need to make a similar version for Lite with only the supported bits (so that we don't coverage on this). |
Feel free to send PRs or, at the very least, please create new issue(s) for them so we keep track of all of them. |
Breaking up the sets of tests into separate categories, first @interceptors based tests need to added to the CDI_FULL test group.
The text was updated successfully, but these errors were encountered: