-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Improve ControlFlowPointcut
extensibility
#27187
Comments
I would be glad to receive some feedback after 3 months. I am not sure what there is to triage in this case. |
@kriegaex sorry for the time it took to come to this. As I am sure you are aware, Spring Framework is touching a lot of ground and the team is limited. I don't know why this particular request took a lot of time, but there hasn't been a lot of interest by the community either (votes, comments, etc).
|
@snicoll, I am not sure I understand what exactly you are suggesting. If you have seen my code, you know that it would be easy to add more power and flexibility to this pointcut type with almost trivial changes. If you think, that this makes things too complicated, I am failing to see why. But as maintainer of AspectJ, I can always welcome more Spring AOP users in need of better aspect functionality there, if you prefer. |
ControlFlowPointcut
extensibility
Hi @kriegaex,
Let's go with that option. Do you want to submit a PR? If not, we can make the necessary changes. Cheers, Sam |
@sbrannen, assuming that I provide PR A to make the fields protected, would you also accept PR B which adds a subclass extending the simple parent class with more powerful pattern matching functionality? It would be backwards compatible, leaving the original untouched, but also enable Spring AOP users to utilise a more powerful solution out of the box, not everyone having to implement it by themselves. I am assuming, that pattern matching is what most users are looking for, expecting something like it, because other pointcut designators also support it. What would it take for you to accept that into Spring Core? Or asking the other way around, what would be the problem in accepting it? The prospect to have one more class to maintain? To have to document it? Test coverage? Maybe we can address your concerns for the benefit of the Spring users community. Just to be clear here: I personally would not benefit from it. I am not even an active Spring user. I am a native AspectJ guy. I simply mean to help to improve Spring AOP, raising the threshold for users for having to switch to full-blown AspectJ just because they need a control flow pointcut with a pattern. |
Hi @kriegaex, @jhoeller and I took a closer look at our options and decided to focus this issue on the basic extensibility needs in In addition, we've created #31435 to provide a built-in mechanism for pattern matching which simultaneously allows for extension -- for example, to use regular expressions instead of I'll take care of both of these issues. In light of that, there's no need for a PR. Cheers, Sam |
For anyone interested, this is now quite easy to achieve, as can be seen in the Lines 263 to 276 in f0c6fab
I've also posted an answer on that Stack Overflow discussion to point this out. |
@sbrannen, LGTM. Thank you so much for addressing this issue. |
I am starting with an issue instead of a PR, because I want to find out if the maintainers are open to this suggestion and discuss how it best be done.
ControlFlowPointcut
does not support method name patterns liketest*
(AspectJ-like syntax) ortest.*
,test[1-3]
(regex syntax).While the class is extensible and sports two methods to be overridden for improved filtering and it would be possible to override
public boolean matches(Method, Class<?>)
orpublic boolean matches(Method, Class<?>, Object...)
in order to add the extra functionality, subclasses do not have access to fields likeprivate Class<?> clazz
,private String methodName
andprivate volatile int evaluations
. I.e., instead of extending existing functionality users would end up duplicating some things or even copying and extending the whole class like I did when answering StackOverflow #68431056 - please read and feel free to copy the source code.I see several options here:
ControlFlowPointcut
directly in order to allow for more flexible method name matching, similar to how I did it. Sub-options:Pattern
field and corresponding constructor, like I did, in order to retain exactString
matching mode for best performance.String
parameter as a regex.ControlFlowPointcut
extensibility by making the fields mentioned aboveprotected
instead ofprivate
.After we have come to a common understanding how this should best be done, the implementation as such should be pretty trivial. I can then create a PR, but the maintainers could also quickly do it by themselves, depending on their preference.
The text was updated successfully, but these errors were encountered: