Example usage for org.apache.commons.configuration Configuration getList

List of usage examples for org.apache.commons.configuration Configuration getList

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration getList.

Prototype

List getList(String key);

Source Link

Document

Get a List of strings associated with the given configuration key.

Usage

From source file:com.appeligo.channelfeed.SendCaptions.java

@Override
protected void openSources(Configuration provider) {
    int tunerCount = provider.getList("tuners.tuner[@deviceNumber]").size();

    for (int j = 0; j < tunerCount; j++) {
        String deviceNumber = provider.getString("tuners.tuner(" + j + ")[@deviceNumber]");
        String channel = provider.getString("tuners.tuner(" + j + ")[@channel]");
        String callsign = provider.getString("tuners.tuner(" + j + ")[@callsign]");
        boolean capturetv = provider.getBoolean("tuners.tuner(" + j + ")[@capturetv]", false);
        String framesize = provider.getString("tuners.tuner(" + j + ")[@framesize]");
        int framerate = provider.getInt("tuners.tuner(" + j + ")[@framerate]", -1);
        boolean nocaptions = provider.getBoolean("tuners.tuner(" + j + ")[@nocaptions]", false);
        boolean xds = provider.getBoolean("tuners.tuner(" + j + ")[@xds]", false);
        boolean itv = provider.getBoolean("tuners.tuner(" + j + ")[@itv]", false);

        log.info("deviceNumber=" + deviceNumber + ", channel=" + channel + ", callsign=" + callsign
                + ", capturetv=" + capturetv + ", framesize=" + framesize + ", framerate=" + framerate
                + ", nocaptions=" + nocaptions + ", xds=" + xds + ", itv=" + itv);

        if (deviceNumber == null || channel == null || callsign == null) {
            log.error("Invalid configuration in: " + identifyMe());
            log.error("    deviceNumber=" + deviceNumber + ", channel=" + channel + ", callsign=" + callsign);
            continue;
        }//from  w w w. j a  va 2 s  .c  o m
        try {
            VideoDevice videoDevice = new VideoDevice(Integer.parseInt(deviceNumber), getFrequencyStandard());
            videoDevice.setChannel(channel);

            if (capturetv) {
                TVThread tvThread = new TVThread(
                        "Video record " + getLineupID() + ", channel " + channel + ", callsign " + callsign);
                tvThread.setEpgService(getEpgService());
                tvThread.setLineupID(getLineupID());
                tvThread.setCallsign(callsign);
                tvThread.setCcDocumentRoot(getCaptionDocumentRoot());
                if (framesize != null && (framesize.trim().length() > 0)) {
                    tvThread.setFrameSize(framesize);
                }
                if (framerate >= 0) {
                    tvThread.setFrameRate(framerate);
                }
                tvThread.setVideoDevice(videoDevice);
                tvThread.start();
            }

            if (!nocaptions) {

                VideoDeviceReaderThread captionThread = new VideoDeviceReaderThread(
                        "Captions " + getLineupID() + ", channel " + channel + ", callsign " + callsign);

                Destinations destinations = setupDestinations();

                destinations.setCallsign(callsign);
                destinations.setSendXDS(xds);
                destinations.setSendITV(itv);

                captionThread.setDestinations(destinations);
                captionThread.setVideoDevice(videoDevice); // important to set destination and it's callsign before video device...sorry
                captionThread.setEpgService(getEpgService());

                destinations.connect();
                captionThread.start();
            }
        } catch (MalformedURLException e1) {
            log.error("Exception on a channel", e1);
        } catch (NumberFormatException e1) {
            log.error("Exception on a channel", e1);
        } catch (IOException e1) {
            log.error("Exception on a channel", e1);
        } catch (BadChannelException e1) {
            log.error("Exception on a channel", e1);
        } catch (Throwable e1) {
            log.error("Unexpected exception", e1);
        }
    }
}

From source file:es.udc.gii.common.eaf.log.BestFEsLogTool.java

@Override
public void configure(Configuration conf) {
    try {//from  www . jav  a 2s .  c o m
        super.configure(conf);
        this.fes_prints = conf.getList("Fes_Prints");
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.boozallen.cognition.ingest.storm.bolt.enrich.SetDateBoltTest.java

@Test
public void testConfigure(@Injectable Configuration conf) {
    new Expectations() {
        {//from  w  ww.  j  av a 2 s .c  o  m
            conf.getList(SetDateBolt.DATE_FIELD);
            result = Arrays.asList("field0");
            conf.getString(SetDateBolt.DATE_FORMAT);
            result = "format0";
        }
    };
    bolt.configure(conf);
    assertThat(bolt.dateFields.get(0), is("field0"));
    assertThat(bolt.dateFormat, is("format0"));
}

From source file:cross.io.AFragmentCommandServiceLoader.java

@Override
public void configure(Configuration cfg) {
    fragmentCommands = StringTools.toStringList(cfg.getList(getClass().getName() + ".fragmentCommands"));
}

From source file:com.boozallen.cognition.ingest.storm.bolt.starter.LineRegexReplaceInRegionBolt.java

void configureFields(Configuration conf) {
    fieldList = conf.getList(FIELDS).stream().map(o -> o.toString()).collect(Collectors.toList());
}

From source file:com.boozallen.cognition.ingest.storm.bolt.enrich.SetDateBolt.java

@Override
public void configure(Configuration conf) {
    dateFormat = conf.getString(DATE_FORMAT);
    dateFields = new ArrayList<>();
    conf.getList(DATE_FIELD).forEach(x -> dateFields.add(x.toString()));

    _updateIndexField = conf.getBoolean(UPDATE_INDEX_FIELD, false);

    Validate.notEmpty(dateFields);/*from   w w  w.  java  2 s .  c  om*/
    Validate.notBlank(dateFormat);
}

From source file:es.udc.gii.common.eaf.log.BestEverIndividualLogTool.java

@Override
public void configure(Configuration conf) {

    super.configure(conf);
    if (conf.containsKey("Fes_Prints")) {
        this.fes_prints = conf.getList("Fes_Prints");
    } else {//from   ww  w  . j  a  v  a  2  s . co  m
        ConfWarning w = new ConfWarning("Fes_Prints", "Empty List");
        w.warn();
    }
}

From source file:com.boozallen.cognition.ingest.storm.bolt.starter.LineRegexReplaceInRegionBolt.java

void configureRegexRegions(Configuration conf) throws ConfigurationException {
    List<String> regexRegionGroupList = conf.getList(REGEX_REGION_GROUP).stream().map(o -> o.toString())
            .collect(Collectors.toList());
    List<String> regexRegionSearchList = conf.getList(REGEX_REGION_SEARCH).stream().map(o -> o.toString())
            .collect(Collectors.toList());
    List<String> regexRegionReplaceList = conf.getList(REGEX_REGION_REPLACE).stream().map(o -> o.toString())
            .collect(Collectors.toList());

    int groupListSize = regexRegionGroupList.size();
    int searchListSize = regexRegionSearchList.size();
    int replaceListSize = regexRegionReplaceList.size();
    if (!(groupListSize == searchListSize && searchListSize == replaceListSize)) {
        // all lists must be the same size
        throw new ConfigurationException(
                "Error initializing class. All regexRegion lists must be the same size");
    }/* w w  w  .j av a  2s.  c  om*/

    groupSearchReplaceList = new ArrayList<>(groupListSize);
    for (int index = 0; index < regexRegionGroupList.size(); index++) {
        Pattern pattern = Pattern.compile(regexRegionGroupList.get(index));
        String regex = regexRegionSearchList.get(index);
        String replacement = regexRegionReplaceList.get(index);

        ImmutableTriple<Pattern, String, String> triple = new ImmutableTriple<>(pattern, regex, replacement);
        groupSearchReplaceList.add(triple);
    }
}

From source file:com.appeligo.alerts.CheckAlertsThread.java

private void updateEpgIndex() {
    Date updated = new Date();
    //Update the index with new programs now:
    Configuration lineupConfiguration = ConfigurationService.getConfiguration("lineups");
    List<String> lineups = (List<String>) lineupConfiguration.getList("lineups.lineup.id");

    EpgIndexer indexer = new EpgIndexer(alertManager.getLuceneIndex(), alertManager.getCompositeIndex(),
            alertManager.getEpg(), lineups);
    indexer.updateEpgIndex(alertManager.getLastEpgUpdate());
    alertManager.setLastEpgUpdate(updated);
}

From source file:es.udc.gii.common.eaf.problem.Problem.java

/**
 * Creates the list of constraint functions of this problem from the Configuration object.
 * @param conf a Configuration object with the configuration of this problem.
 * @return the list of constraint functions.
 *//*from  w w  w .  java  2s.  co  m*/
private List<Constraint> createConstraints(Configuration conf) {

    List<Constraint> listCnsts = new ArrayList<Constraint>();
    List cnsts = conf.getList("Constraint.Class");

    for (int i = 0; i < cnsts.size(); i++) {
        try {
            Constraint cnstr = (Constraint) Class.forName((String) cnsts.get(i)).newInstance();
            cnstr.configure(conf.subset("Constraint(" + i + ")"));
            listCnsts.add(cnstr);
        } catch (Exception ex) {
            throw new ConfigurationException("Wrong constraint configuration for " + (String) cnsts.get(i)
                    + " ?" + " \n Thrown exception: \n" + ex);
        }
    }

    return listCnsts;
}