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


##########
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}.

Review Comment:
   Why can’t this be transparently handled whenever RSS is created?



##########
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:
   From a consumer perspective a `close()` method on RSS would be a lot easier 
and in addition allows to use
   - try with resources
   - semantic code analysis tools to emit a WARN when someone forgot to call 
close.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to