[ 
https://issues.apache.org/jira/browse/MRESOLVER-302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17653080#comment-17653080
 ] 

ASF GitHub Bot commented on MRESOLVER-302:
------------------------------------------

kwin commented on code in PR #232:
URL: https://github.com/apache/maven-resolver/pull/232#discussion_r1059306441


##########
maven-resolver-api/src/main/java/org/eclipse/aether/RepositorySystem.java:
##########
@@ -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>
+     * <en>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>
+     * <en>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 );

Review Comment:
   Understood, but the same uncertainty is now applicable to 
`sessionEnded(...)`. When should consumers call it? What about sessions created 
with 
https://maven.apache.org/resolver/apidocs/org/eclipse/aether/DefaultRepositorySystemSession.html#%3Cinit%3E(org.eclipse.aether.RepositorySystemSession)?
 What about forwarding sessions. The Javadocs need to be extended in this 
regard.





> Introduce onSession close
> -------------------------
>
>                 Key: MRESOLVER-302
>                 URL: https://issues.apache.org/jira/browse/MRESOLVER-302
>             Project: Maven Resolver
>          Issue Type: New Feature
>          Components: Resolver
>            Reporter: Tamas Cservenak
>            Assignee: Tamas Cservenak
>            Priority: Major
>             Fix For: 1.9.3
>
>
> The on session close callback, revisited.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to