Skip to content

Commit

Permalink
Cleanup rest service dependencies for Vert.x
Browse files Browse the repository at this point in the history
  • Loading branch information
GedMarc committed Apr 14, 2024
1 parent 4b3d284 commit 1df4e18
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/main/java/com/guicedee/guicedinjection/GuiceContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import java.util.regex.Pattern;

import static com.guicedee.guicedinjection.properties.GlobalProperties.getSystemPropertyOrEnvironment;
import static java.util.stream.Collectors.groupingBy;
import static java.util.stream.Collectors.toSet;

/**
* Provides an interface for reflection and injection in one.
Expand Down Expand Up @@ -772,20 +774,22 @@ public static void setScanner(ClassGraph scanner)
private void loadPostStartups()
{
Set<IGuicePostStartup> startupSet = loadPostStartupServices();
Map<Integer, Set<IGuicePostStartup>> groupedPostStartup = startupSet.stream()
.collect(groupingBy(IGuicePostStartup::sortOrder, toSet()));
/* Map<Integer, Set<IGuicePostStartup<?>>> postStartupGroups = new TreeMap<>();
Map<Integer, Set<IGuicePostStartup<?>>> postStartupGroups = new TreeMap<>();
for (IGuicePostStartup<?> postStartup : startupSet)
{
Integer sortOrder = postStartup.sortOrder();
postStartupGroups
.computeIfAbsent(sortOrder, k -> new TreeSet<>())
.add(postStartup);
}

for (Map.Entry<Integer, Set<IGuicePostStartup<?>>> entry : postStartupGroups.entrySet())
*/
for (Map.Entry<Integer, Set<IGuicePostStartup>> entry : groupedPostStartup.entrySet())
{
Integer key = entry.getKey();
Set<IGuicePostStartup<?>> value = entry.getValue();
Set<IGuicePostStartup> value = entry.getValue();
if (value.size() == 1)
{
//run in order
Expand Down Expand Up @@ -843,7 +847,7 @@ public GuiceConfig<?> getConfig()
*/
public Set<IGuicePostStartup> loadPostStartupServices()
{
return getLoader(IGuicePostStartup.class, ServiceLoader.load(IGuicePostStartup.class));
return new TreeSet<>(getLoader(IGuicePostStartup.class, ServiceLoader.load(IGuicePostStartup.class)));
}

/**
Expand Down Expand Up @@ -886,7 +890,7 @@ public Set<IGuiceScanJarInclusions> loadJarInclusionScanners()
*/
public Set<IGuicePreStartup> loadPreStartupServices()
{
return getLoader(IGuicePreStartup.class, true, ServiceLoader.load(IGuicePreStartup.class));
return new TreeSet<>(getLoader(IGuicePreStartup.class, true, ServiceLoader.load(IGuicePreStartup.class)));
}

/**
Expand All @@ -896,7 +900,7 @@ public Set<IGuicePreStartup> loadPreStartupServices()
*/
public Set<IGuiceModule> loadIGuiceModules()
{
return getLoader(IGuiceModule.class, true, ServiceLoader.load(IGuiceModule.class));
return new TreeSet<>(getLoader(IGuiceModule.class, true, ServiceLoader.load(IGuiceModule.class)));
}

/**
Expand All @@ -915,9 +919,7 @@ public Set<IGuiceConfigurator> loadIGuiceConfigs()
private void loadPreStartups()
{
Set<IGuicePreStartup> preStartups = loadPreStartupServices();
List<IGuicePreStartup> startups = new ArrayList<>(preStartups);
startups.sort(Comparator.comparing(IGuicePreStartup::sortOrder));
for (IGuicePreStartup startup : startups)
for (IGuicePreStartup startup : preStartups)
{
GuiceContext.log.config("Loading IGuicePreStartup - " + startup
.getClass()
Expand Down

0 comments on commit 1df4e18

Please sign in to comment.