Search in sources :

Example 1 with ConfigurationException

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();
    }
}
Also used : ConfigurationException(org.iobserve.stages.general.ConfigurationException) JCommander(com.beust.jcommander.JCommander) ParameterException(com.beust.jcommander.ParameterException)

Example 2 with ConfigurationException

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);
    }
}
Also used : ConfigurationException(org.iobserve.stages.general.ConfigurationException)

Example 3 with ConfigurationException

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);
    }
}
Also used : ConfigurationException(org.iobserve.stages.general.ConfigurationException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException)

Example 4 with ConfigurationException

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);
    }
}
Also used : ConfigurationException(org.iobserve.stages.general.ConfigurationException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) ArrayList(java.util.ArrayList) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) File(java.io.File) SAXException(org.xml.sax.SAXException)

Example 5 with ConfigurationException

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);
    }
}
Also used : ResourceEnvironment(org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment) ModelProvider(org.iobserve.model.provider.neo4j.ModelProvider) PCMModelHandler(org.iobserve.model.PCMModelHandler) IOException(java.io.IOException) System(org.palladiosimulator.pcm.system.System) Graph(org.iobserve.model.provider.neo4j.Graph) GraphLoader(org.iobserve.model.provider.neo4j.GraphLoader) Allocation(org.palladiosimulator.pcm.allocation.Allocation) ConfigurationException(org.iobserve.stages.general.ConfigurationException)

Aggregations

ConfigurationException (org.iobserve.stages.general.ConfigurationException)6 IOException (java.io.IOException)4 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 JCommander (com.beust.jcommander.JCommander)1 ParameterException (com.beust.jcommander.ParameterException)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 PCMModelHandler (org.iobserve.model.PCMModelHandler)1 Graph (org.iobserve.model.provider.neo4j.Graph)1 GraphLoader (org.iobserve.model.provider.neo4j.GraphLoader)1 ModelProvider (org.iobserve.model.provider.neo4j.ModelProvider)1 Allocation (org.palladiosimulator.pcm.allocation.Allocation)1 ResourceEnvironment (org.palladiosimulator.pcm.resourceenvironment.ResourceEnvironment)1 System (org.palladiosimulator.pcm.system.System)1 SAXException (org.xml.sax.SAXException)1