-
Notifications
You must be signed in to change notification settings - Fork 146
[MRESOLVER-302] Introduce onSessionClose hooks #232
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -302,4 +302,39 @@ List<RemoteRepository> newResolutionRepositories( RepositorySystemSession sessio | |
| * @since 1.9.0 | ||
| */ | ||
| void shutdown(); | ||
|
|
||
| /** | ||
| * Registers the session for lifecycle tracking: it marks that the passed in session instance is about to start. | ||
| * After this call it is possible to register "on close" handlers using | ||
| * {@link #addOnSessionEndedHandle(RepositorySystemSession, Runnable)} method that will execute once | ||
| * {@link #sessionEnded(RepositorySystemSession)} method was invoked. | ||
| * <p> | ||
| * <em>Same session instance can be started only once.</em> | ||
| * | ||
| * @param session the session that is about to start, never {@code null}. | ||
| * @since TBD | ||
| */ | ||
| void sessionStarted( RepositorySystemSession session ); | ||
|
|
||
| /** | ||
| * Registers a handler to execute when this session ends. This method throws, if the passed in session instance | ||
| * was not passed to method {@link #sessionStarted(RepositorySystemSession)} beforehand. | ||
| * | ||
| * @param session the session for which the handler needs to be registered, never {@code null}. | ||
| * @param handler the handler, never {@code null}. | ||
| * @since TBD | ||
| */ | ||
| void addOnSessionEndedHandle( RepositorySystemSession session, Runnable handler ); | ||
|
|
||
| /** | ||
| * Signals to repository system that passed in session ended, it will not be used anymore. Repository system | ||
| * will invoke the registered handlers for this session, if any. This method throws if the passed in session | ||
| * instance was not passed to method {@link #sessionStarted(RepositorySystemSession)} beforehand. | ||
| * <p> | ||
| * <em>Same session instance can be ended only once.</em> | ||
| * | ||
| * @param session the session that just ended, never {@code null}. | ||
| * @since TBD | ||
| */ | ||
| void sessionEnded( RepositorySystemSession session ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. From a consumer perspective a
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the least painful way with 1.x. Problem is how session instances are created (by client code, using def ctor of DefaultRepositorySystemSession, no factory for it) and derived. Just look thru Maven and plugin sources as example. They are not "boxed" nor are hierarchical, you can get session A and have it "derived" (using copy ctor) into session B and then continue to use it (typical when local repo is overridden in plugins), etc. And then i did not even mention "forwarding" session... So yes, ideally session would be:
But doing this would be very disruptive, so baby steps... leave these changes for 2.0
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Understood, but the same uncertainty is now applicable to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given all that I still think that a
Doing this should be fully backwards compatible and still expose an API which is much easier to digest. |
||
| } | ||
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.
Why can’t this be transparently handled whenever RSS is created?