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.apache.whirr.karaf.itest.integration.WhirrLiveTestSupport.java

public void loadConfiguration(String name, String pid) throws ConfigurationException, IOException {
    if (configurationAdmin == null) {
        String message = "No configuration admin available. Make sure you have "
                + "properly looked it up before invoking this method";
        System.err.println(message);
        throw new IllegalStateException(message);
    }/*from   ww  w  .ja v a2  s  .  c o  m*/

    PropertiesConfiguration properties = new PropertiesConfiguration(
            getClass().getClassLoader().getResource(name));
    Configuration configuration = configurationAdmin.getConfiguration(pid);

    Dictionary dictionary = configuration.getProperties();
    if (dictionary == null) {
        dictionary = new Properties();
    }

    Iterator iterator = properties.getKeys();
    while (iterator.hasNext()) {
        String key = (String) iterator.next();
        String value = properties.getString(key);
        dictionary.put(key, value);
    }
    configuration.update(dictionary);
}

From source file:com.whizzosoftware.hobson.bootstrap.api.hub.OSGIHubManager.java

@Override
public void setHubName(String userId, String hubId, String name) {
    try {//  w  ww . jav a2 s .c  o  m
        Configuration config = getConfiguration();
        Dictionary props = getConfigurationProperties(config);
        props.put(HUB_NAME, name);

        updateConfiguration(config, props);
    } catch (IOException e) {
        throw new HobsonRuntimeException("Error setting hub name", e);
    }
}

From source file:com.whizzosoftware.hobson.bootstrap.api.hub.OSGIHubManager.java

@Override
public void setHubEmailConfiguration(String userId, String hubId, EmailConfiguration ec) {
    try {/*  w  w w.  java  2  s  .c o  m*/
        Configuration config = getConfiguration();
        Dictionary d = getConfigurationProperties(config);
        d.put(EmailConfiguration.PROP_MAIL_SERVER, ec.getMailServer());
        d.put(EmailConfiguration.PROP_MAIL_SMTPS, ec.isSMTPS());
        d.put(EmailConfiguration.PROP_MAIL_USERNAME, ec.getUsername());
        d.put(EmailConfiguration.PROP_MAIL_PASSWORD, ec.getPassword());
        d.put(EmailConfiguration.PROP_MAIL_SENDER, ec.getSenderAddress());

        updateConfiguration(config, d);
    } catch (IOException e) {
        throw new HobsonRuntimeException("Error setting hub location", e);
    }
}

From source file:org.eclipse.virgo.medic.impl.LogController.java

private ServiceRegistration<PrintStream> publishPrintStream(PrintStream printStream, String name) {
    Dictionary<String, String> properties = new Hashtable<String, String>();
    properties.put("org.eclipse.virgo.medic.log.printStream", name);

    ServiceRegistration<PrintStream> registration = bundleContext.registerService(PrintStream.class,
            printStream, properties);//from  w ww  .j  a v a  2s . com
    registrationTracker.track(registration);

    return registration;
}

From source file:org.eclipse.virgo.medic.impl.LogController.java

private ServiceRegistration<DelegatingPrintStream> publishDelegatingPrintStream(
        DelegatingPrintStream printStream, String name) {
    Dictionary<String, String> properties = new Hashtable<String, String>();
    properties.put("org.eclipse.virgo.medic.log.printStream", name);

    ServiceRegistration<DelegatingPrintStream> delegatingPrintStreamRegistration = bundleContext
            .registerService(DelegatingPrintStream.class, printStream, properties);
    registrationTracker.track(delegatingPrintStreamRegistration);

    return delegatingPrintStreamRegistration;
}

From source file:org.opencastproject.series.impl.SeriesServiceImpl.java

/**
 * Sends an OSGI Event./* w ww.  ja  v a 2 s . c  om*/
 * 
 * @param topic
 *          the event topic
 * @param objectId
 *          the series identifier
 * @param payload
 *          the event payload
 */
private void sendEvent(String topic, String objectId, String payload) {
    Dictionary<String, String> eventProperties = new Hashtable<String, String>();
    eventProperties.put(ID, objectId);
    eventProperties.put(PAYLOAD, payload);
    eventAdmin.postEvent(new Event(topic, eventProperties));
}

From source file:org.inaetics.pubsub.demo.config.Configurator.java

private void configurePubSub() {
    ServiceReference configurationAdminReference = bundleContext
            .getServiceReference(ConfigurationAdmin.class.getName());

    if (configurationAdminReference != null) {

        ConfigurationAdmin confAdmin = (ConfigurationAdmin) bundleContext
                .getService(configurationAdminReference);

        try {//from  w ww . j av a2s .c o m
            Configuration config = confAdmin
                    .getConfiguration("org.inaetics.pubsub.impl.discovery.etcd.EtcdDiscoveryManager", null);
            Dictionary props = config.getProperties();

            // if null, the configuration is new
            if (props == null) {
                props = new Hashtable();
            }

            // set some properties
            props.put("url", "http://" + VAGRANT_HOST_IP + ":2379/v2/keys");

            // update the configuration

            config.update(props);

            config = confAdmin.getConfiguration("org.inaetics.pubsub.impl.pubsubadmin.kafka.KafkaPubSubAdmin",
                    null);
            props = config.getProperties();

            // if null, the configuration is new
            if (props == null) {
                props = new Hashtable();
            }

            // set some properties
            props.put("sub:zookeeper.connect", VAGRANT_HOST_IP + ":2181");
            props.put("pub:bootstrap.servers", VAGRANT_HOST_IP + ":9092");
            config.update(props);
        } catch (Throwable e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

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

private void setSolrSoftCommit() throws IOException {
    Configuration solrConfig = configAdmin.getConfiguration(SOLR_CONFIG_PID, null);
    Dictionary<String, Object> properties = new Hashtable<String, Object>();
    properties.put("forceAutoCommit", "true");
    solrConfig.update(properties);/*from   w ww.j  ava 2s .  c  o  m*/
}

From source file:org.codice.ddf.configuration.admin.ConfigurationAdminMigratableTest.java

private Configuration getConfigurationForExportSystem() throws IOException {
    Configuration config = mock(Configuration.class);
    Dictionary<String, Object> props = new Hashtable<>();
    props.put(DirectoryWatcher.FILENAME, ddfHome.resolve("etc").toRealPath()
            .resolve(String.format("%s-csw.config", DDF_CUSTOM_MIME_TYPE_RESOLVER_FACTORY_PID)).toUri());
    String pid = String.format("%s.4039089d-839f-4d52-a174-77c8a19fc03d",
            DDF_CUSTOM_MIME_TYPE_RESOLVER_FACTORY_PID);
    props.put("service.pid", pid);
    props.put("service.factoryPid", DDF_CUSTOM_MIME_TYPE_RESOLVER_FACTORY_PID);
    props.put("schema", "http://www.opengis.net/cat/csw/2.0.2");
    when(config.getProperties()).thenReturn(props);
    when(config.getPid()).thenReturn(pid);
    when(config.getFactoryPid()).thenReturn(DDF_CUSTOM_MIME_TYPE_RESOLVER_FACTORY_PID);
    return config;
}

From source file:org.apache.clerezza.platform.testing.blackbox.osgi.FelixClerezzaPlatformTest.java

private void registerRDFListRootResource() {
    final Dictionary<String, Object> jaxRsResourceProperty = new Hashtable<String, Object>();
    {//  w w w .j  a  v a2 s .c  om
        jaxRsResourceProperty.put("javax.ws.rs", Boolean.TRUE);
        jaxRsResourceProperty.put("service.pid", RDFListRootResource.class.getName());
    }
    bundleContext.registerService(Object.class.getName(), new RDFListRootResource(), jaxRsResourceProperty);
}