-
Notifications
You must be signed in to change notification settings - Fork 332
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
Download observing instead of intercepting #255
Conversation
|| Download.class.isAssignableFrom(type) || type == byte[].class; | ||
} | ||
|
||
public void download(@Observes MethodExecuted event) { |
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.
this observer class is always called, on each request?
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.
method is called each request, but logic is only executed if isDownloadType
returns true, just like interceptors with accepts method (but a little faster now).
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.
Thanks a lot. I think that with observers we will only "intercept" if download are needed. But the logic is the same that interceptors. 🍡
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.
I did a simple test firing event only if download are needed, but in 10k requests it
increases like 20ms (nothing), so has not justified creation of an event just for it =)
|
||
public void download(@Observes MethodExecuted event) { | ||
|
||
if (isDownloadType(event.getControllerMethod().getMethod().getReturnType())) { |
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.
I'd use something like:
Download download = resolveDownload(result);
if (download != null) {
//....
}
So isDownloadType
is not needed.
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.
nice, done in 3d05702
Upload observing instead of intercepting
…pting Download observing instead of intercepting
#247 - Sending just for code review... do not merge yet! :)