List of usage examples for java.util Dictionary get
public abstract V get(Object key);
From source file:org.openhab.binding.whistle.internal.WhistleBinding.java
@Override @SuppressWarnings("rawtypes") public void updated(Dictionary config) throws ConfigurationException { if (config != null) { String usernameString = (String) config.get("username"); if (StringUtils.isNotBlank(usernameString)) { username = usernameString;/*from w ww . ja v a 2s. co m*/ } String passwordString = (String) config.get("password"); if (StringUtils.isNotBlank(passwordString)) { password = passwordString; } String refreshIntervalString = (String) config.get("refresh"); if (StringUtils.isNotBlank(refreshIntervalString)) { refreshInterval = Long.parseLong(refreshIntervalString); } setProperlyConfigured(true); logger.debug("Loaded configuration - '" + username + "', refresh: '" + refreshInterval + "'"); } }
From source file:org.eclipse.virgo.medic.impl.LogController.java
private synchronized void updateLogConfiguration(Dictionary<String, Object> configuration) { String logSysOutConfiguration = (String) configuration.get(ConfigurationProvider.KEY_LOG_WRAP_SYSOUT); if (Boolean.valueOf(logSysOutConfiguration)) { delegatingSysOutRegistration = publishDelegatingPrintStream(delegatingSysOut, LOGGER_NAME_SYSOUT_DELEGATE); sysOutRegistration = publishPrintStream(this.sysOut, LOGGER_NAME_SYSOUT); System.setOut(wrapPrintStream(System.out, LOGGER_NAME_SYSOUT, LoggingLevel.INFO, stackAccessor, configurationProvider, ConfigurationProvider.KEY_LOG_WRAP_SYSOUT)); } else {//from w w w. j a v a 2 s . c o m if (Boolean.FALSE.toString().equals(logSysOutConfiguration)) { if (delegatingSysOutRegistration != null) { registrationTracker.unregister(delegatingSysOutRegistration); delegatingSysOutRegistration = null; } if (sysOutRegistration != null) { registrationTracker.unregister(sysOutRegistration); sysOutRegistration = null; } System.setOut((PrintStream) delegatingSysOut); } else { delegatingSysOutRegistration = publishDelegatingPrintStream(delegatingSysOut, LOGGER_NAME_SYSOUT_DELEGATE); sysOutRegistration = publishPrintStream(this.sysOut, LOGGER_NAME_SYSOUT); System.setOut(decoratePrintStream(System.out, LOGGER_NAME_SYSOUT, LoggingLevel.INFO, stackAccessor, configurationProvider, ConfigurationProvider.KEY_LOG_WRAP_SYSOUT)); if (!ConfigurationProvider.LOG_TEE_SYSSTREAMS.equals(logSysOutConfiguration)) { System.out.println("Invalid value '" + logSysOutConfiguration + "' for configuration key '" + ConfigurationProvider.KEY_LOG_WRAP_SYSOUT + "'. Valid values are 'true | tee | false'. Defaulted to 'tee'."); } } } String logSysErrConfiguration = (String) configuration.get(ConfigurationProvider.KEY_LOG_WRAP_SYSERR); if (Boolean.valueOf(logSysErrConfiguration)) { delegatingSysErrRegistration = publishDelegatingPrintStream(delegatingSysErr, LOGGER_NAME_SYSERR_DELEGATE); sysErrRegistration = publishPrintStream(this.sysErr, LOGGER_NAME_SYSERR); System.setErr(wrapPrintStream(System.err, LOGGER_NAME_SYSERR, LoggingLevel.ERROR, stackAccessor, configurationProvider, ConfigurationProvider.KEY_LOG_WRAP_SYSERR)); } else { if (Boolean.FALSE.toString().equals(logSysErrConfiguration)) { if (delegatingSysErrRegistration != null) { registrationTracker.unregister(delegatingSysErrRegistration); delegatingSysErrRegistration = null; } if (sysErrRegistration != null) { registrationTracker.unregister(sysErrRegistration); sysErrRegistration = null; } System.setErr((PrintStream) delegatingSysErr); } else { delegatingSysErrRegistration = publishDelegatingPrintStream(delegatingSysErr, LOGGER_NAME_SYSERR_DELEGATE); sysErrRegistration = publishPrintStream(this.sysErr, LOGGER_NAME_SYSERR); System.setErr(decoratePrintStream(System.err, LOGGER_NAME_SYSERR, LoggingLevel.ERROR, stackAccessor, configurationProvider, ConfigurationProvider.KEY_LOG_WRAP_SYSERR)); if (!ConfigurationProvider.LOG_TEE_SYSSTREAMS.equals(logSysErrConfiguration)) { System.err.println("Invalid value '" + logSysErrConfiguration + "' for configuration key '" + ConfigurationProvider.KEY_LOG_WRAP_SYSERR + "'. Valid values are 'true | tee | false'. Defaulted to 'tee'."); } } } if (Boolean.valueOf((String) configuration.get(ConfigurationProvider.KEY_ENABLE_JUL_CONSOLE_HANDLER))) { enableJulConsoleLogger(); } else { disableJulConsoleHandler(); } }
From source file:org.openhab.binding.hms.internal.HMSBinding.java
@Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { if (config != null) { // to override the default refresh interval one has to add a // parameter to openhab.cfg like // <bindingName>:refresh=<intervalInMs> String refreshIntervalString = (String) config.get("refresh"); if (StringUtils.isNotBlank(refreshIntervalString)) { refreshInterval = Long.parseLong(refreshIntervalString); }/* ww w. jav a 2 s .c o m*/ String deviceName = (String) config.get(KEY_DEVICE_NAME); if (StringUtils.isEmpty(deviceName)) { logger.error("No device name configured"); setProperlyConfigured(false); throw new ConfigurationException(KEY_DEVICE_NAME, "The device name can't be empty"); } else { setNewDeviceName(deviceName); } setProperlyConfigured(true); } }
From source file:org.openhab.binding.nikobus.internal.NikobusBinding.java
/** * Update the configuration.//from ww w.java 2 s.c om */ public void updated(Dictionary<String, ?> config) throws ConfigurationException { if (config != null) { String configuredSerialPort = (String) config.get("serial.port"); if (StringUtils.isNotBlank(configuredSerialPort)) { log.trace("Setting serial port to {}", configuredSerialPort); serialInterface.setPort(configuredSerialPort); } String configuredInterval = (String) config.get("refresh"); if (StringUtils.isNotBlank(configuredInterval)) { refreshInterval = Long.parseLong(configuredInterval); log.trace("Setting refresh interval to {}", refreshInterval); startRefreshScheduler(); } connect(); } }
From source file:com.activecq.tools.auth.impl.CookieAuthenticationImpl.java
@SuppressWarnings("unchecked") protected void activate(ComponentContext componentContext) { Dictionary properties = componentContext.getProperties(); encryptionType = PropertiesUtil.toString(properties.get(PROP_ENCRYPTION_TYPE), DEFAULT_ENCRYPTION_TYPE); cookieName = PropertiesUtil.toString(properties.get(PROP_COOKIE_NAME), DEFAULT_COOKIE_NAME); cookiePath = PropertiesUtil.toString(properties.get(PROP_COOKIE_PATH), DEFAULT_COOKIE_PATH); cookieEncoding = PropertiesUtil.toString(properties.get(PROP_COOKIE_ENCODING), DEFAULT_COOKIE_ENCODING); secret = PropertiesUtil.toString(properties.get(PROP_COOKIE_SECRET), DEFAULT_COOKIE_SECRET); cookieExpiry = PropertiesUtil.toInteger(properties.get(PROP_COOKIE_EXPIRY), DEFAULT_COOKIE_EXPIRY); final long cookieRememberMeExpiryL = PropertiesUtil.toLong(properties.get(PROP_COOKIE_REMEMBER_ME_EXPIRY), DEFAULT_REMEMBER_ME_COOKIE_EXPIRY); cookieRememberMeExpiry = (int) (cookieRememberMeExpiryL * 86400); // Seconds in a day rememberMe = OsgiPropertyUtil//from w ww.ja v a2 s . c om .toSimpleEntry(PropertiesUtil.toString(properties.get(PROP_REMEMBER_ME), "remember-me"), ":"); }
From source file:datasource.BasicDataSourceProvider.java
/** * Perform a registration for a specific PID. The properties specified are converted to settings * on a basic datasource and that one is registered in the service registry for later handling. * Note that no checking is done on validation of properties, they are parsed as is. * /*from w w w. ja v a2 s. c o m*/ * @param pid The managed service pid * @param properties The properties of the pid */ synchronized void registration(String pid, Dictionary<String, ?> properties) { deleted(pid); Hashtable<String, Object> dict = new Hashtable<>(); Enumeration<String> enumeration = properties.keys(); T source = getDataSource(); source.setMaxWait(10000L); while (enumeration.hasMoreElements()) { String key = enumeration.nextElement(); Object value = properties.get(key); // Check the values. if (key.equals("jdbc.driver")) { source.setDriverClassName(value.toString()); } else if (key.equals("jdbc.user")) { source.setUsername(value.toString()); } else if (key.equals("jdbc.password")) { source.setPassword(value.toString()); } else if (key.equals("jdbc.url")) { source.setUrl(value.toString()); } else if (key.equals("validation.query")) { source.setValidationQuery(value.toString()); } else if (key.equals("validation.timeout")) { source.setValidationQueryTimeout(Integer.parseInt(value.toString())); } else if (key.equals("pool.idle.min")) { source.setMinIdle(Integer.parseInt(value.toString())); } else if (key.equals("pool.idle.max")) { source.setMaxIdle(Integer.parseInt(value.toString())); } else if (key.equals("pool.wait")) { source.setMaxWait(Long.parseLong(value.toString())); } else if (key.equals("pool.active.max")) { source.setMaxActive(Integer.parseInt(value.toString())); } else { dict.put(key, value); } } // Got it. Create the registration for it. ServiceRegistration<DataSource> sr = FrameworkUtil.getBundle(getClass()).getBundleContext() .registerService(DataSource.class, source, dict); registrations.put(pid, new Registration<>(source, sr)); }
From source file:org.openhab.binding.koubachi.internal.KoubachiBinding.java
@Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { if (config != null) { String refreshIntervalString = (String) config.get("refresh"); if (StringUtils.isNotBlank(refreshIntervalString)) { refreshInterval = Long.parseLong(refreshIntervalString); }/*from w ww . j a v a 2s . c om*/ String apiDeviceUrlString = (String) config.get("deviceurl"); if (StringUtils.isNotBlank(apiDeviceUrlString)) { apiDeviceListUrl = apiDeviceUrlString; } String apiPlantUrlString = (String) config.get("planturl"); if (StringUtils.isNotBlank(apiPlantUrlString)) { apiPlantListUrl = apiPlantUrlString; } String apiTasksUrlString = (String) config.get("tasksurl"); if (StringUtils.isNotBlank(apiTasksUrlString)) { apiTasksUrl = apiTasksUrlString; } credentials = (String) config.get("credentials"); if (StringUtils.isBlank(credentials)) { throw new ConfigurationException("koubachi:credentials", "Users' credentials parameter must be set"); } appKey = (String) config.get("appkey"); if (StringUtils.isBlank(appKey)) { throw new ConfigurationException("koubachi:appkey", "AppKey parameter must be set"); } setProperlyConfigured(true); } }
From source file:org.opencastproject.silencedetection.impl.SilenceDetectionServiceImpl.java
@Override public void updated(Dictionary properties) throws ConfigurationException { this.properties = new Properties(); Enumeration keys = properties.keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); this.properties.put(key, properties.get(key)); }//from w ww . j a v a 2 s. com logger.debug("Properties updated!"); }
From source file:org.openhab.binding.em.internal.EMBinding.java
/** * @{inheritDoc/*from w w w . j a va2 s . com*/ */ @Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { if (config != null) { // to override the default refresh interval one has to add a // parameter to openhab.cfg like // <bindingName>:refresh=<intervalInMs> String refreshIntervalString = (String) config.get("refresh"); if (StringUtils.isNotBlank(refreshIntervalString)) { refreshInterval = Long.parseLong(refreshIntervalString); } String deviceName = (String) config.get(CONFIG_KEY_DEVICE_NAME); if (!StringUtils.isEmpty(deviceName)) { setNewDeviceName(deviceName); } else { setProperlyConfigured(false); throw new ConfigurationException(CONFIG_KEY_DEVICE_NAME, "Device name not configured"); } setProperlyConfigured(true); } }
From source file:org.openhab.binding.exec.internal.ExecBinding.java
@Override @SuppressWarnings("rawtypes") public void updated(Dictionary config) throws ConfigurationException { if (config != null) { String timeoutString = (String) config.get("timeout"); if (StringUtils.isNotBlank(timeoutString)) { timeout = Integer.parseInt(timeoutString); }//from w w w. ja v a 2 s . c o m String granularityString = (String) config.get("granularity"); if (StringUtils.isNotBlank(granularityString)) { granularity = Integer.parseInt(granularityString); } } }