mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-13 16:15:16 +00:00
[configuration] ConfigurationKeysLoader now caches.
This commit is contained in:
1 parent
8a1e0d03ae
commit
e5dc6203c8
1 file changed
+7
@@ -23,18 +23,23 @@ package lombok.core.configuration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import lombok.ConfigurationKeys;
|
||||
import lombok.core.SpiLoadUtil;
|
||||
|
||||
public interface ConfigurationKeysLoader {
|
||||
public class LoaderLoader {
|
||||
private static final AtomicBoolean alreadyLoaded = new AtomicBoolean(false);
|
||||
private LoaderLoader() {}
|
||||
|
||||
public static void loadAllConfigurationKeys() {
|
||||
if (alreadyLoaded.get()) return;
|
||||
|
||||
try {
|
||||
Class.forName(ConfigurationKeys.class.getName());
|
||||
} catch (Throwable ignore) {}
|
||||
|
||||
try {
|
||||
Iterator<ConfigurationKeysLoader> iterator = SpiLoadUtil.findServices(ConfigurationKeysLoader.class, ConfigurationKeysLoader.class.getClassLoader()).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
@@ -44,6 +49,8 @@ public interface ConfigurationKeysLoader {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Can't load config keys; services file issue.", e);
|
||||
} finally {
|
||||
alreadyLoaded.set(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user