Example usage for java.util Dictionary put

List of usage examples for java.util Dictionary put

Introduction

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

Prototype

public abstract V put(K key, V value);

Source Link

Document

Maps the specified key to the specified value in this dictionary.

Usage

From source file:ddf.catalog.test.AbstractIntegrationTest.java

protected void setLogLevels() throws IOException {
    Configuration logConfig = configAdmin.getConfiguration(LOG_CONFIG_PID, null);
    Dictionary<String, Object> properties = logConfig.getProperties();
    properties.put(LOGGER_PREFIX + "ddf", "TRACE");
    properties.put(LOGGER_PREFIX + "org.codice", "TRACE");
    logConfig.update(properties);//  www .  ja va  2s. c om
}

From source file:org.eclipse.gemini.blueprint.extender.internal.blueprint.event.OsgiEventDispatcher.java

private Dictionary<String, Object> init(BlueprintEvent event) {
    Dictionary<String, Object> props = new Hashtable<String, Object>();

    Bundle bundle = event.getBundle();/*from w  w w  . j  a va 2s  .  c  om*/

    // common properties
    props.put(TIMESTAMP, System.currentTimeMillis());
    props.put(EVENT, event);
    props.put(TYPE, Integer.valueOf(event.getType()));

    props.put(BUNDLE, event.getBundle());
    props.put(BUNDLE_ID, bundle.getBundleId());

    // name (under two keys)
    String name = OsgiStringUtils.nullSafeName(bundle);
    props.put(BUNDLE_NAME, name);
    props.put(Constants.BUNDLE_NAME, name);

    // sym name (under two keys)
    String symName = OsgiStringUtils.nullSafeSymbolicName(bundle);
    props.put(BUNDLE_SYM_NAME, symName);
    props.put(Constants.BUNDLE_SYMBOLICNAME, symName);

    // version (as well under two keys)
    Version version = OsgiBundleUtils.getBundleVersion(bundle);
    props.put(BUNDLE_VERSION, version);
    props.put(Constants.BUNDLE_VERSION, version);

    // extender bundle info
    Bundle extenderBundle = event.getExtenderBundle();

    props.put(EXTENDER_BUNDLE, extenderBundle);
    props.put(EXTENDER_BUNDLE_ID, extenderBundle.getBundleId());
    props.put(EXTENDER_BUNDLE_SYM_NAME, extenderBundle.getSymbolicName());
    Version extenderVersion = OsgiBundleUtils.getBundleVersion(extenderBundle);
    props.put(EXTENDER_BUNDLE_VERSION, extenderVersion);

    return props;
}

From source file:org.openhab.io.cv.CVApplication.java

private Dictionary<String, String> getJerseyServletParams() {
    Dictionary<String, String> jerseyServletParams = new Hashtable<String, String>();
    jerseyServletParams.put("javax.ws.rs.Application", CVApplication.class.getName());
    jerseyServletParams.put("org.atmosphere.core.servlet-mapping", CV_SERVLET_ALIAS + "/*");
    jerseyServletParams.put("org.atmosphere.useWebSocket", "true");
    jerseyServletParams.put("org.atmosphere.useNative", "true");
    jerseyServletParams.put("org.atmosphere.cpr.AtmosphereInterceptor.disableDefaults", "true");
    // use the default interceptors without PaddingAtmosphereInterceptor
    // see: https://groups.google.com/forum/#!topic/openhab/Z-DVBXdNiYE
    final String[] interceptors = { "org.atmosphere.interceptor.CacheHeadersInterceptor",
            "org.atmosphere.interceptor.AndroidAtmosphereInterceptor",
            "org.atmosphere.interceptor.SSEAtmosphereInterceptor",
            "org.atmosphere.interceptor.JSONPAtmosphereInterceptor",
            "org.atmosphere.interceptor.JavaScriptProtocol",
            "org.atmosphere.interceptor.OnDisconnectInterceptor" };
    jerseyServletParams.put("org.atmosphere.cpr.AtmosphereInterceptor", StringUtils.join(interceptors, ","));
    jerseyServletParams.put("org.atmosphere.cpr.broadcasterLifeCyclePolicy", "IDLE_DESTROY");
    jerseyServletParams.put("org.atmosphere.cpr.CometSupport.maxInactiveActivity", "300000");

    jerseyServletParams.put("com.sun.jersey.spi.container.ResourceFilter",
            "org.atmosphere.core.AtmosphereFilter");
    //        The BroadcasterCache is set in ResourceStateChangeListener.registerItems(), because otherwise
    //        it gets somehow overridden by other registered servlets (e.g. the REST-bundle)
    //        the other advantage of this solution is, that the BroadcasterCache class does not need to be exported by this package
    //        jerseyServletParams.put("org.atmosphere.cpr.broadcasterCacheClass", "org.openhab.io.cv.internal.cache.CVBroadcasterCache");        

    // required because of bug http://java.net/jira/browse/JERSEY-361
    jerseyServletParams.put(FeaturesAndProperties.FEATURE_XMLROOTELEMENT_PROCESSING, "true");

    return jerseyServletParams;
}

From source file:org.apache.ace.authentication.processor.password.PasswordAuthenticationProcessorTest.java

/**
 * Tests that updated throws an exception for missing "key.password" property. 
 *//* w  w w.  j a v  a  2  s  .  c  o  m*/
@Test(groups = { UNIT }, expectedExceptions = ConfigurationException.class)
public void testUpdatedDoesNotAcceptMissingKeyPassword() throws ConfigurationException {
    Dictionary<String, Object> props = new Hashtable<>();

    props.put(PROPERTY_KEY_USERNAME, "foo");
    props.put(PROPERTY_PASSWORD_HASHMETHOD, "none");

    new PasswordAuthenticationProcessor().updated(props);
}

From source file:org.apache.ace.authentication.processor.password.PasswordAuthenticationProcessorTest.java

/**
 * Tests that updated throws an exception for missing "key.username" property. 
 *//* w w  w.j  av a2  s.  co m*/
@Test(groups = { UNIT }, expectedExceptions = ConfigurationException.class)
public void testUpdatedDoesNotAcceptMissingKeyUsername() throws ConfigurationException {
    Dictionary<String, Object> props = new Hashtable<>();

    props.put(PROPERTY_KEY_PASSWORD, "foo");
    props.put(PROPERTY_PASSWORD_HASHMETHOD, "none");

    new PasswordAuthenticationProcessor().updated(props);
}

From source file:org.apache.ace.authentication.processor.password.PasswordAuthenticationProcessorTest.java

/**
 * Tests that updated throws an exception for missing "password.hashtype" property. 
 *///ww  w .j  a  va 2s  . c  om
@Test(groups = { UNIT }, expectedExceptions = ConfigurationException.class)
public void testUpdatedDoesNotAcceptMissingPasswordHashType() throws ConfigurationException {
    Dictionary<String, Object> props = new Hashtable<>();

    props.put(PROPERTY_KEY_USERNAME, "foo");
    props.put(PROPERTY_KEY_PASSWORD, "foo");

    new PasswordAuthenticationProcessor().updated(props);
}

From source file:org.apache.ace.authentication.processor.password.PasswordAuthenticationProcessorTest.java

/**
 * Tests that updated throws an exception for missing "key.password" property. 
 *///  w w w. ja va 2s  . c om
@Test(groups = { UNIT }, expectedExceptions = ConfigurationException.class)
public void testUpdatedDoesNotAcceptEmptyKeyPassword() throws ConfigurationException {
    Dictionary<String, Object> props = new Hashtable<>();

    props.put(PROPERTY_KEY_USERNAME, "foo");
    props.put(PROPERTY_KEY_PASSWORD, "");
    props.put(PROPERTY_PASSWORD_HASHMETHOD, "none");

    new PasswordAuthenticationProcessor().updated(props);
}

From source file:org.apache.ace.authentication.processor.password.PasswordAuthenticationProcessorTest.java

/**
 * Tests that updated throws an exception for missing "key.username" property. 
 *//* ww  w  .  j a  v  a2s.c  om*/
@Test(groups = { UNIT }, expectedExceptions = ConfigurationException.class)
public void testUpdatedDoesNotAcceptEmptyKeyUsername() throws ConfigurationException {
    Dictionary<String, Object> props = new Hashtable<>();

    props.put(PROPERTY_KEY_USERNAME, "");
    props.put(PROPERTY_KEY_PASSWORD, "foo");
    props.put(PROPERTY_PASSWORD_HASHMETHOD, "none");

    new PasswordAuthenticationProcessor().updated(props);
}

From source file:org.apache.ace.authentication.processor.password.PasswordAuthenticationProcessorTest.java

/**
 * Tests that updated throws an exception for missing "password.hashtype" property. 
 */// www .  j  a  va 2  s.  c  om
@Test(groups = { UNIT }, expectedExceptions = ConfigurationException.class)
public void testUpdatedDoesNotAcceptEmptyPasswordHashType() throws ConfigurationException {
    Dictionary<String, Object> props = new Hashtable<>();

    props.put(PROPERTY_KEY_USERNAME, "foo");
    props.put(PROPERTY_KEY_PASSWORD, "bar");
    props.put(PROPERTY_PASSWORD_HASHMETHOD, "");

    new PasswordAuthenticationProcessor().updated(props);
}

From source file:org.eclipse.gyrex.services.common.provider.BaseService.java

/**
 * Registers the metrics on behalf of the bundle which loaded this class.
 * //from w  w  w  . j  av  a 2  s  .  c o  m
 * @throws IllegalArgumentException
 *             if the class was not loaded by a bundle class loader
 * @throws IllegalStateException
 *             if the bundle which loaded the class has no valid bundle
 *             context
 */
private void registerMetrics() throws IllegalArgumentException, IllegalStateException {
    // get bundle context
    // TODO: we might need to wrap this into a privileged call
    final Bundle bundle = FrameworkUtil.getBundle(getClass());
    final BundleContext bundleContext = null != bundle ? bundle.getBundleContext() : null;
    if (null == bundleContext) {
        throw new IllegalStateException("Unable to determin bundle context for class '" + getClass().getName()
                + "'. Please ensure that this class was loaded by a bundle which is either STARTING, ACTIVE or STOPPING.");
    }

    // create properties
    final Dictionary<String, Object> properties = new Hashtable<String, Object>(2);
    properties.put(Constants.SERVICE_VENDOR, this.getClass().getName());
    properties.put(Constants.SERVICE_DESCRIPTION,
            "Metrics for service implementation '" + this.getClass().getName() + "'.");
    properties.put(IRuntimeContextConstants.SERVICE_PROPERTY_CONTEXT_PATH,
            getContext().getContextPath().toString());

    // register service
    metricsRegistration = bundleContext.registerService(MetricSet.class.getName(), metrics, properties);
}