List of usage examples for org.apache.commons.configuration HierarchicalConfiguration getLong
public long getLong(String key, long defaultValue)
From source file:com.norconex.collector.http.delay.impl.ReferenceDelayResolver.java
@Override protected void loadDelaysFromXML(XMLConfiguration xml) throws IOException { List<HierarchicalConfiguration> nodes = xml.configurationsAt("pattern"); for (HierarchicalConfiguration node : nodes) { delayPatterns.add(/*from w w w .jav a 2 s . c om*/ new DelayReferencePattern(node.getString("", ""), node.getLong("[@delay]", DEFAULT_DELAY))); } }
From source file:com.github.steveash.typedconfig.resolver.type.simple.LongValueResolverFactory.java
@Override public ValueResolver makeForThis(final ConfigBinding binding, final HierarchicalConfiguration config, ConfigFactoryContext context) {// w w w . jav a 2s . com final String key = binding.getConfigKeyToLookup(); return new ConvertableValueResolver(Long.class, key) { @Override public Long resolve() { return config.getLong(binding.getConfigKeyToLookup(), null); } }; }
From source file:net.datenwerke.sandbox.util.SandboxParser.java
protected void configureThreadRestrictions(SandboxContext context, HierarchicalConfiguration contextConf) { long maximumRunTime = contextConf.getLong("[@maximumRunTime]", -1); context.setMaximumRunTime(maximumRunTime); String maximumRunTimeUnit = contextConf.getString("[@maximumRunTimeUnit]", null); if (null != maximumRunTimeUnit && !"".equals(maximumRunTimeUnit.trim())) context.setMaximumRunTimeUnit(TimeUnit.valueOf(maximumRunTimeUnit.toUpperCase())); String maximumRunTimeMode = contextConf.getString("[@maximumRunTimeMode]", null); if (null != maximumRunTimeMode && !"".equals(maximumRunTimeMode.trim())) context.setMaximumRuntimeMode(RuntimeMode.valueOf(maximumRunTimeMode.toUpperCase())); int maxStackDepth = contextConf.getInteger("[@maximumStackDepth]", -1); context.setMaximumStackDepth(maxStackDepth); }
From source file:com.sm.store.BuildRemoteConfig.java
private StoreConfig buildStoreConfig(HierarchicalConfiguration configuration) { StringBuilder sb = new StringBuilder(); String name = configuration.getString("name"); if (name == null) sb.append("store name is not defined "); String path = configuration.getString("path", "data"); String filename = configuration.getString("filename", name); boolean delay = configuration.getBoolean("delay", true); int mode = configuration.getInt("mode", 0); int freq = configuration.getInt("freq", this.freq == 0 ? 1 : this.freq); int batchSize = configuration.getInt("batchSize", 10); String logPath = configuration.getString("logPath", "log"); List<String> replicaUrl = configuration.getList("replicaUrl"); long replciaTimeout = configuration.getLong("replicaTimeout", 60000); if (replicaUrl == null) sb.append("no replicaUrl is defined"); boolean sorted = configuration.getBoolean("sorted", false); if (sb.length() > 0) { throw new RuntimeException("error on buildStoreConfig " + sb.toString()); } else {//from w w w .java 2 s. c om StoreConfig storeConfig = new StoreConfig(name, path, freq, replicaUrl, batchSize, delay, mode, sorted); storeConfig.setGetTriggerName(configuration.getString("getTrigger")); storeConfig.setPutTriggerName(configuration.getString("putTrigger")); storeConfig.setDeleteTriggerName(configuration.getString("deleteTrigger")); storeConfig.setUseMaxCache(configuration.getBoolean("useMaxCache", false)); storeConfig.setMaxCacheMemory(configuration.getInt("maxCacheMemory", 20000)); storeConfig.setUseLRU(configuration.getBoolean("useLRU", false)); storeConfig.setLogPath(logPath); storeConfig.setReplicaTimeout(replciaTimeout); //add pstReplicaURl storeConfig.setPstReplicaUrl(configuration.getList("pstReplicaUrl")); storeConfig.setSerializeClass(configuration.getString("serializeClass")); return storeConfig; } }
From source file:com.sm.store.cluster.BuildStoreConfig.java
private StoreConfig buildStoreConfig(HierarchicalConfiguration configuration) { StringBuilder sb = new StringBuilder(); String name = configuration.getString("name"); if (name == null) sb.append("store name is not defined "); String path = configuration.getString("path", "data"); String filename = configuration.getString("filename", name); boolean delay = configuration.getBoolean("delayWrite", true); int mode = configuration.getInt("mode", 0); int delayThread = configuration.getInt("delayThread", 2); String serializeClass = configuration.getString("serializer", "com.sm.localstore.impl.HessianSerializer"); String blockSizeClass = configuration.getString("blockSize"); BlockSize blockSize = null;// w ww . j ava 2s . co m if (blockSizeClass != null) { try { blockSize = (BlockSize) Class.forName(blockSizeClass).newInstance(); } catch (Exception ex) { sb.append(("unable to load " + blockSizeClass + " " + ex.getMessage())); } } boolean useCache = configuration.getBoolean("useCache", false); long maxCache = configuration.getLong("maxCache", 1000 * 1000 * 1000L); String logPath = configuration.getString("logPath", "log"); String replicaUrl = configuration.getString("replicaUrl"); String purgeClass = configuration.getString("purgeClass"); if (sb.length() > 0) { throw new RuntimeException("error on buildStoreConfig " + sb.toString()); } else { StoreConfig storeConfig = new StoreConfig(name, path, 10, null); storeConfig.setDelay(delay); storeConfig.setDelayThread(delayThread); storeConfig.setLogPath(logPath); storeConfig.setBlockSize(blockSize); storeConfig.setPurgeClass(purgeClass); // return new StoreConfig(name, path, filename, delay, mode, writeThread, useCache, maxCache, maxCache, // logPath, serializeClass, blockSize, replicaUrl); return storeConfig; } }
From source file:org.apache.james.lmtpserver.netty.LMTPServer.java
public void doConfigure(HierarchicalConfiguration configuration) throws ConfigurationException { super.doConfigure(configuration); if (isEnabled()) { // get the message size limit from the conf file and multiply // by 1024, to put it in bytes maxMessageSize = configuration.getLong("maxmessagesize", maxMessageSize) * 1024; if (maxMessageSize > 0) { getLogger().info("The maximum allowed message size is " + maxMessageSize + " bytes."); } else {//from w w w. j a v a 2s .c om getLogger().info("No maximum message size is enforced for this server."); } // get the lmtpGreeting lmtpGreeting = configuration.getString("lmtpGreeting", null); } }
From source file:org.apache.james.smtpserver.netty.SMTPServer.java
@Override public void doConfigure(HierarchicalConfiguration configuration) throws ConfigurationException { super.doConfigure(configuration); if (isEnabled()) { String authRequiredString = configuration.getString("authRequired", "false").trim().toLowerCase(); if (authRequiredString.equals("true")) authRequired = AUTH_REQUIRED; else if (authRequiredString.equals("announce")) authRequired = AUTH_ANNOUNCE; else/*from w ww . java 2 s.co m*/ authRequired = AUTH_DISABLED; if (authRequired != AUTH_DISABLED) { getLogger().info("This SMTP server requires authentication."); } else { getLogger().info("This SMTP server does not require authentication."); } authorizedAddresses = configuration.getString("authorizedAddresses", null); if (authRequired == AUTH_DISABLED && authorizedAddresses == null) { /* * if SMTP AUTH is not required then we will use * authorizedAddresses to determine whether or not to relay * e-mail. Therefore if SMTP AUTH is not required, we will not * relay e-mail unless the sending IP address is authorized. * * Since this is a change in behavior for James v2, create a * default authorizedAddresses network of 0.0.0.0/0, which * matches all possible addresses, thus preserving the current * behavior. * * James v3 should require the <authorizedAddresses> element. */ authorizedAddresses = "0.0.0.0/0.0.0.0"; } if (authorizedNetworks != null) { getLogger().info("Authorized addresses: " + authorizedNetworks.toString()); } // get the message size limit from the conf file and multiply // by 1024, to put it in bytes maxMessageSize = configuration.getLong("maxmessagesize", maxMessageSize) * 1024; if (maxMessageSize > 0) { getLogger().info("The maximum allowed message size is " + maxMessageSize + " bytes."); } else { getLogger().info("No maximum message size is enforced for this server."); } heloEhloEnforcement = configuration.getBoolean("heloEhloEnforcement", true); if (authRequiredString.equals("true")) authRequired = AUTH_REQUIRED; // get the smtpGreeting smtpGreeting = configuration.getString("smtpGreeting", null); addressBracketsEnforcement = configuration.getBoolean("addressBracketsEnforcement", true); verifyIdentity = configuration.getBoolean("verifyIdentity", true); } }
From source file:org.apache.james.user.ldap.LdapRepositoryConfiguration.java
public static LdapRepositoryConfiguration from(HierarchicalConfiguration configuration) throws ConfigurationException { String ldapHost = configuration.getString("[@ldapHost]", ""); String principal = configuration.getString("[@principal]", ""); String credentials = configuration.getString("[@credentials]", ""); String userBase = configuration.getString("[@userBase]"); String userIdAttribute = configuration.getString("[@userIdAttribute]"); String userObjectClass = configuration.getString("[@userObjectClass]"); // Default is to use connection pooling boolean useConnectionPool = configuration.getBoolean("[@useConnectionPool]", USE_CONNECTION_POOL); int connectionTimeout = configuration.getInt("[@connectionTimeout]", NO_CONNECTION_TIMEOUT); int readTimeout = configuration.getInt("[@readTimeout]", NO_READ_TIME_OUT); // Default maximum retries is 1, which allows an alternate connection to // be found in a multi-homed environment int maxRetries = configuration.getInt("[@maxRetries]", 1); boolean supportsVirtualHosting = configuration.getBoolean(SUPPORTS_VIRTUAL_HOSTING, !ENABLE_VIRTUAL_HOSTING);//from w ww . jav a 2 s.co m // Default retry start interval is 0 second long retryStartInterval = configuration.getLong("[@retryStartInterval]", 0); // Default maximum retry interval is 60 seconds long retryMaxInterval = configuration.getLong("[@retryMaxInterval]", 60); int scale = configuration.getInt("[@retryIntervalScale]", 1000); // seconds HierarchicalConfiguration restrictionConfig = null; // Check if we have a restriction we can use // See JAMES-1204 if (configuration.containsKey("restriction[@memberAttribute]")) { restrictionConfig = configuration.configurationAt("restriction"); } ReadOnlyLDAPGroupRestriction restriction = new ReadOnlyLDAPGroupRestriction(restrictionConfig); //see if there is a filter argument String filter = configuration.getString("[@filter]"); Optional<String> administratorId = Optional.ofNullable(configuration.getString("[@administratorId]")); return new LdapRepositoryConfiguration(ldapHost, principal, credentials, userBase, userIdAttribute, userObjectClass, useConnectionPool, connectionTimeout, readTimeout, maxRetries, supportsVirtualHosting, retryStartInterval, retryMaxInterval, scale, restriction, filter, administratorId); }
From source file:org.apache.james.user.ldap.ReadOnlyUsersLDAPRepository.java
/** * Extracts the parameters required by the repository instance from the * James server configuration data. The fields extracted include * {@link #ldapHost}, {@link #userIdAttribute}, {@link #userBase}, * {@link #principal}, {@link #credentials} and {@link #restriction}. * * @param configuration//from w w w . j a v a2s.co m * An encapsulation of the James server configuration data. */ public void configure(HierarchicalConfiguration configuration) throws ConfigurationException { ldapHost = configuration.getString("[@ldapHost]", ""); principal = configuration.getString("[@principal]", ""); credentials = configuration.getString("[@credentials]", ""); userBase = configuration.getString("[@userBase]"); userIdAttribute = configuration.getString("[@userIdAttribute]"); userObjectClass = configuration.getString("[@userObjectClass]"); // Default is to use connection pooling useConnectionPool = configuration.getBoolean("[@useConnectionPool]", true); connectionTimeout = configuration.getInt("[@connectionTimeout]", -1); readTimeout = configuration.getInt("[@readTimeout]", -1); // Default maximum retries is 1, which allows an alternate connection to // be found in a multi-homed environment maxRetries = configuration.getInt("[@maxRetries]", 1); // Default retry start interval is 0 second long retryStartInterval = configuration.getLong("[@retryStartInterval]", 0); // Default maximum retry interval is 60 seconds long retryMaxInterval = configuration.getLong("[@retryMaxInterval]", 60); int scale = configuration.getInt("[@retryIntervalScale]", 1000); // seconds schedule = new DoublingRetrySchedule(retryStartInterval, retryMaxInterval, scale); HierarchicalConfiguration restrictionConfig = null; // Check if we have a restriction we can use // See JAMES-1204 if (configuration.containsKey("restriction[@memberAttribute]")) { restrictionConfig = configuration.configurationAt("restriction"); } restriction = new ReadOnlyLDAPGroupRestriction(restrictionConfig); //see if there is a filter argument filter = configuration.getString("[@filter]"); }