use of de.fraunhofer.iosb.ilt.faaast.service.config.Config in project FAAAST-Service by FraunhoferIOSB.
the class Application method run.
@Override
public void run() {
try {
ConfigFactory configFactory = new ConfigFactory();
AASEnvironmentFactory environmentFactory = new AASEnvironmentFactory();
readConfigurationParametersOverEnvironmentVariables();
readFilePathsOverEnvironmentVariables();
List<Config> customConfigComponents = getCustomConfigComponents();
ServiceConfig config = configFactory.toServiceConfig(configFilePath, autoCompleteConfiguration, properties, customConfigComponents);
AssetAdministrationShellEnvironment environment = null;
if (useEmptyAASEnvironment) {
LOGGER.info("Using empty Asset Administration Shell Environment");
environment = environmentFactory.getEmptyAASEnvironment();
} else {
environment = environmentFactory.getAASEnvironment(aasEnvironmentFilePath);
LOGGER.info("Successfully parsed Asset Administration Shell Environment");
}
if (validateAASEnv) {
validate(environment);
}
service = new Service(config);
service.setAASEnvironment(environment);
service.start();
LOGGER.info("FAAAST Service is running!");
} catch (Exception ex) {
if (service != null) {
service.stop();
}
LOGGER.error(ex.getMessage());
LOGGER.error("Abort starting FAAAST Service");
}
}
use of de.fraunhofer.iosb.ilt.faaast.service.config.Config in project FAAAST-Service by FraunhoferIOSB.
the class ConfigFactory method applyToServiceConfig.
private void applyToServiceConfig(ServiceConfig serviceConfig, List<Config> configs) throws Exception {
boolean isEndpointAlreadySet = false;
for (Config c : configs) {
LOGGER.debug("Apply custom config parameter '" + c.getClass().getSimpleName() + "'");
if (EndpointConfig.class.isAssignableFrom(c.getClass())) {
// if yet no endpoint was set remove old enpoints (most likely default endpoint) and set new endpoint
// else add the new endpoint to the existing list of endpoints
serviceConfig.setEndpoints(!isEndpointAlreadySet ? new ArrayList<>() {
{
add((EndpointConfig) c);
}
} : new ArrayList<>() {
{
addAll(serviceConfig.getEndpoints());
add((EndpointConfig) c);
}
});
isEndpointAlreadySet = true;
continue;
}
if (PersistenceConfig.class.isAssignableFrom(c.getClass())) {
serviceConfig.setPersistence((PersistenceConfig) c);
continue;
}
if (MessageBusConfig.class.isAssignableFrom(c.getClass())) {
serviceConfig.setMessageBus((MessageBusConfig) c);
continue;
}
if (AssetConnectionConfig.class.isAssignableFrom(c.getClass())) {
serviceConfig.getAssetConnections().add((AssetConnectionConfig) c);
continue;
}
throw new Exception("Cannot set config component '" + c.getClass().getSimpleName() + "'");
}
}
Aggregations