Skip to content

Commit

Permalink
Updates for Cerials, Websockets, and Queues
Browse files Browse the repository at this point in the history
  • Loading branch information
GedMarc committed Jun 29, 2024
1 parent daef326 commit 7397967
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/main/java/com/guicedee/guicedinjection/GuiceContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ private GuiceContext()
//No config required
}



/**
* Reference the Injector Directly
*
Expand Down Expand Up @@ -142,19 +140,16 @@ public Injector inject()
log.config("Modules - " + Arrays.toString(cModules.toArray()));
GuiceContext.instance().injector = Guice.createInjector(cModules);
GuiceContext.buildingInjector = false;
GuiceContext
.instance()
.loadPostStartups();

startup.complete(true);
GuiceContext.instance().loadPostStartups();
GuiceContext.instance().loadPreDestroyServices();
Runtime
.getRuntime()
.addShutdownHook(new Thread()
{
public void run()
{
IGuiceContext
.getContext()
.destroy();
GuiceContext.instance().destroy();
}
});
LocalDateTime end = LocalDateTime.now();
Expand All @@ -170,10 +165,6 @@ public void run()
return GuiceContext.instance().injector;
}

private static Set<IGuicePreDestroy> destroyers = GuiceContext
.instance()
.getLoader(IGuicePreDestroy.class, false, ServiceLoader.load(IGuicePreDestroy.class));

/**
* Execute on Destroy
*/
Expand All @@ -182,7 +173,7 @@ public void destroy()
{
try
{
for (IGuicePreDestroy destroyer : destroyers)
for (IGuicePreDestroy destroyer : loadPreDestroyServices())
{
try
{
Expand Down Expand Up @@ -882,6 +873,17 @@ public Set<IGuicePreStartup> loadPreStartupServices()
return new TreeSet<>(getLoader(IGuicePreStartup.class, true, ServiceLoader.load(IGuicePreStartup.class)));
}


/**
* Returns the set of service lists of pre startup's for manual additions
*
* @return The list of guice post startups
*/
public Set<IGuicePreDestroy> loadPreDestroyServices()
{
return new TreeSet<>(getLoader(IGuicePreDestroy.class, true, ServiceLoader.load(IGuicePreDestroy.class)));
}

/**
* Loads the service lists of post startup's for manual additions
*
Expand Down

0 comments on commit 7397967

Please sign in to comment.