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:org.wso2.carbon.dbconsole.ui.internal.DBConsoleComponent.java

public void registerServlet(BundleContext bundleContext) throws Exception {
    HttpContext defaultHttpContext = httpService.createDefaultHttpContext();
    Dictionary<String, String> servletParam = new Hashtable<String, String>(2);
    servletParam.put("-webAllowOthers", "");
    httpService.registerServlet("/dbconsole", new WebServlet(), servletParam, defaultHttpContext);
}

From source file:org.openengsb.core.util.DictonaryUtilTest.java

@Test
public void testWrapDictionary_shouldWrapDictionaryAsMap() throws Exception {
    Dictionary<String, Object> dict = new Hashtable<String, Object>();
    dict.put("test", 42L);
    dict.put("foo", "bar");
    Map<String, Object> wrapped = DictionaryAsMap.wrap(dict);
    assertThat((Long) wrapped.get("test"), is(42L));
    assertThat((String) wrapped.get("foo"), is("bar"));
}

From source file:org.openengsb.core.util.DictonaryUtilTest.java

@Test
public void testIterateWrappedDictionary_shouldReturnKeysAndValues() throws Exception {
    Dictionary<String, Object> dict = new Hashtable<String, Object>();
    dict.put("test", 42L);
    dict.put("foo", "bar");
    Map<String, Object> wrapped = DictionaryAsMap.wrap(dict);
    assertThat(wrapped.keySet(), hasItems("test", "foo"));
    assertThat(wrapped.values(), hasItems((Object) 42L, (Object) "bar"));
}

From source file:org.openengsb.core.util.DictonaryUtilTest.java

@Test
public void testIterateEntriesOfWrappedDictionary_shouldWork() throws Exception {
    Dictionary<String, Object> dict = new Hashtable<String, Object>();
    dict.put("test", 42L);
    dict.put("foo", "bar");
    Map<String, Object> wrapped = DictionaryAsMap.wrap(dict);
    Set<Entry<String, Object>> entrySet = wrapped.entrySet();
    Iterator<Entry<String, Object>> iterator = entrySet.iterator();
    iterator.next();//w  w  w. j a  v  a  2s  .co m
    Entry<String, Object> entry2 = iterator.next();
    assertThat(entry2.getKey(), is("test"));
    assertThat(entry2.getValue(), is((Object) 42L));
}

From source file:org.apache.sling.extensions.datasource.DataSourceIT.java

@Test
public void testDataSourceAsService() throws Exception {
    Configuration config = ca.createFactoryConfiguration(PID, null);
    Dictionary<String, Object> p = new Hashtable<String, Object>();
    p.put("url", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE");
    p.put("datasource.name", "test");
    p.put("maxActive", 70);
    config.update(p);/*from w  w w  . jav  a2s  .c o m*/

    Filter filter = context.createFilter("(&(objectclass=javax.sql.DataSource)(datasource.name=test))");
    ServiceTracker<DataSource, DataSource> st = new ServiceTracker<DataSource, DataSource>(context, filter,
            null);
    st.open();

    DataSource ds = st.waitForService(10000);
    assertNotNull(ds);

    Connection conn = ds.getConnection();
    assertNotNull(conn);

    //Cannot access directly so access via reflection
    assertEquals("70", getProperty(ds, "poolProperties.maxActive"));
}

From source file:org.wso2.carbon.sts.internal.STSServiceComponent.java

protected void activate(ComponentContext ctxt) {
    if (log.isDebugEnabled()) {
        log.debug("Carbon STS bundle is activated");
    }//ww  w .  j ava 2 s  .  c o  m
    try {
        BundleContext bundleCtx = ctxt.getBundleContext();
        STSServiceDataHolder.getInstance().setBundle(bundleCtx.getBundle());
        // Publish the OSGi service
        Dictionary props = new Hashtable();
        props.put(CarbonConstants.AXIS2_CONFIG_SERVICE, AxisObserver.class.getName());
        ctxt.getBundleContext().registerService(AxisObserver.class.getName(), new STSDeploymentInterceptor(),
                props);

        // Publish an OSGi service to listen tenant configuration context creation events
        bundleCtx.registerService(Axis2ConfigurationContextObserver.class.getName(),
                new STSDeploymentListener(), null);
    } catch (Throwable e) {
        log.error("Error occurred while updating carbon STS service", e);
    }
}

From source file:com.ning.killbill.zuora.osgi.ZuoraActivator.java

private void registerPaymentPluginApi(final BundleContext context, final PaymentPluginApi api) {
    final Dictionary props = new Hashtable();
    props.put(OSGIPluginProperties.PLUGIN_NAME_PROP, PLUGIN_NAME);
    registrar.registerService(context, PaymentPluginApi.class, api, props);
}

From source file:org.ops4j.pax.jdbc.pool.dbcp2.impl.ds.XAPooledDataSourceFactory.java

@Override
public Dictionary<String, Object> createPropsForPoolingDataSourceFactory(
        ServiceReference<DataSourceFactory> reference) {
    Dictionary<String, Object> props = super.createPropsForPoolingDataSourceFactory(reference);
    props.put("xa", "true");
    return props;
}

From source file:org.wso2.carbon.identity.authenticator.webseal.ui.internal.Activator.java

public void start(BundleContext bc) {

    WebSealUIAuthenticator authenticator = new WebSealUIAuthenticator();
    Hashtable<String, String> props = new Hashtable<String, String>();
    props.put(CarbonConstants.AUTHENTICATOR_TYPE, authenticator.getAuthenticatorName());
    bc.registerService(CarbonUIAuthenticator.class.getName(), authenticator, props);

    //register log-out filter
    Utils.initConfig();// ww w  .  j  a  v  a  2s  .c om
    HttpServlet logOutServlet = new HttpServlet() {
        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp)
                throws ServletException, IOException {

        }
    };

    Filter logOutPageFilter = new LogOutPageFilter();
    Dictionary logOutPageFilterProps = new Hashtable(2);
    Dictionary redirectorParams = new Hashtable(3);

    redirectorParams.put("url-pattern", Utils.getLogOutPage());

    redirectorParams.put("associated-filter", logOutPageFilter);
    redirectorParams.put("servlet-attributes", logOutPageFilterProps);
    bc.registerService(Servlet.class.getName(), logOutServlet, redirectorParams);

    //Register the SSO Assertion Consumer Service Servlet
    HttpServlet acsServlet = new WebSealConsumerService();
    Dictionary acsParams = new Hashtable(2);
    acsParams.put("url-pattern", "/webseal");
    acsParams.put("display-name", "WebSeal Consumer Service");
    bc.registerService(Servlet.class.getName(), acsServlet, acsParams);

    log.info("WebSeal Authenticator FE Bundle activated successfully.");

}

From source file:org.eclipse.swordfish.core.configuration.ConfigurationServiceImpl.java

public <T> void updateConfiguration(String id, Map<String, T> configurationData) {
    try {//from   www . ja  va 2 s  .  c  o m
        Configuration configuration = configurationAdmin.getConfiguration(id);
        Assert.notNull(configuration, "Could npot find configuration by id = " + id);
        if (configurationData == null) {
            configuration.update(null);
            return;
        }
        Dictionary properties = new Hashtable();
        for (Object key : configurationData.keySet()) {
            properties.put(key, configurationData.get(key));
        }
        configuration.update(properties);
    } catch (Exception ex) {
        throw new SwordfishException(ex);
    }

}