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:io.wcm.config.core.override.impl.SystemPropertyOverrideProvider.java

@Activate
void activate(final ComponentContext ctx) {
    Dictionary config = ctx.getProperties();
    final boolean enabled = PropertiesUtil.toBoolean(config.get(PROPERTY_ENABLED), DEFAULT_ENABLED);

    Map<String, String> map = new HashMap<>();
    if (enabled) {
        Properties properties = System.getProperties();
        Enumeration<Object> keys = properties.keys();
        while (keys.hasMoreElements()) {
            Object keyObject = keys.nextElement();
            if (keyObject instanceof String) {
                String key = (String) keyObject;
                if (StringUtils.startsWith(key, SYSTEM_PROPERTY_PREFIX)) {
                    map.put(StringUtils.substringAfter(key, SYSTEM_PROPERTY_PREFIX), System.getProperty(key));
                }//  w w w  .j a v a  2 s . co  m
            }
        }
    }
    this.overrideMap = ImmutableMap.copyOf(map);
}

From source file:com.foglyn.core.FoglynCorePlugin.java

private String getBundleVersion() {
    Dictionary<?, ?> headers = getBundle().getHeaders();
    Object version = headers.get(Constants.BUNDLE_VERSION);
    if (version == null) {
        return null;
    }//  w ww .j  a  v a2 s.co m

    return String.valueOf(version);
}

From source file:org.openhab.persistence.caldav.internal.CaldavConfiguration.java

/**
 * {@inheritDoc}//  w  w w.  ja v a 2  s.  com
 */
public void updated(Dictionary<String, ?> config) throws ConfigurationException {
    if (config != null) {
        String calendarIdString = (String) config.get("calendarId");
        if (StringUtils.isNotBlank(calendarIdString)) {
            calendarId = calendarIdString;
        }

        String durationString = (String) config.get("duration");
        if (StringUtils.isNotBlank(durationString)) {
            try {
                duration = Integer.parseInt(durationString);
            } catch (NumberFormatException e) {
                logger.error("cannot convert to int: {}", durationString);
            }
        }

        String singleEventsString = (String) config.get("singleEvents");
        if (StringUtils.isNotBlank(singleEventsString)) {
            singleEvents = Boolean.parseBoolean(singleEventsString);
        }
    }
}

From source file:com.adobe.acs.commons.http.headers.impl.AbstractExpiresHeaderFilter.java

@Override
protected void doActivate(ComponentContext context) throws Exception {
    Dictionary<?, ?> properties = context.getProperties();
    String time = PropertiesUtil.toString(properties.get(PROP_EXPIRES_TIME), null);
    if (StringUtils.isBlank(time)) {
        throw new ConfigurationException(PROP_EXPIRES_TIME, "Expires Time must be specified.");
    }//from   w ww.  j  av a  2  s .c  o  m
    SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
    sdf.setLenient(false);
    try {
        Date date = sdf.parse(time);
        expiresTime.setTime(date);
    } catch (ParseException ex) {
        throw new ConfigurationException(PROP_EXPIRES_TIME, "Expires Time must be specified.");
    }
}

From source file:org.apache.sling.scripting.sightly.impl.engine.SightlyEngineConfiguration.java

protected void activate(ComponentContext componentContext) {
    InputStream ins = null;// w  w  w .jav  a  2s.  co m
    try {
        ins = getClass().getResourceAsStream("/META-INF/MANIFEST.MF");
        if (ins != null) {
            Manifest manifest = new Manifest(ins);
            Attributes attrs = manifest.getMainAttributes();
            String version = attrs.getValue("ScriptEngine-Version");
            if (version != null) {
                engineVersion = version;
            }
            String symbolicName = attrs.getValue("Bundle-SymbolicName");
            if (StringUtils.isNotEmpty(symbolicName)) {
                bundleSymbolicName = symbolicName;
            }
        }
    } catch (IOException ioe) {
    } finally {
        if (ins != null) {
            try {
                ins.close();
            } catch (IOException ignore) {
            }
        }
    }
    Dictionary properties = componentContext.getProperties();
    keepGenerated = PropertiesUtil.toBoolean(properties.get(SCR_PROP_NAME_KEEPGENERATED),
            SCR_PROP_DEFAULT_KEEPGENERATED);
}

From source file:org.apache.cxf.dosgi.dsw.Activator.java

public synchronized void updated(Dictionary props) throws ConfigurationException {
    if (props != null && CONFIG_SERVICE_PID.equals(props.get(Constants.SERVICE_PID))) {
        // topManager.updated(props);
    }//from  ww  w .  ja v a  2  s.c o m
}

From source file:net.solarnetwork.central.dras.web.AboutController.java

@ModelAttribute("app")
public Map<String, Object> getApplicationDetails(Locale locale) {
    Map<String, Object> result = new LinkedHashMap<String, Object>(5);
    if (bundleContext != null) {
        Dictionary<?, ?> dic = bundleContext.getBundle().getHeaders();
        for (String key : DEFAULT_KEYS) {
            Object val = dic.get(key);
            Map<String, Object> value = new LinkedHashMap<String, Object>(2);
            value.put("value", val);
            if (messageSource != null) {
                String msg = messageSource.getMessage("about.field." + key, null, locale);
                value.put("title", msg);
            }/*w w w .  j  a v a 2s.  c  o  m*/
            result.put(key, value);
        }
    }
    return result;
}

From source file:org.ops4j.pax.web.itest.jetty.Servlet3WarIntegrationTest.java

/**
 * You will get a list of bundles installed by default plus your testcase,
 * wrapped into a bundle called pax-exam-probe
 *///  w  ww . ja v a  2  s  .  c o  m
@Test
public void listBundles() {
    for (Bundle b : bundleContext.getBundles()) {
        if (b.getState() != Bundle.ACTIVE) {
            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());
        }
    }

}

From source file:org.fusesource.cloudmix.controller.configadmindataprovider.ConfigAdminControllerDataProvider.java

protected void loadProfiles(Dictionary dictionary) {
    int numProfiles = Integer.parseInt((String) dictionary.get("profiles"));
    for (int i = 1; i <= numProfiles; i++) {
        String name = (String) dictionary.get("profile." + i + ".name");
        ProfileDetails pd = new ProfileDetails(name);
        String feats = (String) dictionary.get("profile." + i + ".features");
        if (feats != null) {
            List<Dependency> profileFeatures = new ArrayList<Dependency>();
            for (String feat : feats.split(",")) {
                Dependency f = new Dependency();
                f.setFeatureId(feat);//from w  ww. j a v a  2  s  .  c  o  m
                profileFeatures.add(f);
            }
            pd.setFeatures(profileFeatures);
        }
        ProfileController pc = new ProfileController(grid, pd);
        addProfile(name, pc);
    }
}

From source file:org.fusesource.cloudmix.controller.configadmindataprovider.ConfigAdminControllerDataProvider.java

protected void loadFeatures(Dictionary dictionary) {
    int numFeatures = Integer.parseInt((String) dictionary.get("features"));
    for (int i = 1; i <= numFeatures; i++) {
        String name = (String) dictionary.get("feature." + i + ".name");
        String url = (String) dictionary.get("feature." + i + ".url");
        FeatureDetails fd = new FeatureDetails(name, url);
        String deps = (String) dictionary.get("feature." + i + ".deps");
        if (deps != null) {
            List<Dependency> dependencies = new ArrayList<Dependency>();
            for (String dep : deps.split(",")) {
                Dependency d = new Dependency();
                d.setFeatureId(dep);/*from  ww w .jav a 2s . c  o m*/
                dependencies.add(d);
            }
            fd.setDependencies(dependencies);
        }
        FeatureController fc = new FeatureController(grid, fd);
        addFeature(name, fc);
    }
}