ImmutableTypedProperties(TypedProperties properties) { super(); if (properties != null && !properties.isEmpty()) { for (Map.Entry<Object, Object> e : properties.entrySet()) super.put(e.getKey(), e.getValue()); } }
public void load(TypedProperties properties, String key, Class<?> type, String value) { Matcher m = MAP_PATTERN.matcher(key); if (m.matches()) { String mainKey = m.group(1); TypedProperties subProperties = properties.get(mainKey, (TypedProperties) null); if (subProperties == null) { subProperties = new TypedProperties(properties, mainKey); } String subKey = m.group(2); if (!m.group(3).equals("")) { // FIXME, assumed it is {}{} load(subProperties, subKey + m.group(3), type, value); } else { PropertyConverter<?> converter = converters.get(type); if (converter == null) { System.err.println( "TypedProperties.load: No Converter defined for '" + type + "' of '" + subKey + "'"); } else { try { converter.load(subProperties, subKey, type, value); } catch (Exception e) { System.err.println( "TypedProperties.load: Could not load property '" + subKey + "' with type '" + type + "'"); } } } } }
protected String readTemplate(String filePropertyKey, String languageCode, boolean isMandatory) throws MegatronException { String filename = props.getString(filePropertyKey, null); if (StringUtil.isNullOrEmpty(filename)) { if (isMandatory) { throw new MegatronException("Mandatory property for template file is missing."); } return null; } File templateFile = null; if (languageCode != null) { templateFile = new File(getTemplateDir(), languageCode.toLowerCase()); templateFile = new File(templateFile, filename); if (!templateFile.canRead()) { log.warn( "Cannot read template for language '" + languageCode + "'. Using default template instead. File: " + templateFile.getAbsolutePath()); // fallback to default template templateFile = new File(getTemplateDir(), filename); } } else { templateFile = new File(getTemplateDir(), filename); } try { return FileUtil.readFile(templateFile, Constants.UTF8); } catch (IOException e) { String msg = "Cannot read template file: " + templateFile.getAbsolutePath(); throw new MegatronException(msg, e); } }
public Collection<SocketAddress> getServerList() { Set<SocketAddress> addresses = new HashSet<SocketAddress>(); String servers = props.getProperty(SERVER_LIST, "127.0.0.1:" + DEFAULT_HOTROD_PORT); for (String server : servers.split(";")) { String[] components = server.trim().split(":"); String host = components[0]; int port = DEFAULT_HOTROD_PORT; if (components.length > 1) port = Integer.parseInt(components[1]); addresses.add(new InetSocketAddress(host, port)); } if (addresses.isEmpty()) throw new IllegalStateException("No Hot Rod servers specified!"); return addresses; }
public String getTrustStoreFileName() { return props.getProperty(TRUST_STORE_FILE_NAME, null); }
public String getKeyStorePassword() { return props.getProperty(KEY_STORE_PASSWORD, null); }
public String getKeyStoreFileName() { return props.getProperty(KEY_STORE_FILE_NAME, null); }
public boolean getTcpNoDelay() { return props.getBooleanProperty(TCP_NO_DELAY, true); }
public void store(Properties p, String key, Class<?> type, TypedProperties value) { value.store(p, key); }
public String getTransportFactory() { return props.getProperty(TRANSPORT_FACTORY, TcpTransportFactory.class.getName()); }
public ConfigurationProperties(String serverList) { this(); props.setProperty(SERVER_LIST, serverList); }
public boolean getForceReturnValues() { return props.getBooleanProperty(FORCE_RETURN_VALUES, false); }
public int getValueSizeEstimate() { return props.getIntProperty(VALUE_SIZE_ESTIMATE, DEFAULT_VALUE_SIZE); }
public int getKeySizeEstimate() { return props.getIntProperty(KEY_SIZE_ESTIMATE, DEFAULT_KEY_SIZE); }
public String getRequestBalancingStrategy() { return props.getProperty( REQUEST_BALANCING_STRATEGY, RoundRobinBalancingStrategy.class.getName()); }
public boolean getPingOnStartup() { return props.getBooleanProperty(PING_ON_STARTUP, true); }
public boolean getTcpKeepAlive() { return props.getBooleanProperty(TCP_KEEP_ALIVE, false); }
public String getTrustStorePassword() { return props.getProperty(TRUST_STORE_PASSWORD, null); }
public int getMaxRetries() { return props.getIntProperty(MAX_RETRIES, DEFAULT_MAX_RETRIES); }
public int getSoTimeout() { return props.getIntProperty(SO_TIMEOUT, DEFAULT_SO_TIMEOUT); }
public ConfigurationProperties(Properties props) { this.props = props == null ? new TypedProperties() : TypedProperties.toTypedProperties(props); }
public String getProtocolVersion() { return props.getProperty(PROTOCOL_VERSION, DEFAULT_PROTOCOL_VERSION); }
public int getDefaultExecutorFactoryPoolSize() { return props.getIntProperty(DEFAULT_EXECUTOR_FACTORY_POOL_SIZE, 99); }
public String getAsyncExecutorFactory() { return props.getProperty(ASYNC_EXECUTOR_FACTORY, DefaultAsyncExecutorFactory.class.getName()); }
public int getConnectTimeout() { return props.getIntProperty(CONNECT_TIMEOUT, DEFAULT_CONNECT_TIMEOUT); }
public int getDefaultExecutorFactoryQueueSize() { return props.getIntProperty(DEFAULT_EXECUTOR_FACTORY_QUEUE_SIZE, 10000); }
public boolean getUseSSL() { return props.getBooleanProperty(USE_SSL, false); }
public String getMarshaller() { return props.getProperty(MARSHALLER, GenericJBossMarshaller.class.getName()); }