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

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

Introduction

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

Prototype

int getInt(String key, int defaultValue);

Source Link

Document

Get a int associated with the given configuration key.

Usage

From source file:org.apache.james.smtpserver.fastfail.MaxUnknownCmdHandler.java

@Override
public void init(Configuration config) throws ConfigurationException {
    int maxUnknown = config.getInt("maxUnknownCmdCount", DEFAULT_MAX_UNKOWN);
    setMaxUnknownCmdCount(maxUnknown);/*  w  ww  .j  a  v  a 2  s . c  o m*/
}

From source file:org.apache.james.smtpserver.fastfail.SpamAssassinHandler.java

@Override
public void init(Configuration config) throws ConfigurationException {
    setSpamdHost(config.getString("spamdHost", "localhost"));
    setSpamdPort(config.getInt("spamdPort", 783));
    setSpamdRejectionHits(config.getDouble("spamdRejectionHits", 0.0));
}

From source file:org.apache.marmotta.platform.core.services.modules.ModuleServiceImpl.java

@PostConstruct
public void initialize() {

    //default_container_name = configurationService.getStringConfiguration("kiwi.pages.default_container.name",default_container_name);
    //default_container_number = configurationService.getIntConfiguration("kiwi.pages.default_container.number",default_container_number);

    modules = new HashSet<String>();
    containers = new HashMap<String, ArrayList<String>>();
    container_weight = new HashMap<String, Integer>();

    configurationMap = new HashMap<String, Configuration>();
    jarURLs = new HashMap<String, Configuration>();

    try {/* w ww  .  j a va2  s .  c  om*/
        Enumeration<URL> modulePropertiesEnum = this.getClass().getClassLoader()
                .getResources("kiwi-module.properties");

        while (modulePropertiesEnum.hasMoreElements()) {
            URL moduleUrl = modulePropertiesEnum.nextElement();

            Configuration moduleProperties = null;
            try {
                Set<Configuration> configurations = new HashSet<Configuration>();

                // get basic module configuration
                moduleProperties = new PropertiesConfiguration(moduleUrl);
                configurations.add(moduleProperties);

                String moduleName = moduleProperties.getString("name");
                modules.add(moduleName);

                String c_name = moduleProperties.getString("container") != null
                        ? moduleProperties.getString("container")
                        : default_container_name;

                if (containers.get(c_name) == null) {
                    containers.put(c_name, new ArrayList<String>());
                }
                containers.get(c_name).add(moduleName);

                if (container_weight.get(c_name) == null) {
                    container_weight.put(c_name, -1);
                }

                if (moduleProperties.getString("container.weight") != null) {
                    container_weight.put(c_name, Math.max(container_weight.get(c_name),
                            moduleProperties.getInt("container.weight", -1)));
                }

                URLConnection urlConnection = moduleUrl.openConnection();
                URL jarUrl;
                if (urlConnection instanceof JarURLConnection) {
                    JarURLConnection conn = (JarURLConnection) urlConnection;
                    jarUrl = conn.getJarFileURL();
                } else {
                    String fileUrl = moduleUrl.toString();
                    jarUrl = new URL(fileUrl.substring(0, fileUrl.lastIndexOf("/")));
                }

                // get the build information
                try {
                    PropertiesConfiguration buildInfo = new PropertiesConfiguration(
                            new URL("jar:" + jarUrl.toString() + "!/buildinfo.properties"));
                    buildInfo.setDelimiterParsingDisabled(true);
                    configurations.add(buildInfo);
                } catch (ConfigurationException ex) {
                }

                // alternative: maven buildinfo plugin
                try {
                    PropertiesConfiguration buildInfo = new PropertiesConfiguration(
                            new URL("jar:" + jarUrl.toString() + "!/build.info"));
                    buildInfo.setDelimiterParsingDisabled(true);
                    configurations.add(buildInfo);
                } catch (ConfigurationException ex) {
                }

                // create runtime configuration
                MapConfiguration runtimeConfiguration = new MapConfiguration(new HashMap<String, Object>());
                runtimeConfiguration.setProperty("runtime.jarfile", jarUrl.toString());
                configurations.add(runtimeConfiguration);

                CompositeConfiguration moduleConfiguration = new CompositeConfiguration(configurations);
                configurationMap.put(moduleName, moduleConfiguration);
                jarURLs.put(jarUrl.toString(), moduleConfiguration);

            } catch (ConfigurationException e) {
                log.error("error parsing kiwi-module.properties file at {}", moduleUrl, e);
            }

        }
        //TODO container should be sortable
    } catch (IOException ex) {
        log.error("I/O error while trying to retrieve kiwi-module.properties file", ex);
    }
}

From source file:org.apache.marmotta.platform.core.services.modules.ModuleServiceImpl.java

@Override
public int getWeight(String moduleName) {
    Configuration config = getModuleConfiguration(moduleName).getConfiguration();
    if (config != null)
        return config.getInt("weight", 50);
    else/*w  w w. jav  a2  s. co  m*/
        return 50;
}

From source file:org.apache.tinkerpop.gremlin.hadoop.structure.io.HadoopPools.java

public synchronized static void initialize(final Configuration configuration) {
    if (!INITIALIZED) {
        INITIALIZED = true;//from w  ww .  j a  v a 2  s.  c om
        GRYO_POOL = GryoPool.build().poolSize(configuration.getInt(GryoPool.CONFIG_IO_GRYO_POOL_SIZE, 256))
                .ioRegistries(configuration.getList(GryoPool.CONFIG_IO_REGISTRY, Collections.emptyList()))
                .create();
    }
}

From source file:org.apache.tinkerpop.gremlin.process.computer.clustering.peerpressure.PeerPressureVertexProgram.java

@Override
public void loadState(final Graph graph, final Configuration configuration) {
    if (configuration.containsKey(EDGE_TRAVERSAL)) {
        this.edgeTraversal = PureTraversal.loadState(configuration, EDGE_TRAVERSAL, graph);
        this.voteScope = MessageScope.Local.of(() -> this.edgeTraversal.get().clone());
        this.countScope = MessageScope.Local
                .of(new MessageScope.Local.ReverseTraversalSupplier(this.voteScope));
    }/*from  ww w .  java  2s .  c  o m*/
    this.property = configuration.getString(PROPERTY, CLUSTER);
    this.maxIterations = configuration.getInt(MAX_ITERATIONS, 30);
    this.distributeVote = configuration.getBoolean(DISTRIBUTE_VOTE, false);
}

From source file:org.apache.tinkerpop.gremlin.process.computer.ranking.pagerank.PageRankVertexProgram.java

@Override
public void loadState(final Graph graph, final Configuration configuration) {
    if (configuration.containsKey(INITIAL_RANK_TRAVERSAL))
        this.initialRankTraversal = PureTraversal.loadState(configuration, INITIAL_RANK_TRAVERSAL, graph);
    if (configuration.containsKey(EDGE_TRAVERSAL)) {
        this.edgeTraversal = PureTraversal.loadState(configuration, EDGE_TRAVERSAL, graph);
        this.incidentMessageScope = MessageScope.Local.of(() -> this.edgeTraversal.get().clone());
        this.countMessageScope = MessageScope.Local
                .of(new MessageScope.Local.ReverseTraversalSupplier(this.incidentMessageScope));
    }//from  w w  w  .  j  av a  2  s .  c o  m
    this.vertexCountAsDouble = configuration.getDouble(VERTEX_COUNT, 1.0d);
    this.alpha = configuration.getDouble(ALPHA, 0.85d);
    this.totalIterations = configuration.getInt(TOTAL_ITERATIONS, 30);
    this.property = configuration.getString(PROPERTY, PAGE_RANK);
    this.vertexComputeKeys = new HashSet<>(
            Arrays.asList(VertexComputeKey.of(this.property, false), VertexComputeKey.of(EDGE_COUNT, true)));
}

From source file:org.apache.tinkerpop.gremlin.spark.structure.io.gryo.kryoshim.unshaded.UnshadedKryoShimService.java

private LinkedBlockingQueue<Kryo> initialize(final Configuration configuration) {
    // DCL is safe in this case due to volatility
    if (!INITIALIZED) {
        synchronized (UnshadedKryoShimService.class) {
            if (!INITIALIZED) {
                // so we don't get a WARN that a new configuration is being created within an active context
                final SparkConf sparkConf = null == Spark.getContext() ? new SparkConf()
                        : Spark.getContext().getConf().clone();
                configuration.getKeys()/*  w  w w. j  av a  2s .  c  om*/
                        .forEachRemaining(key -> sparkConf.set(key, configuration.getProperty(key).toString()));
                final KryoSerializer serializer = new KryoSerializer(sparkConf);
                // Setup a pool backed by our spark.serializer instance
                // Reuse Gryo poolsize for Kryo poolsize (no need to copy this to SparkConf)
                KRYOS.clear();
                final int poolSize = configuration.getInt(GryoPool.CONFIG_IO_GRYO_POOL_SIZE,
                        GryoPool.CONFIG_IO_GRYO_POOL_SIZE_DEFAULT);
                for (int i = 0; i < poolSize; i++) {
                    KRYOS.add(serializer.newKryo());
                }
                INITIALIZED = true;
            }
        }
    }

    return KRYOS;
}

From source file:org.apache.tinkerpop.gremlin.structure.io.gryo.GryoPool.java

/**
 * Create a pool of readers and writers from a {@code Configuration} object.  There are two configuration keys
 * expected: "gremlin.io.registry" which defines a fully qualified class name of an {@link IoRegistry}
 * implementation and the "gremlin.io.gryo.poolSize" which defines the initial size of the {@code GryoPool}.
 */// w w w  .  ja  v a 2s . com
public GryoPool(final Configuration conf) {
    this(conf.getInt(CONFIG_IO_GRYO_POOL_SIZE, 256), Type.READER_WRITER,
            tryCreateIoRegistry(conf.getString(CONFIG_IO_REGISTRY, "")));
}

From source file:org.apache.whirr.service.accumulo.AccumuloGCClusterActionHandler.java

@Override
protected void configureFirewallRules(FirewallManager firewallManager, Configuration conf) throws IOException {
    firewallManager.addRule(Rule.create().destination(role(AccumuloGCClusterActionHandler.ROLE)).port(
            conf.getInt(AccumuloConstants.PROP_ACCUMULO_PORT_GC, AccumuloConstants.DEFAULT_ACCUMULO_PORT_GC)));
}