Config config = Config.getInstance(getServletContext()); String property = config.getProperty("somekey");
@Override public String getProperty(String name) { return staticConfig.getProperty(name); }
@Override public String getProperty(String name) { return staticConfig.getProperty(name); }
Config config = Config.getInstance(getApplicationContext()); config.getProperty(...);
enum SingleService { INSTANCE; private String conn; private String user; private String pass; private SingleService instance; public synchronized void init(Config config) throws SomeException { // don't leave in a half state if we fail. internalService = null; conn = config.getProperty("conn"); user = config.getProperty("user"); pass = config.getProperty("pass"); internalService = tryConnect(conn, user, pass); } public synchronized void methodForService() { if (internalService == null) throw new IllegalSateException(); // do work. } }
public class MyServlet extends HttpServlet { protected Config config = new Config(); @Override public void doGet(request, response) throws ServletException{ Strign s = config.getProperty("myParam"); } }
private AddressDefinition getSystemConfiguredAddress() throws UnknownHostException { String address = config.getProperty("hazelcast.local.localAddress"); if (address != null) { address = address.trim(); if ("127.0.0.1".equals(address) || "localhost".equals(address)) { return pickLoopbackAddress(address); } else { logger.info("Picking address configured by property 'hazelcast.local.localAddress'"); return new AddressDefinition(address, InetAddress.getByName(address)); } } return null; }
private AddressDefinition getSystemConfiguredAddress() throws UnknownHostException { String address = config.getProperty("hazelcast.local.localAddress"); if (address != null) { address = address.trim(); if ("127.0.0.1".equals(address) || "localhost".equals(address)) { return pickLoopbackAddress(address); } else { logger.info("Picking address configured by property 'hazelcast.local.localAddress'"); return new AddressDefinition(address, InetAddress.getByName(address)); } } return null; }
public static long getMaxOperationTimeout(final HazelcastInstance instance) { String maxOpTimeoutProp = null; try { Config config = instance.getConfig(); maxOpTimeoutProp = config.getProperty(CacheEnvironment.HAZELCAST_OPERATION_TIMEOUT); } catch (UnsupportedOperationException e) { // HazelcastInstance is instance of HazelcastClient. Logger.getLogger(HazelcastTimestamper.class).finest(e); } if (maxOpTimeoutProp != null) { return Long.parseLong(maxOpTimeoutProp); } return Long.MAX_VALUE; } }
public static long getMaxOperationTimeout(final HazelcastInstance instance) { String maxOpTimeoutProp = null; try { Config config = instance.getConfig(); maxOpTimeoutProp = config.getProperty(CacheEnvironment.HAZELCAST_OPERATION_TIMEOUT); } catch (UnsupportedOperationException e) { // HazelcastInstance is instance of HazelcastClient. Logger.getLogger(HazelcastTimestamper.class).finest(e); } if (maxOpTimeoutProp != null) { return Long.parseLong(maxOpTimeoutProp); } return Long.MAX_VALUE; } }
public static long getMaxOperationTimeout(HazelcastInstance instance) { String maxOpTimeoutProp = null; try { Config config = instance.getConfig(); maxOpTimeoutProp = config.getProperty(CacheEnvironment.HAZELCAST_OPERATION_TIMEOUT); } catch (UnsupportedOperationException e) { // HazelcastInstance is instance of HazelcastClient. Logger.getLogger(HazelcastTimestamper.class).finest(e); } if (maxOpTimeoutProp != null) { return Long.parseLong(maxOpTimeoutProp); } return Long.MAX_VALUE; } }
public static long getMaxOperationTimeout(final HazelcastInstance instance) { String maxOpTimeoutProp = null; try { Config config = instance.getConfig(); maxOpTimeoutProp = config.getProperty(CacheEnvironment.HAZELCAST_OPERATION_TIMEOUT); } catch (UnsupportedOperationException e) { // HazelcastInstance is instance of HazelcastClient. Logger.getLogger(HazelcastTimestamper.class).finest(e); } if (maxOpTimeoutProp != null) { return Long.parseLong(maxOpTimeoutProp); } return Long.MAX_VALUE; } }
private AddressDefinition getPublicAddress(int port) throws UnknownHostException { String address = config.getProperty("hazelcast.local.publicAddress"); if (address == null) { address = config.getNetworkConfig().getPublicAddress(); } if (address != null) { address = address.trim(); if ("127.0.0.1".equals(address) || "localhost".equals(address)) { return pickLoopbackAddress(address, port); } else { // allow port to be defined in same string in the form of <host>:<port>, e.g. 10.0.0.0:1234 AddressUtil.AddressHolder holder = AddressUtil.getAddressHolder(address, port); return new AddressDefinition(holder.getAddress(), holder.getPort(), InetAddress.getByName(holder.getAddress())); } } return null; }
private AddressDefinition getPublicAddress(int port) throws UnknownHostException { String address = config.getProperty("hazelcast.local.publicAddress"); if (address == null) { address = config.getNetworkConfig().getPublicAddress(); } if (address != null) { address = address.trim(); if ("127.0.0.1".equals(address) || "localhost".equals(address)) { return pickLoopbackAddress(address, port); } else { // allow port to be defined in same string in the form of <host>:<port>, e.g. 10.0.0.0:1234 AddressUtil.AddressHolder holder = AddressUtil.getAddressHolder(address, port); return new AddressDefinition(holder.getAddress(), holder.getPort(), InetAddress.getByName(holder.getAddress())); } } return null; }
public ConfigCheck(Config config, String joinerType) { this.joinerType = joinerType; // Copying all properties relevant for checking properties.put(PARTITION_COUNT.getName(), config.getProperty(PARTITION_COUNT.getName())); properties.put(APPLICATION_VALIDATION_TOKEN.getName(), config.getProperty(APPLICATION_VALIDATION_TOKEN.getName())); // Copying group-config settings GroupConfig groupConfig = config.getGroupConfig(); if (groupConfig != null) { this.groupName = groupConfig.getName(); } // Partition-group settings final PartitionGroupConfig partitionGroupConfig = config.getPartitionGroupConfig(); if (partitionGroupConfig != null) { partitionGroupEnabled = partitionGroupConfig.isEnabled(); if (partitionGroupEnabled) { memberGroupType = partitionGroupConfig.getGroupType(); } else { memberGroupType = PartitionGroupConfig.MemberGroupType.PER_MEMBER; } } }
public ConfigCheck(Config config, String joinerType) { this.joinerType = joinerType; // Copying all properties relevant for checking properties.put(PARTITION_COUNT.getName(), config.getProperty(PARTITION_COUNT.getName())); properties.put(APPLICATION_VALIDATION_TOKEN.getName(), config.getProperty(APPLICATION_VALIDATION_TOKEN.getName())); // Copying group-config settings GroupConfig groupConfig = config.getGroupConfig(); if (groupConfig != null) { this.groupName = groupConfig.getName(); } // Partition-group settings final PartitionGroupConfig partitionGroupConfig = config.getPartitionGroupConfig(); if (partitionGroupConfig != null) { partitionGroupEnabled = partitionGroupConfig.isEnabled(); if (partitionGroupEnabled) { memberGroupType = partitionGroupConfig.getGroupType(); } else { memberGroupType = PartitionGroupConfig.MemberGroupType.PER_MEMBER; } } }