Skip to content

Commit

Permalink
Only update whitelist when Addon registry has changed
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnthree committed Feb 18, 2014
1 parent d319372 commit a6cece3
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions se/src/main/java/org/jboss/forge/furnace/se/FurnaceFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,25 @@ public static Furnace getInstance(final ClassLoader loader)
return (Furnace) ClassLoaderAdapterBuilder.callingLoader(FurnaceFactory.class.getClassLoader())
.delegateLoader(loader).whitelist(new Callable<Set<ClassLoader>>()
{
volatile long lastRegistryVersion = 0;
final Set<ClassLoader> result = new HashSet<>();

@Override
public Set<ClassLoader> call() throws Exception
{
Set<ClassLoader> result = new HashSet<>();

if (furnace.getStatus().isStarted())
if (result == null)
{
for (Addon addon : furnace.getAddonRegistry().getAddons())
if (furnace.getStatus().isStarted())
{
result.add(addon.getClassLoader());
long registryVersion = furnace.getAddonRegistry().getVersion();
if (registryVersion > lastRegistryVersion)
{
lastRegistryVersion = registryVersion;
for (Addon addon : furnace.getAddonRegistry().getAddons())
{
result.add(addon.getClassLoader());
}
}
}
}

Expand Down

0 comments on commit a6cece3

Please sign in to comment.