Example usage for org.apache.commons.configuration CompositeConfiguration getStringArray

List of usage examples for org.apache.commons.configuration CompositeConfiguration getStringArray

Introduction

In this page you can find the example usage for org.apache.commons.configuration CompositeConfiguration getStringArray.

Prototype

public String[] getStringArray(String key) 

Source Link

Usage

From source file:com.germinus.easyconf.AggregatedProperties.java

private void addIncludedPropertiesSources(Configuration newConf, CompositeConfiguration loadedConf) {
    CompositeConfiguration tempConf = new CompositeConfiguration();
    tempConf.addConfiguration(prefixedSystemConfiguration);
    tempConf.addConfiguration(newConf);/* ww w  .  j ava  2  s . c  o m*/
    tempConf.addConfiguration(systemConfiguration);
    tempConf.addProperty(Conventions.COMPANY_ID_PROPERTY, companyId);
    tempConf.addProperty(Conventions.COMPONENT_NAME_PROPERTY, componentName);
    String[] fileNames = tempConf.getStringArray(Conventions.INCLUDE_PROPERTY);
    for (int i = fileNames.length - 1; i >= 0; i--) {
        String iteratedFileName = fileNames[i];
        addPropertiesSource(iteratedFileName, loadedConf);
    }
}

From source file:ffx.potential.utils.PotentialsFileOpener.java

/**
 * At present, parses the PDB, XYZ, INT, or ARC file from the constructor
 * and creates MolecularAssembly and properties objects.
 *///from w ww.j a va2  s.  c  om
@Override
public void run() {
    int numFiles = allFiles.length;
    for (int i = 0; i < numFiles; i++) {
        File fileI = allFiles[i];
        Path pathI = allPaths[i];
        MolecularAssembly assembly = new MolecularAssembly(pathI.toString());
        assembly.setFile(fileI);
        CompositeConfiguration properties = Keyword.loadProperties(fileI);
        ForceFieldFilter forceFieldFilter = new ForceFieldFilter(properties);
        ForceField forceField = forceFieldFilter.parse();
        String patches[] = properties.getStringArray("patch");
        for (String patch : patches) {
            logger.info(" Attempting to read force field patch from " + patch + ".");
            CompositeConfiguration patchConfiguration = new CompositeConfiguration();
            try {
                patchConfiguration.addProperty("propertyFile", fileI.getCanonicalPath());
            } catch (IOException e) {
                logger.log(Level.INFO, " Error loading {0}.", patch);
            }
            patchConfiguration.addProperty("parameters", patch);
            forceFieldFilter = new ForceFieldFilter(patchConfiguration);
            ForceField patchForceField = forceFieldFilter.parse();
            forceField.append(patchForceField);
            if (RotamerLibrary.addRotPatch(patch)) {
                logger.info(String.format(" Loaded rotamer definitions from patch %s.", patch));
            }
        }
        assembly.setForceField(forceField);
        if (new PDBFileFilter().acceptDeep(fileI)) {
            filter = new PDBFilter(fileI, assembly, forceField, properties);
        } else if (new XYZFileFilter().acceptDeep(fileI)) {
            filter = new XYZFilter(fileI, assembly, forceField, properties);
        } else if (new INTFileFilter().acceptDeep(fileI) || new ARCFileFilter().accept(fileI)) {
            filter = new INTFilter(fileI, assembly, forceField, properties);
        } else {
            throw new IllegalArgumentException(
                    String.format(" File %s could not be recognized as a valid PDB, XYZ, INT, or ARC file.",
                            pathI.toString()));
        }
        if (filter.readFile()) {
            if (!(filter instanceof PDBFilter)) {
                Utilities.biochemistry(assembly, filter.getAtomList());
            }
            filter.applyAtomProperties();
            assembly.finalize(true, forceField);
            //ForceFieldEnergy energy = new ForceFieldEnergy(assembly, filter.getCoordRestraints());
            ForceFieldEnergy energy;
            if (nThreads > 0) {
                energy = new ForceFieldEnergy(assembly, filter.getCoordRestraints(), nThreads);
            } else {
                energy = new ForceFieldEnergy(assembly, filter.getCoordRestraints());
            }
            assembly.setPotential(energy);
            assemblies.add(assembly);
            propertyList.add(properties);

            if (filter instanceof PDBFilter) {
                PDBFilter pdbFilter = (PDBFilter) filter;
                List<Character> altLocs = pdbFilter.getAltLocs();
                if (altLocs.size() > 1 || altLocs.get(0) != ' ') {
                    StringBuilder altLocString = new StringBuilder("\n Alternate locations found [ ");
                    for (Character c : altLocs) {
                        // Do not report the root conformer.
                        if (c == ' ') {
                            continue;
                        }
                        altLocString.append(format("(%s) ", c));
                    }
                    altLocString.append("]\n");
                    logger.info(altLocString.toString());
                }

                /**
                 * Alternate conformers may have different chemistry, so
                 * they each need to be their own MolecularAssembly.
                 */
                for (Character c : altLocs) {
                    if (c.equals(' ') || c.equals('A')) {
                        continue;
                    }
                    MolecularAssembly newAssembly = new MolecularAssembly(pathI.toString());
                    newAssembly.setForceField(assembly.getForceField());
                    pdbFilter.setAltID(newAssembly, c);
                    pdbFilter.clearSegIDs();
                    if (pdbFilter.readFile()) {
                        String fileName = assembly.getFile().getAbsolutePath();
                        newAssembly.setName(FilenameUtils.getBaseName(fileName) + " " + c);
                        filter.applyAtomProperties();
                        newAssembly.finalize(true, assembly.getForceField());
                        //energy = new ForceFieldEnergy(newAssembly, filter.getCoordRestraints());
                        if (nThreads > 0) {
                            energy = new ForceFieldEnergy(assembly, filter.getCoordRestraints(), nThreads);
                        } else {
                            energy = new ForceFieldEnergy(assembly, filter.getCoordRestraints());
                        }
                        newAssembly.setPotential(energy);
                        assemblies.add(newAssembly);
                    }
                }
            }
        } else {
            logger.warning(String.format(" Failed to read file %s", fileI.toString()));
        }
    }
    activeAssembly = assemblies.get(0);
    activeProperties = propertyList.get(0);
}

From source file:com.liferay.portal.configuration.easyconf.ClassLoaderAggregateProperties.java

private void _addIncludedPropertiesSources(Configuration newConfiguration,
        CompositeConfiguration loadedCompositeConfiguration) {

    CompositeConfiguration tempCompositeConfiguration = new CompositeConfiguration();

    tempCompositeConfiguration.addConfiguration(_prefixedSystemConfiguration);
    tempCompositeConfiguration.addConfiguration(newConfiguration);
    tempCompositeConfiguration.addConfiguration(_systemConfiguration);
    tempCompositeConfiguration.addProperty(Conventions.COMPANY_ID_PROPERTY, _companyId);
    tempCompositeConfiguration.addProperty(Conventions.COMPONENT_NAME_PROPERTY, _componentName);

    String[] fileNames = tempCompositeConfiguration.getStringArray(Conventions.INCLUDE_PROPERTY);
    //Modification start
    for (int i = fileNames.length - 1; i >= 0; i--) {
        String fileName = fileNames[i];
        //Modification end
        URL url = null;// ww  w.  j av  a 2 s.  c  om

        try {
            url = _classLoader.getResource(fileName);
        } catch (RuntimeException re) {
            if (fileName.startsWith("file:/")) {
                throw re;
            }

            fileName = "file:/".concat(fileName);

            url = _classLoader.getResource(fileName);
        }

        _addPropertiesSource(fileName, url, loadedCompositeConfiguration);
    }
}

From source file:cc.kune.wave.server.CustomSettingsBinder.java

/**
 * Bind configuration parameters into Guice Module.
 *
 * @param propertyFile the property file
 * @param settingsArg the settings arg//  w w w . j  a  v a 2 s .  c om
 * @return a Guice module configured with setting support.
 * @throws ConfigurationException on configuration error
 */
public static Module bindSettings(String propertyFile, Class<?>... settingsArg) throws ConfigurationException {
    final CompositeConfiguration config = new CompositeConfiguration();
    config.addConfiguration(new SystemConfiguration());
    config.addConfiguration(new PropertiesConfiguration(propertyFile));

    List<Field> fields = new ArrayList<Field>();
    for (Class<?> settings : settingsArg) {
        fields.addAll(Arrays.asList(settings.getDeclaredFields()));
    }

    // Reflect on settings class and absorb settings
    final Map<Setting, Field> settings = new LinkedHashMap<Setting, Field>();
    for (Field field : fields) {
        if (!field.isAnnotationPresent(Setting.class)) {
            continue;
        }

        // Validate target type
        SettingTypeValidator typeHelper = supportedSettingTypes.get(field.getType());
        if (typeHelper == null || !typeHelper.check(field.getGenericType())) {
            throw new IllegalArgumentException(field.getType() + " is not one of the supported setting types");
        }

        Setting setting = field.getAnnotation(Setting.class);
        settings.put(setting, field);
    }

    // Now validate them
    List<String> missingProperties = new ArrayList<String>();
    for (Setting setting : settings.keySet()) {
        if (setting.defaultValue().isEmpty()) {
            if (!config.containsKey(setting.name())) {
                missingProperties.add(setting.name());
            }
        }
    }
    if (missingProperties.size() > 0) {
        StringBuilder error = new StringBuilder();
        error.append("The following required properties are missing from the server configuration: ");
        error.append(Joiner.on(", ").join(missingProperties));
        throw new ConfigurationException(error.toString());
    }

    // bundle everything up in an injectable guice module
    return new AbstractModule() {

        @Override
        protected void configure() {
            // We must iterate the settings a third time when binding.
            // Note: do not collapse these loops as that will damage
            // early error detection. The runtime is still O(n) in setting count.
            for (Map.Entry<Setting, Field> entry : settings.entrySet()) {
                Class<?> type = entry.getValue().getType();
                Setting setting = entry.getKey();

                if (int.class.equals(type)) {
                    Integer defaultValue = null;
                    if (!setting.defaultValue().isEmpty()) {
                        defaultValue = Integer.parseInt(setting.defaultValue());
                    }
                    bindConstant().annotatedWith(Names.named(setting.name()))
                            .to(config.getInteger(setting.name(), defaultValue));
                } else if (boolean.class.equals(type)) {
                    Boolean defaultValue = null;
                    if (!setting.defaultValue().isEmpty()) {
                        defaultValue = Boolean.parseBoolean(setting.defaultValue());
                    }
                    bindConstant().annotatedWith(Names.named(setting.name()))
                            .to(config.getBoolean(setting.name(), defaultValue));
                } else if (String.class.equals(type)) {
                    bindConstant().annotatedWith(Names.named(setting.name()))
                            .to(config.getString(setting.name(), setting.defaultValue()));
                } else {
                    String[] value = config.getStringArray(setting.name());
                    if (value.length == 0 && !setting.defaultValue().isEmpty()) {
                        value = setting.defaultValue().split(",");
                    }
                    bind(new TypeLiteral<List<String>>() {
                    }).annotatedWith(Names.named(setting.name())).toInstance(ImmutableList.copyOf(value));
                }
            }
        }
    };
}

From source file:net.elsched.utils.SettingsBinder.java

/**
 * Bind configuration parameters into Guice Module.
 * /*  ww w. ja v a2s  .c  om*/
 * @return a Guice module configured with setting support.
 * @throws ConfigurationException
 *             on configuration error
 */
public static Module bindSettings(String propertiesFileKey, Class<?>... settingsArg)
        throws ConfigurationException {
    final CompositeConfiguration config = new CompositeConfiguration();
    config.addConfiguration(new SystemConfiguration());
    String propertyFile = config.getString(propertiesFileKey);

    if (propertyFile != null) {
        config.addConfiguration(new PropertiesConfiguration(propertyFile));
    }

    List<Field> fields = new ArrayList<Field>();
    for (Class<?> settings : settingsArg) {
        fields.addAll(Arrays.asList(settings.getDeclaredFields()));
    }

    // Reflect on settings class and absorb settings
    final Map<Setting, Field> settings = new LinkedHashMap<Setting, Field>();
    for (Field field : fields) {
        if (!field.isAnnotationPresent(Setting.class)) {
            continue;
        }

        // Validate target type
        SettingTypeValidator typeHelper = supportedSettingTypes.get(field.getType());
        if (typeHelper == null || !typeHelper.check(field.getGenericType())) {
            throw new IllegalArgumentException(field.getType() + " is not one of the supported setting types");
        }

        Setting setting = field.getAnnotation(Setting.class);
        settings.put(setting, field);
    }

    // Now validate them
    List<String> missingProperties = new ArrayList<String>();
    for (Setting setting : settings.keySet()) {
        if (setting.defaultValue().isEmpty()) {
            if (!config.containsKey(setting.name())) {
                missingProperties.add(setting.name());
            }
        }
    }
    if (missingProperties.size() > 0) {
        StringBuilder error = new StringBuilder();
        error.append("The following required properties are missing from the server configuration: ");
        error.append(Joiner.on(", ").join(missingProperties));
    }

    // bundle everything up in an injectable guice module
    return new AbstractModule() {

        @Override
        protected void configure() {
            // We must iterate the settings a third time when binding.
            // Note: do not collapse these loops as that will damage
            // early error detection. The runtime is still O(n) in setting
            // count.
            for (Map.Entry<Setting, Field> entry : settings.entrySet()) {
                Class<?> type = entry.getValue().getType();
                Setting setting = entry.getKey();

                if (int.class.equals(type)) {
                    Integer defaultValue = null;
                    if (!setting.defaultValue().isEmpty()) {
                        defaultValue = Integer.parseInt(setting.defaultValue());
                    }
                    bindConstant().annotatedWith(Names.named(setting.name()))
                            .to(config.getInteger(setting.name(), defaultValue));
                } else if (boolean.class.equals(type)) {
                    Boolean defaultValue = null;
                    if (!setting.defaultValue().isEmpty()) {
                        defaultValue = Boolean.parseBoolean(setting.defaultValue());
                    }
                    bindConstant().annotatedWith(Names.named(setting.name()))
                            .to(config.getBoolean(setting.name(), defaultValue));
                } else if (String.class.equals(type)) {
                    bindConstant().annotatedWith(Names.named(setting.name()))
                            .to(config.getString(setting.name(), setting.defaultValue()));
                } else {
                    String[] value = config.getStringArray(setting.name());
                    if (value.length == 0 && !setting.defaultValue().isEmpty()) {
                        value = setting.defaultValue().split(",");
                    }
                    bind(new TypeLiteral<List<String>>() {
                    }).annotatedWith(Names.named(setting.name())).toInstance(ImmutableList.copyOf(value));
                }
            }
        }
    };
}

From source file:ffx.ui.MainPanel.java

/**
 * Attempts to load the supplied file/*  w w w .  ja  v a2 s. co m*/
 *
 * @param files Files to open
 * @param commandDescription Description of the command that created this
 * file.
 * @return a {@link java.lang.Thread} object.
 */
private UIFileOpener openInit(List<File> files, String commandDescription) {
    if (files == null) {
        return null;
    }
    File file = new File(FilenameUtils.normalize(files.get(0).getAbsolutePath()));
    // Set the Current Working Directory based on this file.
    setCWD(file.getParentFile());

    // Get "filename" from "filename.extension".
    String name = file.getName();
    String extension = FilenameUtils.getExtension(name);

    // Create the CompositeConfiguration properties.
    CompositeConfiguration properties = Keyword.loadProperties(file);
    forceFieldFilter = new ForceFieldFilter(properties);
    ForceField forceField = forceFieldFilter.parse();

    // Create an FFXSystem for this file.
    FFXSystem newSystem = new FFXSystem(file, commandDescription, properties);
    String patches[] = properties.getStringArray("patch");
    for (String patch : patches) {
        logger.info(" Attempting to read force field patch from " + patch + ".");
        CompositeConfiguration patchConfiguration = new CompositeConfiguration();
        patchConfiguration.addProperty("parameters", patch);
        forceFieldFilter = new ForceFieldFilter(patchConfiguration);
        ForceField patchForceField = forceFieldFilter.parse();
        forceField.append(patchForceField);
        if (RotamerLibrary.addRotPatch(patch)) {
            logger.info(String.format(" Loaded rotamer definitions from patch %s.", patch));
        }
    }
    newSystem.setForceField(forceField);
    // Decide what parser to use.
    SystemFilter systemFilter = null;
    if (xyzFileFilter.acceptDeep(file)) {
        // Use the TINKER Cartesian Coordinate File Parser.
        systemFilter = new XYZFilter(files, newSystem, forceField, properties);
    } else if (intFileFilter.acceptDeep(file)) {
        // Use the TINKER Internal Coordinate File Parser.
        systemFilter = new INTFilter(files, newSystem, forceField, properties);
    } else {
        // Use the PDB File Parser.
        systemFilter = new PDBFilter(files, newSystem, forceField, properties);
    }

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    activeFilter = systemFilter;
    //return new UIFileOpener(systemFilter, this);
    UIFileOpener fileOpener = new UIFileOpener(systemFilter, this);
    if (fileOpenerThreads > 0) {
        fileOpener.setNThreads(fileOpenerThreads);
    }
    return fileOpener;
}

From source file:ffx.ui.MainPanel.java

/**
 * Attempts to load from the supplied data structure
 *
 * @param data Data structure to load from
 * @param file Source file//from   w w  w  .  j a  va2  s  .c  o  m
 * @param commandDescription Description of the command that created this
 * file.
 * @return A thread-based UIDataConverter
 */
private UIDataConverter convertInit(Object data, File file, String commandDescription) {
    if (data == null) {
        return null;
    }

    // Create the CompositeConfiguration properties.
    CompositeConfiguration properties = Keyword.loadProperties(file);
    // Create an FFXSystem for this file.
    FFXSystem newSystem = new FFXSystem(file, commandDescription, properties);
    // Create a Force Field.
    forceFieldFilter = new ForceFieldFilter(properties);
    ForceField forceField = forceFieldFilter.parse();
    String patches[] = properties.getStringArray("patch");
    for (String patch : patches) {
        logger.info(" Attempting to read force field patch from " + patch + ".");
        CompositeConfiguration patchConfiguration = new CompositeConfiguration();
        patchConfiguration.addProperty("parameters", patch);
        forceFieldFilter = new ForceFieldFilter(patchConfiguration);
        ForceField patchForceField = forceFieldFilter.parse();
        forceField.append(patchForceField);
        if (RotamerLibrary.addRotPatch(patch)) {
            logger.info(String.format(" Loaded rotamer definitions from patch %s.", patch));
        }
    }
    newSystem.setForceField(forceField);
    ConversionFilter convFilter = null;

    // Decide what parser to use.
    if (biojavaDataFilter.accept(data)) {
        convFilter = new BiojavaFilter((Structure) data, newSystem, forceField, properties);
    } else {
        throw new IllegalArgumentException("Not a recognized data structure.");
    }

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    activeConvFilter = convFilter;
    return new UIDataConverter(data, file, convFilter, this);
}

From source file:ffx.ui.MainPanel.java

/**
 * Attempts to load the supplied file/*from   w w w  .  j  a va 2  s . c o  m*/
 *
 * @param file File to open
 * @param commandDescription Description of the command that created this
 * file.
 * @return a {@link java.lang.Thread} object.
 */
private UIFileOpener openInit(File file, String commandDescription) {
    if (file == null || !file.isFile() || !file.canRead()) {
        return null;
    }
    file = new File(FilenameUtils.normalize(file.getAbsolutePath()));
    // Set the Current Working Directory based on this file.
    setCWD(file.getParentFile());

    // Get "filename" from "filename.extension".
    String name = file.getName();
    String extension = FilenameUtils.getExtension(name);

    /**
     * Run a Force Field X script.
     */
    if (extension.equalsIgnoreCase("ffx") || extension.equalsIgnoreCase("groovy")) {
        ModelingShell shell = getModelingShell();
        shell.runFFXScript(file);
        boolean shutDown = Boolean.parseBoolean(System.getProperty("ffx.shutDown", "true"));
        if (java.awt.GraphicsEnvironment.isHeadless() && shutDown) {
            exit();
        } else {
            return null;
        }
    }

    // Create the CompositeConfiguration properties.
    CompositeConfiguration properties = Keyword.loadProperties(file);
    // Create an FFXSystem for this file.
    FFXSystem newSystem = new FFXSystem(file, commandDescription, properties);
    // Create a Force Field.
    forceFieldFilter = new ForceFieldFilter(properties);
    ForceField forceField = forceFieldFilter.parse();
    String patches[] = properties.getStringArray("patch");
    for (String patch : patches) {
        logger.info(" Attempting to read force field patch from " + patch + ".");
        CompositeConfiguration patchConfiguration = new CompositeConfiguration();
        patchConfiguration.addProperty("parameters", patch);
        forceFieldFilter = new ForceFieldFilter(patchConfiguration);
        ForceField patchForceField = forceFieldFilter.parse();
        forceField.append(patchForceField);
        if (RotamerLibrary.addRotPatch(patch)) {
            logger.info(String.format(" Loaded rotamer definitions from patch %s.", patch));
        }
    }
    newSystem.setForceField(forceField);
    SystemFilter systemFilter = null;

    // Decide what parser to use.
    if (xyzFileFilter.acceptDeep(file)) {
        // Use the TINKER Cartesian Coordinate File Parser.
        systemFilter = new XYZFilter(file, newSystem, forceField, properties);
    } else if (intFileFilter.acceptDeep(file)) {
        // Use the TINKER Internal Coordinate File Parser.
        systemFilter = new INTFilter(file, newSystem, forceField, properties);
    } else {
        // Use the PDB File Parser.
        systemFilter = new PDBFilter(file, newSystem, forceField, properties);
    }

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    activeFilter = systemFilter;
    UIFileOpener fileOpener = new UIFileOpener(systemFilter, this);
    if (fileOpenerThreads > 0) {
        fileOpener.setNThreads(fileOpenerThreads);
    }
    return fileOpener;
    //return new UIFileOpener(systemFilter, this);
}

From source file:org.soaplab.clients.BatchTestClient.java

/*************************************************************************
 *
 * Entry point...//from  ww w  . j av a  2 s.  co  m
 *
 *************************************************************************/
public static void main(String[] args) {
    try {
        BaseCmdLine cmd = getCmdLine(args, BatchTestClient.class);

        // service location and protocol parameters
        ServiceLocator mainLocator = InputUtils.getServiceLocator(cmd);

        // file(s) with the testing data (a list of tested
        // services and their inputs)
        String[] batchFiles = null;
        String batchFile = cmd.getParam("-batchfile");
        if (batchFile != null) {
            // take it from the command-line
            batchFiles = new String[] { batchFile };
        } else {
            // take it from the client configuration file
            batchFiles = ClientConfig.get().getStringArray(ClientConfig.PROP_BATCH_TEST_FILE);
        }
        if (batchFiles == null || batchFiles.length == 0) {
            log.error("A file with a list of service to test must be given. "
                    + "Use '-batchfile' or a property '" + ClientConfig.PROP_BATCH_TEST_FILE + "'.");
            System.exit(1);
        }

        // other arguments
        boolean tableReport = (cmd.hasOption("-table")
                || ClientConfig.isEnabled(ClientConfig.PROP_BATCH_REPORT_TABLE, false));
        boolean keepResults = (cmd.hasOption("-keep")
                || ClientConfig.isEnabled(ClientConfig.PROP_BATCH_KEEP_RESULTS, false));
        int maxThreads = -1;
        String strMaxThreads = cmd.getParam("-maxthreads");
        if (strMaxThreads == null)
            maxThreads = ClientConfig.getInt(ClientConfig.PROP_BATCH_MAX_THREADS, 25);
        else
            maxThreads = getInt(strMaxThreads);
        if (maxThreads < 0)
            maxThreads = 0;
        boolean oneByOne = (maxThreads == 1);

        // get a list of available services
        // (for validation purposes later)
        Set<String> services = new HashSet<String>();
        for (String name : new SoaplabBaseClient(mainLocator).getAvailableAnalyses()) {
            services.add(name);
        }

        // loop and do it...
        List<Properties> reports = Collections.synchronizedList(new ArrayList<Properties>());
        List<Thread> threads = Collections.synchronizedList(new ArrayList<Thread>());
        int countNotAvailable = 0;

        title("Progress");
        for (String file : batchFiles) {

            log.info("Using batch file " + file);

            // treat each batch file as a property configuration
            // file - together with a usual Soaplab Client
            // configuration file; this allows handling
            // substitutions of referenced properties, etc.
            CompositeConfiguration cfg = new CompositeConfiguration();
            cfg.addConfiguration(ClientConfig.get());
            cfg.addConfiguration(Config.get());
            try {
                cfg.addConfiguration(new PropertiesConfiguration(file));
            } catch (ConfigurationException e) {
                log.error("Loading batch file from '" + file + "' failed: " + e.getMessage());
                continue;
            }

            //
            for (Iterator it = cfg.getKeys(); it.hasNext();) {
                String propertyName = (String) it.next();
                if (!propertyName.startsWith(PREFIX_SERVICE_TO_TEST))
                    continue;
                String serviceName = StringUtils.removeStart(propertyName, PREFIX_SERVICE_TO_TEST);
                if (!services.contains(serviceName)) {
                    //          log.warn (serviceName + " is not available for testing");
                    countNotAvailable += 1;
                    continue;
                }
                String[] inputs = cfg.getStringArray(propertyName);
                for (String input : inputs) {
                    MyLocator locator = new MyLocator(serviceName, mainLocator);
                    locator.enableKeepResults(keepResults);
                    locator.setInputLine(input);
                    if (oneByOne) {
                        // sequential invocation
                        qmsg(String.format("%-50s", "Running " + serviceName + "... "));
                        Properties report = callService(locator, reports);
                        qmsgln("finished: " + report.getProperty(REPORT_JOB_STATUS));

                    } else {
                        // do it in parallel
                        startService(threads, locator, reports);
                        if (maxThreads > 0) {
                            // limit the number of threads
                            // (just wait for some to finish)
                            while (threads.size() >= maxThreads) {
                                try {
                                    Thread.sleep(1000);
                                } catch (Exception e) {
                                }
                            }
                        }
                    }
                }
            }
        }

        if (!oneByOne) {
            // wait for all the threads to finish
            while (threads.size() > 0) {
                try {
                    Thread.sleep(1000);
                } catch (Exception e) {
                }
            }
        }
        msgln("");

        // report all tests
        if (tableReport)
            createTableReport(reports);

        // report results
        int countSuccessful = 0;
        int countErrors = 0;
        for (Properties report : reports) {
            if (report.containsKey(REPORT_ERROR_MESSAGE)) {
                report.remove(REPORT_STACK_TRACE);
                countErrors += 1;
                createErrorReport(report);
            } else {
                String status = report.getProperty(REPORT_JOB_STATUS);
                if (SoaplabConstants.JOB_COMPLETED.equals(status)) {
                    countSuccessful += 1;
                } else {
                    countErrors += 1;
                    createErrorReport(report);
                }
            }
        }

        // make a summary
        title("Summary");
        msgln("Successfully:  " + countSuccessful);
        msgln("Erroneously:   " + countErrors);
        msgln("Not available: " + countNotAvailable);

        exit(0);

    } catch (Throwable e) {
        processErrorAndExit(e);
    }

}

From source file:org.soaplab.clients.ClientConfig.java

/**************************************************************************
 * The main method returning a configuration object. The returned
 * object is a singleton - but its contents (the properties it
 * carries) can be changed dynamically (the properties are
 * reloaded if their files are modified). <p>
 *
 * The configuration object contains all Java system properties
 * and properties read from the Soaplab client configuration
 * file. This file name is given by the system property {@link
 * #PROP_SOAPLAB_CLIENT_CONFIGURATION}, or using a default name
 * {@link #SOAPLAB_CLIENT_CONFIG_FILENAME}. If the filename does
 * not specify an absolute path, the file will be searched
 * automatically in the following locations:
 *
 * <ul>//w  w w. j a  v  a  2 s .  c  om
 *  <li> in the current directory,
 *  <li> in the user home,
 *  <li> directory in the classpath
 * </ul><p>
 *
 * The System properties take precedence over properties read from
 * the Soaplab client property file. <p>
 *
 * @return a configuration object
 **************************************************************************/
public static synchronized CompositeConfiguration get() {
    if (config == null) {

        // set the global configuration
        CompositeConfiguration cfg = new CompositeConfiguration();

        // first, add System properties
        cfg.addConfiguration(new SystemConfiguration());

        // second, add Soaplab client properties file(s)
        String[] configFilenames = cfg.getStringArray(PROP_SOAPLAB_CLIENT_CONFIGURATION);
        if (configFilenames == null || configFilenames.length == 0)
            configFilenames = new String[] { SOAPLAB_CLIENT_CONFIG_FILENAME };
        for (int i = 0; i < configFilenames.length; i++) {
            log.info("Using configuration file: " + configFilenames[i]);
            addPropertiesConfiguration(cfg, configFilenames[i]);
        }

        // keep it for other calls
        config = cfg;
    }
    return config;
}