use of org.iobserve.stages.general.ConfigurationException in project iobserve-analysis by research-iobserve.
the class AbstractServiceMain method run.
/**
* Configure and execute the evaluation tool.
*
* @param title
* start up label for debug messages
* @param label
* label used during execution
* @param args
* arguments are ignored
*/
public void run(final String title, final String label, final String[] args) {
AbstractServiceMain.LOGGER.debug(title);
final JCommander commander = new JCommander(this);
try {
commander.parse(args);
final kieker.common.configuration.Configuration configuration;
if (this.getConfigurationFile() != null) {
configuration = ConfigurationFactory.createConfigurationFromFile(this.getConfigurationFile().getAbsolutePath());
} else {
configuration = null;
}
this.execute(configuration, commander, label);
} catch (final ParameterException e) {
AbstractServiceMain.LOGGER.error(e.getLocalizedMessage());
commander.usage();
} catch (final ConfigurationException e) {
AbstractServiceMain.LOGGER.error(e.getLocalizedMessage());
commander.usage();
}
}
use of org.iobserve.stages.general.ConfigurationException in project iobserve-analysis by research-iobserve.
the class InstantiationFactory method createWithConfiguration.
/**
* This is a helper method trying to find, create and initialize the given class, using its
* public constructor which accepts a single {@link Configuration}.
*
* @param implementedInterface
* This class defines the expected result of the method call.
* @param className
* The name of the class to be created.
* @param configuration
* The configuration which will be used to initialize the class in question.
*
* @return A new and initializes class instance if everything went well.
*
* @param <C>
* The type of the returned class.
*/
public static <C> C createWithConfiguration(final Class<C> implementedInterface, final String className, final kieker.common.configuration.Configuration configuration) throws ConfigurationException {
try {
final Class<?> clazz = Class.forName(className);
if (implementedInterface.isAssignableFrom(clazz)) {
// Choose the appropriate configuration to pass.
final kieker.common.configuration.Configuration configurationToPass;
if (clazz.isAnnotationPresent(ReceiveUnfilteredConfiguration.class)) {
configurationToPass = configuration.flatten();
} else {
configurationToPass = configuration.getPropertiesStartingWith(className);
}
final Class<?>[] parameterTypes = { kieker.common.configuration.Configuration.class };
return InstantiationFactory.instantiateClass(implementedInterface, clazz, parameterTypes, configurationToPass);
} else {
InstantiationFactory.LOGGER.error("Class '{}' has to implement '{}'.", className, implementedInterface.getSimpleName());
throw new ConfigurationException("Requested class does not match interface.");
}
} catch (final ClassNotFoundException e) {
InstantiationFactory.LOGGER.error("{}: Class '{}' not found: {}", implementedInterface.getSimpleName(), className, e.getLocalizedMessage());
throw new ConfigurationException(e);
}
}
use of org.iobserve.stages.general.ConfigurationException in project iobserve-analysis by research-iobserve.
the class RacCreatorMain method checkParameters.
@Override
protected boolean checkParameters(final JCommander commander) throws ConfigurationException {
try {
if (!this.outputPath.isDirectory() || !this.outputPath.exists()) {
RacCreatorMain.LOGGER.error("Output path {} does not exist or is not a directory.", this.outputPath.getCanonicalPath());
commander.usage();
return false;
}
if (!this.inputPath.isDirectory() || !this.inputPath.exists()) {
RacCreatorMain.LOGGER.error("Input path {} does not exist or is not a directory.", this.inputPath.getCanonicalPath());
commander.usage();
return false;
}
if (!CommandLineParameterEvaluation.isFileReadable(this.mappingFile, "Mapping file")) {
commander.usage();
return false;
}
if (!CommandLineParameterEvaluation.isFileReadable(this.repositoryFile, "Repository file")) {
commander.usage();
return false;
}
return true;
} catch (final IOException e) {
throw new ConfigurationException(e);
}
}
use of org.iobserve.stages.general.ConfigurationException in project iobserve-analysis by research-iobserve.
the class RacCreatorMain method createConfiguration.
@Override
protected ObservationConfiguration createConfiguration(final Configuration configuration) throws ConfigurationException {
final Collection<File> inputPaths = new ArrayList<>();
inputPaths.add(this.inputPath);
final File mappedClassesFile = new File(this.outputPath.getAbsolutePath() + File.separator + RacCreatorMain.MAPPED_CLASSES_FILENAME);
final File unmappedClassesFile = new File(this.outputPath.getAbsolutePath() + File.separator + RacCreatorMain.UNMAPPED_CLASSES_FILENAME);
final File racFile = new File(this.outputPath.getAbsolutePath() + File.separator + RacCreatorMain.RAC_FILENAME);
final RepositoryFileReader repositoryFileReader = new RepositoryFileReader(this.repositoryFile);
final ModelMappingReader mappingFileReader = new ModelMappingReader(this.mappingFile);
try {
return new ObservationConfiguration(inputPaths, repositoryFileReader, mappingFileReader, mappedClassesFile, unmappedClassesFile, racFile);
} catch (ParserConfigurationException | SAXException | IOException e) {
throw new ConfigurationException(e);
}
}
use of org.iobserve.stages.general.ConfigurationException in project iobserve-analysis by research-iobserve.
the class PrivacyViolationDetectionServiceMain method createConfiguration.
@Override
protected PrivacyViolationDetectionConfiguration createConfiguration(final Configuration configuration) throws ConfigurationException {
/**
* load models.
*/
final PCMModelHandler modelHandler = new PCMModelHandler(this.pcmDirectory);
final GraphLoader graphLoader = new GraphLoader(this.modelDatabaseDirectory);
final Graph allocationModelGraph = graphLoader.initializeAllocationModelGraph(modelHandler.getAllocationModel());
final Graph resourceEnvironmentGraph = graphLoader.initializeResourceEnvironmentModelGraph(modelHandler.getResourceEnvironmentModel());
final Graph systemGraph = graphLoader.initializeSystemModelGraph(modelHandler.getSystemModel());
final ModelProvider<Allocation> allocationModelProvider = new ModelProvider<>(allocationModelGraph);
final ModelProvider<ResourceEnvironment> resourceEnvironmentModelProvider = new ModelProvider<>(resourceEnvironmentGraph);
final ModelProvider<System> systemModelProvider = new ModelProvider<>(systemGraph);
try {
return new PrivacyViolationDetectionConfiguration(this.inputPort, this.outputs, modelHandler.getCorrespondenceModel(), resourceEnvironmentModelProvider, allocationModelProvider, systemModelProvider, this.warningFile, this.alarmsFile);
} catch (final IOException e) {
throw new ConfigurationException(e);
}
}
Aggregations