Skip to content
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

Merged
merged 21 commits into from
Nov 14, 2013

Conversation

Turini
Copy link
Member

@Turini Turini commented Nov 12, 2013

#247 - Sending just for code review... do not merge yet! :)

@ghost ghost assigned Turini Nov 12, 2013
|| Download.class.isAssignableFrom(type) || type == byte[].class;
}

public void download(@Observes MethodExecuted event) {
Copy link
Member

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?

Copy link
Member Author

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).

Copy link
Member

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. 🍡

Copy link
Member Author

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())) {
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice, done in 3d05702

Turini added a commit that referenced this pull request Nov 14, 2013
…pting

Download observing instead of intercepting
@Turini Turini merged commit 01cda67 into master Nov 14, 2013
@Turini Turini deleted the DownloadObservingInsteadOfIntercepting branch November 14, 2013 11:15
@Turini Turini added this to the 4.0.0-beta-4 milestone Mar 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants