Example usage for java.util Dictionary get

List of usage examples for java.util Dictionary get

Introduction

In this page you can find the example usage for java.util Dictionary get.

Prototype

public abstract V get(Object key);

Source Link

Document

Returns the value to which the key is mapped in this dictionary.

Usage

From source file:de.iew.stagediver.fx.database.provider.impl.HSQLDBProvider.java

@Override
public void configure(Dictionary<String, ?> properties) {
    // We don't predefine any defaults here. It's up to the factory to create and initialise the provider in the
    // correct way.
    this.databaseBackend = (String) properties.get(DATABASE_BACKEND);
    this.databasePath = (String) properties.get(DATABASE_PATH);
    this.driverClass = (String) properties.get(DRIVER_CLASS);
}

From source file:org.opencastproject.adminui.impl.AdminUIConfiguration.java

@Override
public void updated(Dictionary properties) throws ConfigurationException {
    if (properties == null)
        return;//  ww w . ja  v  a 2  s  . com

    // Preview subtype
    String preview = StringUtils.trimToNull((String) properties.get(OPT_PREVIEW_SUBTYPE));
    if (preview != null) {
        previewSubtype = preview;
        logger.info("Preview subtype is '{}'", previewSubtype);
    } else {
        logger.warn("No preview subtype configured, using '{}'", previewSubtype);
    }

    // Waveform subtype
    String waveform = StringUtils.trimToNull((String) properties.get(OPT_WAVEFORM_SUBTYPE));
    if (waveform != null) {
        waveformSubtype = waveform;
        logger.info("Waveform subtype is '{}'", waveformSubtype);
    } else {
        logger.warn("No waveform subtype configured, using '{}'", waveformSubtype);
    }

    // SMIL catalog flavor
    String smilCatalog = StringUtils.trimToNull((String) properties.get(OPT_SMIL_CATALOG_FLAVOR));
    if (smilCatalog != null) {
        smilCatalogFlavor = MediaPackageElementFlavor.parseFlavor(smilCatalog);
        logger.info("Smil catalg flavor is '{}'", smilCatalogFlavor);
    } else {
        logger.warn("No smil catalog flavor configured, using '{}'", smilCatalogFlavor);
    }

    // SMIL catalog tags
    String[] smilCatalogTags = StringUtils.split((String) properties.get(OPT_SMIL_CATALOG_TAGS), ",");
    if (smilCatalogTags != null) {
        smilCatalogTagSet.clear();
        smilCatalogTagSet.addAll(Arrays.asList(smilCatalogTags));
        logger.info("Smil catalg tags are '{}'", StringUtils.join(smilCatalogTagSet, ","));
    } else {
        logger.warn("No smil catalog tags configured");
    }

    // SMIL silence flavor
    String smilSilence = StringUtils.trimToNull((String) properties.get(OPT_SMIL_SILENCE_FLAVOR));
    if (smilSilence != null) {
        smilSilenceFlavor = MediaPackageElementFlavor.parseFlavor(smilSilence);
        logger.info("Smil silence flavor is '{}'", smilSilenceFlavor);
    } else {
        logger.warn("No smil silence flavor configured, using '{}'", smilSilenceFlavor);
    }
}

From source file:org.openhab.binding.comfoair.internal.ComfoAirBinding.java

/**
 * {@inheritDoc}/*w  w w  . j  a v  a2 s  . c  om*/
 */
@SuppressWarnings("rawtypes")
public void updated(Dictionary config) throws ConfigurationException {

    if (config != null) {
        String newPort = (String) config.get("port"); //$NON-NLS-1$
        if (StringUtils.isNotBlank(newPort) && !newPort.equals(port)) {
            // only do something if the newPort has changed
            port = newPort;

            String refreshIntervalString = (String) config.get("refresh");
            if (StringUtils.isNotBlank(refreshIntervalString)) {
                refreshInterval = Long.parseLong(refreshIntervalString);
            }

            if (connector != null) {
                connector.close();
            }

            connector = new ComfoAirConnector();
            try {
                connector.open(port);
            } catch (InitializationException e) {
                logger.error(e.getMessage());
            }

            setProperlyConfigured(true);
        }
    }
}

From source file:edu.northwestern.bioinformatics.studycalendar.osgi.felixcm.internal.PscFelixPersistenceManagerTest.java

public void testStoreAsNew() throws Exception {
    String newPid = "edu.nwu.psc.numbers";
    {/* ww w . j a  va 2  s.c  o m*/
        Dictionary d = new Hashtable();
        d.put("aleph", (byte) 0);
        d.put("nature", new int[] { 2, 72 });
        d.put("pie", new Vector(Arrays.asList("chess", "key lime")));

        manager.store(newPid, d);
    }

    Dictionary loaded = manager.load(newPid);
    assertEquals("Wrong reloaded contents: " + loaded, 3, loaded.size());
    assertEquals("Missing aleph", (byte) 0, loaded.get("aleph"));

    assertTrue("Missing nature", loaded.get("nature") instanceof int[]);
    int[] actualNature = (int[]) loaded.get("nature");
    assertEquals("Wrong value 0 in nature", 2, actualNature[0]);
    assertEquals("Wrong value 1 in nature", 72, actualNature[1]);

    assertTrue("Missing pie", loaded.get("pie") instanceof Vector);
    List actualPie = (List) loaded.get("pie");
    assertEquals("Wrong value 0 in pie", "chess", actualPie.get(0));
    assertEquals("Wrong value 1 in pie", "key lime", actualPie.get(1));
}

From source file:org.openhab.binding.ehealth.internal.EHealthBinding.java

/**
 * @{inheritDoc}/*  w w  w.j  ava2s. c o  m*/
 */
@Override
public void updated(Dictionary<String, ?> config) throws ConfigurationException {

    logger.debug("Configuration updated, config {}", config != null ? true : false);

    if (config != null) {
        serialPort = (String) config.get("serialPort");
    }

    serialConnector = new SerialConnector(serialPort);
    try {
        serialConnector.connect();
        serialConnector.addSerialEventProcessor(this);
    } catch (EHealthException e) {
        logger.error("Error connecting to serial port '{}'", serialPort, e);
    }
}

From source file:org.openhab.binding.koubachi.internal.KoubachiConnector.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);
        }//  w  w  w  .  j  a v  a  2  s  . com

        String apiDeviceUrlString = (String) config.get("deviceurl");
        if (StringUtils.isNotBlank(apiDeviceUrlString)) {
            apiDeviceListUrl = apiDeviceUrlString;
        }
        String apiPlantUrlString = (String) config.get("planturl");
        if (StringUtils.isNotBlank(apiPlantUrlString)) {
            apiPlantListUrl = apiPlantUrlString;
        }

        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");
        }

        properlyConfigured = true;
    }
}

From source file:org.apache.felix.webconsole.AbstractWebConsolePluginServlet.java

@SuppressWarnings("rawtypes")
public void activateBundle(BundleContext comingContext) {
    this.bundleContext = comingContext;

    Dictionary headersBook = comingContext.getBundle().getHeaders();
    bundleVendorName = (String) headersBook.get(Constants.BUNDLE_VENDOR);
    bundleName = (String) headersBook.get(Constants.BUNDLE_NAME); // "OSGi Management Console";
    bundleProductWeb = (String) headersBook.get(Constants.BUNDLE_DOCURL);

    productName = "Application Server";
}

From source file:org.apache.sling.models.impl.ModelPackageBundleListener.java

@Override
public Object addingBundle(Bundle bundle, BundleEvent event) {
    List<ServiceRegistration> regs = new ArrayList<ServiceRegistration>();

    Dictionary<?, ?> headers = bundle.getHeaders();
    String packageList = PropertiesUtil.toString(headers.get(HEADER), null);
    if (packageList != null) {

        packageList = StringUtils.deleteWhitespace(packageList);
        String[] packages = packageList.split(",");
        for (String singlePackage : packages) {
            @SuppressWarnings("unchecked")
            Enumeration<URL> classUrls = bundle.findEntries("/" + singlePackage.replace('.', '/'), "*.class",
                    true);//from www.j  av a  2s  . c o m

            if (classUrls == null) {
                log.warn("No adaptable classes found in package {}, ignoring", singlePackage);
                continue;
            }

            while (classUrls.hasMoreElements()) {
                URL url = classUrls.nextElement();
                String className = toClassName(url);
                try {
                    Class<?> implType = bundle.loadClass(className);
                    Model annotation = implType.getAnnotation(Model.class);
                    if (annotation != null) {

                        // get list of adapters from annotation - if not given use annotated class itself
                        Class<?>[] adapterTypes = annotation.adapters();
                        if (adapterTypes.length == 0) {
                            adapterTypes = new Class<?>[] { implType };
                        }
                        // register adapter only if given adapters are valid
                        if (validateAdapterClasses(implType, adapterTypes)) {
                            for (Class<?> adapterType : adapterTypes) {
                                adapterImplementations.add(adapterType, implType);
                            }
                            ServiceRegistration reg = registerAdapterFactory(adapterTypes,
                                    annotation.adaptables(), implType, annotation.condition());
                            regs.add(reg);
                        }
                        String[] resourceTypes = annotation.resourceType();
                        for (String resourceType : resourceTypes) {
                            if (StringUtils.isNotEmpty(resourceType)) {
                                for (Class<?> adaptable : annotation.adaptables()) {
                                    adapterImplementations.registerModelToResourceType(bundle, resourceType,
                                            adaptable, implType);
                                }
                            }
                        }

                    }
                } catch (ClassNotFoundException e) {
                    log.warn("Unable to load class", e);
                }

            }
        }
    }
    return regs.toArray(new ServiceRegistration[0]);
}

From source file:org.opencastproject.userdirectory.ldap.LdapUserProviderFactory.java

/**
 * {@inheritDoc}/*from w ww.  jav a  2s  . c  om*/
 * 
 * @see org.osgi.service.cm.ManagedServiceFactory#updated(java.lang.String, java.util.Dictionary)
 */
@Override
public void updated(String pid, Dictionary properties) throws ConfigurationException {
    logger.debug("Updating LdapUserProviderFactory");
    String organization = (String) properties.get(ORGANIZATION_KEY);
    if (StringUtils.isBlank(organization))
        throw new ConfigurationException(ORGANIZATION_KEY, "is not set");
    String searchBase = (String) properties.get(SEARCH_BASE_KEY);
    if (StringUtils.isBlank(searchBase))
        throw new ConfigurationException(SEARCH_BASE_KEY, "is not set");
    String searchFilter = (String) properties.get(SEARCH_FILTER_KEY);
    if (StringUtils.isBlank(searchFilter))
        throw new ConfigurationException(SEARCH_FILTER_KEY, "is not set");
    String url = (String) properties.get(LDAP_URL_KEY);
    if (StringUtils.isBlank(url))
        throw new ConfigurationException(LDAP_URL_KEY, "is not set");
    String userDn = (String) properties.get(SEARCH_USER_DN);
    String password = (String) properties.get(SEARCH_PASSWORD);
    String roleAttributesGlob = (String) properties.get(ROLE_ATTRIBUTES_KEY);

    int cacheSize = 1000;
    logger.debug("Using cache size " + properties.get(CACHE_SIZE) + " for "
            + LdapUserProviderFactory.class.getName());
    Integer configuredCacheSize = Integer.parseInt((String) properties.get(CACHE_SIZE));
    if (configuredCacheSize != null) {
        cacheSize = configuredCacheSize.intValue();
    }

    int cacheExpiration = 1;
    Integer configuredCacheExpiration = Integer.parseInt((String) properties.get(CACHE_EXPIRATION));
    if (configuredCacheExpiration != null) {
        cacheExpiration = configuredCacheExpiration.intValue();
    }

    // Now that we have everything we need, go ahead and activate a new provider, removing an old one if necessary
    ServiceRegistration existingRegistration = providerRegistrations.remove(pid);
    if (existingRegistration != null) {
        existingRegistration.unregister();
    }
    LdapUserProviderInstance provider = new LdapUserProviderInstance(pid, organization, searchBase,
            searchFilter, url, userDn, password, roleAttributesGlob, cacheSize, cacheExpiration);
    providerRegistrations.put(pid, bundleContext.registerService(UserProvider.class.getName(), provider, null));

}

From source file:org.openhab.binding.x10.internal.X10ActiveBinding.java

/**
 * @{inheritDoc//from w  w  w  .  ja  v  a  2s  . c om
 */
@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);
        }

        // read further config parameters here ...

        isProperlyConfigured = true;
    }
}