List of usage examples for java.util Dictionary get
public abstract V get(Object key);
From source file:org.sdntest.app.SDNTest.java
/** * Check property name is defined and set to true. * * @param properties properties to be looked up * @param propertyName the name of the property to look up * @return true when the propertyName is defined and set to true *///w w w. ja v a 2s. com private static boolean isPropertyEnabled(Dictionary<?, ?> properties, String propertyName) { boolean enabled = false; try { String flag = (String) properties.get(propertyName); if (flag != null) { enabled = flag.trim().equals("true"); } } catch (ClassCastException e) { // No propertyName defined. enabled = false; } return enabled; }
From source file:edu.northwestern.bioinformatics.studycalendar.osgi.felixcm.internal.PscFelixPersistenceManagerTest.java
public void testLoadFiltersOutBundleLocation() throws Exception { String pid = "edu.nwu.psc.thoughts"; Map<String, Object> inDb = getJdbcTemplate().queryForMap( "SELECT id FROM osgi_cm_properties WHERE name=? AND service_pid=?", new Object[] { BUNDLE_LOCATION_PROPERTY, pid }); // The inferred type for ID is different for oracle vs. others assertEquals("Test setup failure", -101, ((Number) inDb.get("ID")).intValue()); Dictionary loaded = manager.load(pid); assertNull("Bundle location present", loaded.get(BUNDLE_LOCATION_PROPERTY)); assertEquals("Wrong loaded contents", 1, loaded.size()); }
From source file:io.wcm.devops.conga.plugins.sling.postprocessor.ProvisioningOsgiConfigPostProcessorTest.java
@Test public void testSimpleConfig() throws Exception { final String PROVISIONING_FILE = "[feature name=test]\n" + "[configurations]\n" + "com.example.ServiceConfiguration\n" + " bar=\"bar\"" + " foo=\"foo\""; // post process provisioning example File provisioningFile = new File(targetDir, "simpleConfig.txt"); FileUtils.write(provisioningFile, PROVISIONING_FILE, StandardCharsets.UTF_8); postProcess(provisioningFile);//from w w w. j av a 2 s . co m // validate generated configs Dictionary<?, ?> config = readConfig("com.example.ServiceConfiguration.config"); assertEquals("bar", config.get("bar")); assertEquals("foo", config.get("foo")); }
From source file:org.openhab.io.transport.cul.CULLifecycleManager.java
public void config(Dictionary<String, ?> allConfig) throws ConfigurationException { if (allConfig != null) { String deviceName = (String) allConfig.get(KEY_DEVICE_NAME); if (StringUtils.isEmpty(deviceName)) { throw new ConfigurationException(KEY_DEVICE_NAME, "The device name can't be empty"); }/*from www . j a v a 2 s . c om*/ Matcher deviceMatcher = DEVICE_PATTERN.matcher(deviceName); if (!deviceMatcher.matches()) { throw new ConfigurationException(KEY_DEVICE_NAME, "Invalid device name '" + deviceName + "'. Must be 'DEVICETYPE:ADDRESS'"); } String deviceType = deviceMatcher.group("type"); CULConfigFactory configFactory = culManager.getConfigFactory(deviceType); if (configFactory == null) { throw new ConfigurationException(KEY_DEVICE_NAME, "Invalid device type '" + deviceType + "'"); } String deviceAddress = deviceMatcher.group("address"); config = configFactory.create(deviceType, deviceAddress, mode, allConfig); open(); } }
From source file:org.openhab.action.pushbullet.internal.PushbulletActionService.java
/** * @{inheritDoc}/*from ww w . ja v a2 s . c o m*/ */ @Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { if (config != null) { String defaultAccessToken = Objects.toString(config.get(ACCESS_TOKEN_KEY), null); String botNames = Objects.toString(config.get(BOTS_KEY), null); if (StringUtils.isNotEmpty(botNames)) { String[] bots = botNames.split(","); for (String botName : bots) { botName = botName.trim(); String accessTokenKey = String.format("%s.%s", botName, ACCESS_TOKEN_KEY); String accessToken = Objects.toString(config.get(accessTokenKey), defaultAccessToken); PushbulletAPIConnector.addBot(botName, accessToken); } } // Now, try to configure the default bot just in case we have older configuration around PushbulletAPIConnector.addBot(DEFAULT_BOTNAME, defaultAccessToken); PushbulletAPIConnector.logPushbulletBots(); if (PushbulletAPIConnector.botCount() > 0) { isProperlyConfigured = true; } } logger.debug("Parsing configuration done, configuration is {}", isProperlyConfigured); }
From source file:org.openhab.io.net.actions.Prowl.java
@SuppressWarnings("rawtypes") public void updated(Dictionary config) throws ConfigurationException { if (config != null) { Prowl.url = (String) config.get("url"); Prowl.apiKey = (String) config.get("apikey"); if (StringUtils.isBlank(Prowl.apiKey)) { throw new ConfigurationException("prowl.apikey", "The parameter 'apikey' must be configured. Please refer to your 'openhab.cfg'"); }//w w w. j a va 2s . c o m String priorityString = (String) config.get("defaultpriority"); if (StringUtils.isNotBlank(priorityString)) { Prowl.priority = Integer.valueOf(priorityString); } initialized = true; } }
From source file:org.openhab.io.servicediscovery.internal.DiscoveryServiceImpl.java
@Override public void updated(Dictionary<String, ?> config) throws ConfigurationException { try {// w w w. ja va 2 s. co m if (config != null) { String bindAddress = (String) config.get("bind_address"); if (bindAddress != null && StringUtils.isNotBlank(bindAddress)) { jmdns = JmDNS.create(InetAddress.getByName(bindAddress)); logger.info("Service Discovery initialization completed (bound to address: {}).", bindAddress); return; } } jmdns = JmDNS.create(); logger.info("Service Discovery initialization completed."); } catch (IOException e) { logger.error(e.getMessage()); } }
From source file:com.liferay.frontend.theme.contributor.extender.internal.ThemeContributorExtender.java
private String _getProperty(Bundle bundle, String headerName, String jsonName) { Dictionary<String, String> headers = bundle.getHeaders(); String type = headers.get(headerName); if (type == null) { URL entryURL = bundle.getEntry("/package.json"); if (entryURL != null) { try (Reader reader = new InputStreamReader(entryURL.openStream())) { JSONTokener jsonTokener = new JSONTokener(reader); JSONObject packageJsonObject = new JSONObject(jsonTokener); JSONObject liferayThemeJSONObject = packageJsonObject.optJSONObject("liferayTheme"); if (liferayThemeJSONObject != null) { type = liferayThemeJSONObject.getString(jsonName); }// www .j ava 2s. c o m } catch (IOException ioe) { throw new RuntimeException(ioe); } } } return type; }
From source file:org.ops4j.pax.web.itest.jetty.WarFormAuthIntegrationTest.java
/** * You will get a list of bundles installed by default plus your testcase, * wrapped into a bundle called pax-exam-probe *///from w ww.ja va2 s. co m @Test public void listBundles() { for (Bundle b : bundleContext.getBundles()) { if (b.getState() != Bundle.ACTIVE && b.getState() != Bundle.RESOLVED) { fail("Bundle should be active: " + b); } Dictionary<String, String> headers = b.getHeaders(); String ctxtPath = (String) headers.get(WEB_CONTEXT_PATH); if (ctxtPath != null) { System.out.println("Bundle " + b.getBundleId() + " : " + b.getSymbolicName() + " : " + ctxtPath); } else { System.out.println( "Bundle " + b.getBundleId() + " : " + b.getSymbolicName() + " state = " + b.getState()); } } }
From source file:org.ops4j.pax.web.itest.jetty.WarJSFPrimefacesIntegrationTest.java
/** * You will get a list of bundles installed by default plus your testcase, * wrapped into a bundle called pax-exam-probe *///ww w . j av a 2 s . c o m // @Test public void listBundles() { for (final Bundle b : bundleContext.getBundles()) { if (b.getState() != Bundle.ACTIVE) { fail("Bundle should be active: " + b); } final Dictionary<?, ?> headers = b.getHeaders(); final String ctxtPath = (String) headers.get(WEB_CONTEXT_PATH); if (ctxtPath != null) { System.out.println("Bundle " + b.getBundleId() + " : " + b.getSymbolicName() + " : " + ctxtPath); } else { System.out.println("Bundle " + b.getBundleId() + " : " + b.getSymbolicName()); } } }