-
Notifications
You must be signed in to change notification settings - Fork 333
Make ResolverFactory + ResolutionManifestFactory request-scoped #2540
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
dimas-b
left a comment
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.
LGTM 👍
9b3c687 to
1abd4a4
Compare
dimas-b
left a comment
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 agree that leveraging CDI for request-scope object injection is preferable to manually passing context object as method arguments.
Thanks for you work on this @XN137 !
HonahX
left a comment
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 for looking into these refactoring! I have some concerns that would appreciate your thoughts and feedback.
IMHO, a "factory" makes more sense to be an ApplicationScoped bean, that once initialized, other methods/threads could use it to generate the real instance.
Making factories request-scoped seem to indicate that we do not need actually need these factories, and we can directly have request-scoped Resolver and ResolutionManfiest bean. Otherwise we are generating an additional dispensible factory object for every request.
I think in general the factory design could allow us to add potential customization in the future and maybe some of them could be cached at realm-level instead of every request.
I completely understand the motivation to leverage CDI injection as much as possible. I’m just wondering if there are additional benefits to this approach that would make the refactoring worthwhile?
|
Good points, @HonahX ! From my POV, I tend to view this PR as an incremental step towards that goal :) That said, I guess it might be preferable to continue this kind of design discussion on the |
|
Thanks @dimas-b for the explanation! +1 for a dev list discussion for this.
I think this will be a good point to discuss. CDI producer could help simplify the code within the polaris, however I barely remembered that there was some discussion on making |
1abd4a4 to
f86f02d
Compare
|
rebased after trivial conflict in |
|
sorry i was OOO for a week. thank you for the feedback everyone!
i dont think there is a strict requirement to have factories be application scoped. for example on generally
i would disagree with this because as shown in this PR both so while the factory currently is application-scoped it cant be used outside of a request-scope and this means all callers must pass all the required parameters around all the time, which this PR tries to avoid/clean up.
correct me if i am wrong but i think even with making the factories request-scope (which matches their usage in the codebase) the implementation of that factory is still free to implement the object creation however it wants. |
not sure this is possible as explained in how |
f86f02d to
5d2c56d
Compare
|
rebased again after trivial conflict in |
5d2c56d to
703426c
Compare
dimas-b
left a comment
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 refactoring LGTM and I think it is aligned with our code "evolution" approach, so I think it can be merged without further dev ML discussions.
@HonahX : WDYT?
This, of course, does not preclude dev list discussions about API changes and how to deal with CDI beans and factories in general. I merely mean that this particular change looks reasonable to merge from my POV 🙂
703426c to
d143b73
Compare
|
rebased again after trivial conflict in |
this avoids passing around the `CallContext` parameter note that ideally the `SecurityContext` would also be injected from the request however our tests around `PolarisAuthzTestBase` are written in a way that does not easily support this currently.
d143b73 to
45261df
Compare
|
@HonahX : Do you think we could merge this? |
| @RequestScoped | ||
| public ResolutionManifestFactory resolutionManifestFactory( | ||
| PolarisDiagnostics diagnostics, RealmContext realmContext, ResolverFactory resolverFactory) { | ||
| return new ResolutionManifestFactoryImpl(diagnostics, realmContext, resolverFactory); |
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.
Just a small nit: why do you need this bean to be produced by a producer method? Wouldn't it be enough to annotate ResolutionManifestFactoryImpl with @RequestScoped?
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.
it's probably not strictly needed, this just keeps the same style the previous code used.
we can also do it the other way if you prefer.
i'd suggest to do it a followup if its ok with you?
|
Given some approvals I assume lazy consensus from people who comment before but did not formally approve... merging. Open to follow-up (if required). |
this avoids passing around the
CallContextparameternote that ideally the
SecurityContextwould also be injected from the request however our tests aroundPolarisAuthzTestBaseare written in a way that does not easily support this currently.