use of org.apache.hop.core.config.HopConfig in project hop by apache.
the class HopEnvironment method init.
public static void init(List<IPluginType> pluginTypes) throws HopException {
SettableFuture<Boolean> ready;
if (initialized.compareAndSet(null, ready = SettableFuture.create())) {
// Swaps out System Properties for a thread safe version.
// This is not that important since we're no longer using System properties
// However, plugins might still make use of it so keep it around
//
System.setProperties(ConcurrentMapProperties.convertProperties(System.getProperties()));
try {
//
if (!HopClientEnvironment.isInitialized()) {
HopClientEnvironment.init();
}
// Register the native types and the plugins for the various plugin types...
//
pluginTypes.forEach(PluginRegistry::addPluginType);
PluginRegistry.init();
// Also read the list of variables.
//
HopVariablesList.init();
// If the HopConfig system properties is empty, initialize with the variables...
//
HopConfig hopConfig = HopConfig.getInstance();
List<DescribedVariable> configVariables = hopConfig.getDescribedVariables();
if (configVariables.isEmpty()) {
List<DescribedVariable> describedVariables = HopVariablesList.getInstance().getEnvironmentVariables();
for (DescribedVariable describedVariable : describedVariables) {
hopConfig.setDescribedVariable(new DescribedVariable(describedVariable));
}
}
//
for (DescribedVariable describedVariable : hopConfig.getDescribedVariables()) {
if (StringUtils.isNotEmpty(describedVariable.getName())) {
System.setProperty(describedVariable.getName(), Const.NVL(describedVariable.getValue(), ""));
}
}
// Inform the outside world that we're ready with the init of the Hop Environment
// Others might want to register extra plugins that perhaps were not found automatically
//
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, null, HopExtensionPoint.HopEnvironmentAfterInit.name(), PluginRegistry.getInstance());
ready.set(true);
} catch (Throwable t) {
ready.setException(t);
// If it's a HopException, throw it, otherwise wrap it in a HopException
throw ((t instanceof HopException) ? (HopException) t : new HopException(t));
}
} else {
// A different thread is initializing
ready = initialized.get();
// Block until environment is initialized
try {
ready.get();
} catch (Throwable t) {
throw new HopException(t);
}
}
}
Aggregations