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.codice.ddf.registry.publication.action.provider.RegistryPublicationActionProviderTest.java

@Test
public void testCanHandleRegistrySource() throws Exception {
    when(source.getId()).thenReturn("regId1");
    Dictionary<String, Object> properties = new Hashtable<>();
    properties.put(RegistryConstants.CONFIGURATION_REGISTRY_ID_PROPERTY, "regId1");
    when(configuration.getProperties()).thenReturn(properties);
    assertThat(publicationActionProvider.canHandle(source), is(true));
}

From source file:org.nuxeo.ecm.platform.web.common.requestcontroller.service.NuxeoCorsFilterDescriptor.java

protected Dictionary<String, String> buildDictionary() {
    Dictionary<String, String> params = new Hashtable<>();
    params.put(PROPERTIES_PREFIX + "allowGenericHttpRequests", Boolean.toString(allowGenericHttpRequests));

    if (!isEmpty(allowOrigin)) {
        params.put(PROPERTIES_PREFIX + "allowOrigin", allowOrigin);
    }/*  w  w w . j a v  a 2  s  .  co m*/

    params.put(PROPERTIES_PREFIX + "allowSubdomains", Boolean.toString(allowSubdomains));

    if (!isEmpty(supportedMethods)) {
        params.put(PROPERTIES_PREFIX + "supportedMethods", supportedMethods);
    }

    if (!isEmpty(supportedHeaders)) {
        params.put(PROPERTIES_PREFIX + "supportedHeaders", supportedHeaders);
    }

    if (!isEmpty(exposedHeaders)) {
        params.put(PROPERTIES_PREFIX + "exposedHeaders", exposedHeaders);
    }

    params.put(PROPERTIES_PREFIX + "supportsCredentials", Boolean.toString(supportsCredentials));
    params.put(PROPERTIES_PREFIX + "maxAge", Integer.toString(maxAge));

    return params;
}

From source file:org.eclipse.virgo.snaps.SnapsTagTests.java

@Test
public void snapsFromServiceRegistry() throws JspException, InvalidSyntaxException {
    Dictionary<String, Object> properties1 = new Hashtable<String, Object>();
    properties1.put("a", "b");
    properties1.put("c", new Integer(6));

    ServiceReference<?> serviceReference1 = createServiceReference(properties1);

    Dictionary<String, Object> properties2 = new Hashtable<String, Object>();
    properties2.put("d", "e");
    properties2.put("f", Boolean.TRUE);

    ServiceReference<?> serviceReference2 = createServiceReference(properties2);

    expect(servletContext.getAttribute(WebContainer.ATTRIBUTE_BUNDLE_CONTEXT)).andReturn(bundleContext);

    Bundle bundle = createMock(Bundle.class);
    expect(bundleContext.getBundle()).andReturn(bundle);
    expect(bundle.getBundleId()).andReturn(27L);

    expect(bundleContext.getServiceReferences("org.eclipse.virgo.snaps.core.internal.Snap",
            "(snap.host.id=27)")).andReturn(new ServiceReference[] { serviceReference1, serviceReference2 });

    expect(serviceReference1.compareTo(serviceReference2)).andReturn(1).anyTimes();
    expect(serviceReference2.compareTo(serviceReference1)).andReturn(-1).anyTimes();

    replay(servletContext, bundleContext, serviceReference1, serviceReference2, bundle);

    snapsTag.doStartTag();/*from  w w  w . j  a v a  2  s  .c  om*/

    verify(servletContext, bundleContext, serviceReference1, serviceReference2, bundle);

    @SuppressWarnings("unchecked")
    List<Snap> snaps = (List<Snap>) pageContext.getAttribute(SnapsTag.SNAPS_ATTRIBUTE_NAME);
    assertNotNull(snaps);
    assertEquals(2, snaps.size());

    Snap snap = snaps.get(1);
    assertEquals("b", snap.getProperties().get("a"));
    assertEquals(new Integer(6), snap.getProperties().get("c"));

    snap = snaps.get(0);
    assertEquals("e", snap.getProperties().get("d"));
    assertEquals(Boolean.TRUE, snap.getProperties().get("f"));

}

From source file:org.carrot2.workbench.vis.circles.WebServiceManager.java

public void start(String webappName, BundleContext context) throws Exception {
    final Dictionary<String, Object> d = new Hashtable<String, Object>();

    configureSettings(context);/* ww w.  j  a  va 2 s .com*/

    d.put("http.port", port);
    d.put("context.path", "/");
    d.put("other.info", otherInfo);

    JettyConfigurator.startServer(webappName, d);
    checkBundle();

    this.webappName = webappName;
}

From source file:org.codice.ddf.catalog.subscriptionstore.common.CachedSubscription.java

/**
 * Register the provided {@link Subscription} as this cached subscription's OSGi service.
 *
 * @param sub the subscription to register.
 * @throws SubscriptionRegistrationException if registration failed.
 *///www  .j  ava2s .  c om
public synchronized void registerSubscription(Subscription sub) {
    if (registration != null) {
        throw new SubscriptionRegistrationException("Subscription already registered");
    }

    LOGGER.debug("Registering service [{}]", metadata.getId());

    Dictionary<String, String> properties = new Hashtable<>(INITIAL_CAPACITY);
    properties.put(SUBSCRIPTION_ID_OSGI, metadata.getId());
    properties.put(EVENT_ENDPOINT, metadata.getCallbackAddress());

    registration = getBundleContext().registerService(Subscription.class.getName(), sub, properties);

    if (registration != null) {
        LOGGER.debug("Subscription [ {} | {} | {} ] registered with bundle ID = {}", metadata.getId(),
                metadata.getTypeName(), metadata.getCallbackAddress(),
                registration.getReference().getBundle().getBundleId());
        subscription = sub;
    } else {
        throw new SubscriptionRegistrationException(
                format("Subscription registration attempt for id [%s] of type [%s] failed", metadata.getId(),
                        metadata.getTypeName()));
    }
}

From source file:org.opencastproject.dictionary.hunspell.DictionaryServiceImpl.java

/**
 * OSGi callback on component activation.
 *
 * @param  ctx  the bundle context//from  w  w  w.j  a  v a  2  s .co m
 */
void activate(BundleContext ctx) throws UnsupportedEncodingException {
    Dictionary<String, String> properties = new Hashtable<String, String>();
    properties.put(ARTIFACT, "dictionary");
    ctx.registerService(ReadinessIndicator.class.getName(), new ReadinessIndicator(), properties);

    /* Get hunspell binary from config file */
    String binary = (String) ctx.getProperty(HUNSPELL_BINARY_CONFIG_KEY);
    if (binary != null) {
        /* Fix special characters */
        binary = new String(binary.getBytes("ISO-8859-1"), "UTF-8");
        logger.info("Setting hunspell binary to '{}'", binary);
        this.binary = binary;
    }

    /* Get hunspell command line options from config file */
    String command = (String) ctx.getProperty(HUNSPELL_COMMAND_CONFIG_KEY);
    if (command != null) {
        /* Fix special characters */
        command = new String(command.getBytes("ISO-8859-1"), "UTF-8");
        logger.info("Setting hunspell command line options to '{}'", command);
        this.command = command;
    }
}

From source file:org.ops4j.pax.url.commons.handler.HandlerActivator.java

/**
 * Register the handler service.//from  ww w  . j a v a  2  s  .co m
 */
private void registerHandler() {
    final Dictionary<String, Object> props = new Hashtable<String, Object>();
    props.put(URLConstants.URL_HANDLER_PROTOCOL, m_protocols);
    m_handlerReg = m_bundleContext.registerService(URLStreamHandlerService.class.getName(), new Handler(),
            props);

}

From source file:org.codice.alliance.test.itests.NsiliEndpointTest.java

private void configureSecurityStsClient() throws IOException, InterruptedException {
    Configuration stsClientConfig = configAdmin.getConfiguration("ddf.security.sts.client.configuration.cfg",
            null);//from   ww  w.java  2s  . c om
    Dictionary<String, Object> properties = new Hashtable<>();

    properties.put("address",
            DynamicUrl.SECURE_ROOT + HTTPS_PORT.getPort() + "/services/SecurityTokenService?wsdl");
    stsClientConfig.update(properties);
}

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

public void refreshFailure(BlueprintEvent event) {
    Dictionary<String, Object> props = init(event);

    Throwable th = event.getCause();
    props.put(EXCEPTION, th);
    props.put(CAUSE, th);/*from www .jav  a  2 s  . co m*/
    props.put(EXCEPTION_CLASS, th.getClass().getName());
    String msg = th.getMessage();
    props.put(EXCEPTION_MESSAGE, (msg != null ? msg : ""));
    initDependencies(props, event);
    sendEvent(new Event(TOPIC_FAILURE, props));
}

From source file:org.opencastproject.feed.scanner.FeedRegistrationScanner.java

/**
 * {@inheritDoc}/*from  w w  w . j ava 2s  . c o  m*/
 * 
 * @see org.apache.felix.fileinstall.ArtifactInstaller#install(java.io.File)
 */
@Override
public void install(File artifact) throws Exception {
    logger.info("Installing a feed from {}", artifact.getAbsolutePath());
    Properties props = new Properties();
    FileInputStream in = null;
    try {
        in = new FileInputStream(artifact);
        props.load(in);
    } finally {
        IOUtils.closeQuietly(in);
    }
    // Always include the server URL obtained from the bundle context
    props.put("org.opencastproject.server.url", bundleContext.getProperty("org.opencastproject.server.url"));
    Class<?> clazz = getClass().getClassLoader().loadClass(props.getProperty(FEED_CLASS));
    FeedGenerator generator = (FeedGenerator) clazz.newInstance();
    generator.setSearchService(searchService);
    generator.setSeriesService(seriesService);
    generator.initialize(props);
    ServiceRegistration reg = bundleContext.registerService(FeedGenerator.class.getName(), generator, null);
    generators.put(artifact, reg);
    sumInstalledFiles++;

    // Determine the number of available profiles
    String[] filesInDirectory = artifact.getParentFile().list(new FilenameFilter() {
        public boolean accept(File arg0, String name) {
            return name.endsWith(".properties");
        }
    });

    // Once all profiles have been loaded, announce readiness
    if (filesInDirectory.length == sumInstalledFiles) {
        Dictionary<String, String> properties = new Hashtable<String, String>();
        properties.put(ARTIFACT, "feed");
        logger.debug("Indicating readiness of feed");
        bundleContext.registerService(ReadinessIndicator.class.getName(), new ReadinessIndicator(), properties);
        logger.info("All {} feeds installed", filesInDirectory.length);
    } else {
        logger.debug("{} of {} feeds installed", sumInstalledFiles, filesInDirectory.length);
    }
}