Skip to content

Commit

Permalink
[MRESOLVER-278] On session close reworked
Browse files Browse the repository at this point in the history
Key changes:
* It is not session to register handlers against, but RepositorySystem
* DefaultRepositorySystemSession class deprecated, but will work as intended with a
  slight semantic change (it's handlers are executed on repo system shutdown)
* introduced MutableRepositorySystemSession and used instead, session creation
  should be done using RepositorySystem and handle it as a resource
* locking: partially undo PR #196, but do not use System properties but
  container injecter parameters instead (works with SISU only!)
  • Loading branch information
cstamas committed Oct 27, 2022
1 parent 2b85869 commit 71ca943
Show file tree
Hide file tree
Showing 25 changed files with 2,105 additions and 267 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand All @@ -20,7 +20,6 @@
*/

import java.util.Map;
import java.util.function.Consumer;

import org.eclipse.aether.artifact.ArtifactTypeRegistry;
import org.eclipse.aether.collection.DependencyGraphTransformer;
Expand All @@ -44,7 +43,7 @@
* create a subclass and implement {@link #getSession()}.
*/
public abstract class AbstractForwardingRepositorySystemSession
implements RepositorySystemSession
implements RepositorySystemSession
{

/**
Expand All @@ -58,7 +57,7 @@ protected AbstractForwardingRepositorySystemSession()
* Gets the repository system session to which this instance forwards calls. It's worth noting that this class does
* not save/cache the returned reference but queries this method before each forwarding. Hence, the session
* forwarded to may change over time or depending on the context (e.g. calling thread).
*
*
* @return The repository system session to forward calls to, never {@code null}.
*/
protected abstract RepositorySystemSession getSession();
Expand Down Expand Up @@ -212,34 +211,29 @@ public RepositoryCache getCache()
{
return getSession().getCache();
}

@Override
public FileTransformerManager getFileTransformerManager()
{
return getSession().getFileTransformerManager();
}

@Override
public final void addOnCloseHandler( Consumer<RepositorySystemSession> handler )
{
getSession().addOnCloseHandler( handler );
}

@Override
public final boolean isClosed()
{
return getSession().isClosed();
}

/**
* This method is special: by default it throws (nested session should never be closed), the "top level" session
* should be closed instead. Still, this method is NOT {@code final}, to allow implementations overriding it,
* and in case when needed, handle forwarded session as "top level" session.
* This method is special: by default it does nothing, to allow proper resource-like handling of this session,
* and assumes that forwarded session will be closed on some higher level.
* <p>
* Still, this method is NOT {@code final}, allowing implementations to override it, in case when needed, handle
* forwarded session as "top level" session.
*/
@Override
public void close()
{
throw new IllegalStateException( "Forwarding session should not be closed, "
+ "close the top-level (forwarded) session instead." );
// nothing
}
}
Loading

0 comments on commit 71ca943

Please sign in to comment.