List of usage examples for java.util Dictionary get
public abstract V get(Object key);
From source file:com.activecq.tools.errorpagehandler.impl.ErrorPageHandlerImpl.java
private void configure(ComponentContext componentContext) { Dictionary properties = componentContext.getProperties(); this.enabled = PropertiesUtil.toBoolean(properties.get(PROP_ENABLED), DEFAULT_ENABLED); this.systemErrorPagePath = PropertiesUtil.toString(properties.get(PROP_ERROR_PAGE_PATH), DEFAULT_SYSTEM_ERROR_PAGE_PATH_DEFAULT); this.errorPageExtension = PropertiesUtil.toString(properties.get(PROP_ERROR_PAGE_EXTENSION), DEFAULT_ERROR_PAGE_EXTENSION); this.fallbackErrorName = PropertiesUtil.toString(properties.get(PROP_FALLBACK_ERROR_NAME), DEFAULT_FALLBACK_ERROR_NAME); this.pathMap = configurePathMap( PropertiesUtil.toStringArray(properties.get(PROP_SEARCH_PATHS), DEFAULT_SEARCH_PATHS)); }
From source file:org.openhab.binding.jointspace.internal.JointSpaceBinding.java
/** * @{inheritDoc/*from w w w . j av a 2 s . c o m*/ */ @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("refreshinterval"); if (StringUtils.isNotBlank(refreshIntervalString)) { refreshInterval = Long.parseLong(refreshIntervalString); } String ipString = (String) config.get("ip"); if (StringUtils.isNotBlank(ipString)) { ip = ipString; setProperlyConfigured(true); } String portString = (String) config.get("port"); if (StringUtils.isNotBlank(portString)) { port = portString; } } }
From source file:org.opencastproject.videosegmenter.impl.VideoSegmenterServiceImpl.java
/** * {@inheritDoc}/* w w w.j a v a 2s . co m*/ * * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary) */ @SuppressWarnings("unchecked") @Override public void updated(Dictionary properties) throws ConfigurationException { logger.debug("Configuring the videosegmenter"); // Stability threshold if (properties.get(OPT_STABILITY_THRESHOLD) != null) { String threshold = (String) properties.get(OPT_STABILITY_THRESHOLD); try { stabilityThreshold = Integer.parseInt(threshold); logger.info("Stability threshold set to {} consecutive frames", stabilityThreshold); } catch (Exception e) { logger.warn("Found illegal value '{}' for videosegmenter's stability threshold", threshold); } } // Changes threshold if (properties.get(OPT_CHANGES_THRESHOLD) != null) { String threshold = (String) properties.get(OPT_CHANGES_THRESHOLD); try { changesThreshold = Float.parseFloat(threshold); logger.info("Changes threshold set to {}", changesThreshold); } catch (Exception e) { logger.warn("Found illegal value '{}' for videosegmenter's changes threshold", threshold); } } }
From source file:ddf.common.test.ServiceManager.java
public void printInactiveBundles() { LOGGER.info("Listing inactive bundles"); for (Bundle bundle : getBundleContext().getBundles()) { if (bundle.getState() != Bundle.ACTIVE) { StringBuffer headerString = new StringBuffer("[ "); Dictionary<String, String> headers = bundle.getHeaders(); Enumeration<String> keys = headers.keys(); while (keys.hasMoreElements()) { String key = keys.nextElement(); headerString.append(key).append("=").append(headers.get(key)).append(", "); }// w w w. ja v a2 s.co m headerString.append(" ]"); LOGGER.info("{} | {} | {} | {}", bundle.getSymbolicName(), bundle.getVersion().toString(), OsgiStringUtils.bundleStateAsString(bundle), headerString.toString()); } } }
From source file:org.openengsb.core.test.AbstractOsgiMockServiceTest.java
@SuppressWarnings("unchecked") private ServiceRegistration<?> registerServiceInBundlecontext(String[] clazzes, final Object service, Dictionary<String, Object> dict) { dict.put(Constants.OBJECTCLASS, clazzes); final ServiceReference<?> serviceReference = putService(service, dict); ServiceRegistration<?> result = mock(ServiceRegistration.class); // unregistering removes the service from both maps doAnswer(new Answer<Void>() { @Override//from ww w . j a v a 2s. c o m public Void answer(InvocationOnMock invocation) throws Throwable { synchronized (services) { services.remove(serviceReference); } synchronized (serviceReferences) { Dictionary<String, Object> props = serviceReferences.remove(serviceReference); updateServiceListeners(ServiceEvent.UNREGISTERING, serviceReference, props); return null; } } }).when(result).unregister(); // when properties are replaced, place a copy of the new properties-dictionary in the // serviceReferences-map (that overwrites the old dictionary) doAnswer(new Answer<Void>() { @Override public Void answer(InvocationOnMock invocation) throws Throwable { Dictionary<String, Object> arg = (Dictionary<String, Object>) invocation.getArguments()[0]; Dictionary<String, Object> newDict = new Hashtable<String, Object>(); Enumeration<String> keys = arg.keys(); while (keys.hasMoreElements()) { String next = keys.nextElement(); newDict.put(next, arg.get(next)); } synchronized (serviceReferences) { serviceReferences.put(serviceReference, newDict); } return null; } }).when(result).setProperties(any(Dictionary.class)); when(result.getReference()).thenAnswer(new ValueAnswer<ServiceReference<?>>(serviceReference)); updateServiceListeners(ServiceEvent.REGISTERED, serviceReference, dict); return result; }
From source file:org.opencastproject.usertracking.impl.UserTrackingServiceImpl.java
@Override public void updated(Dictionary props) throws ConfigurationException { if (props == null) { logger.debug("Null properties in user tracking service, not doing detailed logging"); return;/*from ww w . ja va 2 s .c o m*/ } Object val = props.get("org.opencastproject.usertracking.detailedtrack"); if (val != null && String.class.isInstance(val)) { detailedTracking = Boolean.valueOf((String) val); } }
From source file:org.openhab.binding.maxcul.internal.MaxCulBinding.java
private Map<String, Object> convertDictionaryToMap(Dictionary<String, ?> config) { Map<String, Object> myMap = new HashMap<String, Object>(); if (config == null) { return null; }/* www. ja va2 s. com*/ if (config.size() == 0) { return myMap; } Enumeration<String> allKeys = config.keys(); while (allKeys.hasMoreElements()) { String key = allKeys.nextElement(); myMap.put(key, config.get(key)); } return myMap; }
From source file:org.openhab.binding.freebox.internal.FreeboxBinding.java
/** * @{inheritDoc}//ww w.jav a 2 s .c om */ @Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { if (config != null) { setProperlyConfigured(false); deviceName = (String) config.get("device"); if (isBlank(deviceName)) { // The only mandatory parameter is tested first throw new ConfigurationException("freebox", "The parameter 'device' is missing! Please refer to your 'openhab.cfg'"); } String refreshConfig = (String) config.get("refresh"); if (!isBlank(refreshConfig)) { refreshInterval = Long.parseLong(refreshConfig); } serverAddress = (String) config.get("server"); if (isBlank(serverAddress)) serverAddress = "mafreebox.freebox.fr"; appToken = (String) config.get("apptoken"); try { authorize(); } catch (FreeboxException e) { logger.info(e.getMessage()); } setProperlyConfigured((loginManager != null) && loginManager.isConnected()); logger.info("Freebox binding " + (isProperlyConfigured() ? "" : "not ") + "properly configured"); } }
From source file:com.whizzosoftware.hobson.venstar.ColorTouchPlugin.java
@Override public void onStartup(Dictionary config) { addConfigurationPropertyMetaData(new ConfigurationPropertyMetaData("thermostat.host", "Thermostat Host", "The hostname or IP address of a ColorTouch thermostat", ConfigurationPropertyMetaData.Type.STRING)); // set to running status setStatus(new PluginStatus(PluginStatus.Status.RUNNING)); // request SSDP device advertisements events that occurred before this plugin started requestDeviceAdvertisementSnapshot(SSDPPacket.PROTOCOL_ID); // check if a thermostat has been manually configured addManualHostIfNotDiscovered((String) config.get(PROP_THERMOSTAT_HOST)); }
From source file:org.apache.felix.webconsole.internal.servlet.OsgiManager.java
/** * Returns the named property from the configuration. If the property does * not exist, the default value <code>def</code> is returned. * * @param config The properties from which to returned the named one * @param name The name of the property to return * @param def The default value if the named property does not exist * @return The value of the named property as a string or <code>def</code> * if the property does not exist */// w ww. ja v a2s. c om private String getProperty(Dictionary config, String name, String def) { Object value = config.get(name); if (value instanceof String) { return (String) value; } if (value == null) { return def; } return String.valueOf(value); }