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.opennaas.extensions.roadm.wonesys.transports.rawsocket.RawSocketTransport.java

protected Event createErrorEvent(String eventTopic, Exception err) {
    Dictionary<String, Object> properties = new Hashtable<String, Object>();
    properties.put(RawSocketTransport.TRANSPORT_ID_PROPERTY_NAME, getTransportID());
    properties.put(RawSocketTransport.ARRIVAL_TIME_PROPERTY_NAME, new Date().getTime());
    if (err != null)
        properties.put(ERROR_PROPERTY_NAME, err);

    return new Event(eventTopic, properties);
}

From source file:org.apache.sling.hc.core.impl.JmxAdjustableStatusForTesting.java

private synchronized void registerDynamicTestingHealthCheck(Result.Status status, String[] tags) {
    unregisterDynamicTestingHealthCheck();
    HealthCheck healthCheck = new DynamicTestingHealthCheck(status);
    Dictionary<String, Object> props = new Hashtable<String, Object>();
    props.put(HealthCheck.NAME, "JMX-adjustable Testing Check");
    props.put(HealthCheck.TAGS, tags);//from  ww w .j a  v a2s  . c om

    healthCheckRegistration = bundleContext.registerService(HealthCheck.class.getName(), healthCheck, props);

}

From source file:SliderTest.java

public SliderTestFrame() {
    setTitle("SliderTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    sliderPanel = new JPanel();
    sliderPanel.setLayout(new FlowLayout(FlowLayout.LEFT));

    // common listener for all sliders
    listener = new ChangeListener() {
        public void stateChanged(ChangeEvent event) {
            // update text field when the slider value changes
            JSlider source = (JSlider) event.getSource();
            textField.setText("" + source.getValue());
        }/*from   w  w  w  .  j a  v a 2 s. c o m*/
    };

    // add a plain slider

    JSlider slider = new JSlider();
    addSlider(slider, "Plain");

    // add a slider with major and minor ticks

    slider = new JSlider();
    slider.setPaintTicks(true);
    slider.setMajorTickSpacing(20);
    slider.setMinorTickSpacing(5);
    addSlider(slider, "Ticks");

    // add a slider that snaps to ticks

    slider = new JSlider();
    slider.setPaintTicks(true);
    slider.setSnapToTicks(true);
    slider.setMajorTickSpacing(20);
    slider.setMinorTickSpacing(5);
    addSlider(slider, "Snap to ticks");

    // add a slider with no track

    slider = new JSlider();
    slider.setPaintTicks(true);
    slider.setMajorTickSpacing(20);
    slider.setMinorTickSpacing(5);
    slider.setPaintTrack(false);
    addSlider(slider, "No track");

    // add an inverted slider

    slider = new JSlider();
    slider.setPaintTicks(true);
    slider.setMajorTickSpacing(20);
    slider.setMinorTickSpacing(5);
    slider.setInverted(true);
    addSlider(slider, "Inverted");

    // add a slider with numeric labels

    slider = new JSlider();
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);
    slider.setMajorTickSpacing(20);
    slider.setMinorTickSpacing(5);
    addSlider(slider, "Labels");

    // add a slider with alphabetic labels

    slider = new JSlider();
    slider.setPaintLabels(true);
    slider.setPaintTicks(true);
    slider.setMajorTickSpacing(20);
    slider.setMinorTickSpacing(5);

    Dictionary<Integer, Component> labelTable = new Hashtable<Integer, Component>();
    labelTable.put(0, new JLabel("A"));
    labelTable.put(20, new JLabel("B"));
    labelTable.put(40, new JLabel("C"));
    labelTable.put(60, new JLabel("D"));
    labelTable.put(80, new JLabel("E"));
    labelTable.put(100, new JLabel("F"));

    slider.setLabelTable(labelTable);
    addSlider(slider, "Custom labels");

    // add a slider with icon labels

    slider = new JSlider();
    slider.setPaintTicks(true);
    slider.setPaintLabels(true);
    slider.setSnapToTicks(true);
    slider.setMajorTickSpacing(20);
    slider.setMinorTickSpacing(20);

    labelTable = new Hashtable<Integer, Component>();

    // add card images

    labelTable.put(0, new JLabel(new ImageIcon("nine.gif")));
    labelTable.put(20, new JLabel(new ImageIcon("ten.gif")));
    labelTable.put(40, new JLabel(new ImageIcon("jack.gif")));
    labelTable.put(60, new JLabel(new ImageIcon("queen.gif")));
    labelTable.put(80, new JLabel(new ImageIcon("king.gif")));
    labelTable.put(100, new JLabel(new ImageIcon("ace.gif")));

    slider.setLabelTable(labelTable);
    addSlider(slider, "Icon labels");

    // add the text field that displays the slider value

    textField = new JTextField();
    add(sliderPanel, BorderLayout.CENTER);
    add(textField, BorderLayout.SOUTH);
}

From source file:com.liferay.portal.osgi.web.portlet.container.upload.test.UploadPortletTest.java

protected void registerMVCActionCommand(MVCActionCommand mvcActionCommand) throws Exception {

    Bundle bundle = FrameworkUtil.getBundle(getClass());

    BundleContext bundleContext = bundle.getBundleContext();

    Dictionary<String, Object> properties = new HashMapDictionary<>();

    properties.put("javax.portlet.name", TestUploadPortlet.PORTLET_NAME);
    properties.put("mvc.command.name", TestUploadPortlet.MVC_COMMAND_NAME);

    ServiceRegistration<MVCActionCommand> serviceRegistration = bundleContext
            .registerService(MVCActionCommand.class, mvcActionCommand, properties);

    serviceRegistrations.add(serviceRegistration);
}

From source file:org.openhab.binding.configadmin.internal.ConfigAdminBinding.java

/**
 * @{inheritDoc//from w w w.  ja  v  a2  s.com
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void internalReceiveCommand(String itemName, Command command) {
    if (configAdmin != null) {
        for (ConfigAdminBindingProvider provider : this.providers) {
            ConfigAdminBindingConfig bindingConfig = provider.getBindingConfig(itemName);
            Configuration config = getConfiguration(bindingConfig);
            if (config != null) {
                Dictionary props = config.getProperties();
                props.put(bindingConfig.configParameter, command.toString());
                try {
                    config.update(props);
                } catch (IOException ioe) {
                    logger.error("updating Configuration '{}' with '{}' failed", bindingConfig.normalizedPid,
                            command.toString());
                }
                logger.debug("successfully updated configuration (pid={}, value={})",
                        bindingConfig.normalizedPid, command.toString());
            } else {
                logger.info("There is no configuration found for pid '{}'", bindingConfig.normalizedPid);
            }
        }
    }
}

From source file:io.neba.core.resourcemodels.adaptation.ResourceToModelAdapterUpdater.java

private Dictionary<String, Object> createResourceToModelAdapterProperties() {
    Dictionary<String, Object> properties = new Hashtable<>();
    Set<String> fullyQualifiedNamesOfRegisteredModels = getAdapterTypeNames();
    properties.put(ADAPTER_CLASSES, fullyQualifiedNamesOfRegisteredModels.toArray());
    properties.put(ADAPTABLE_CLASSES, new String[] { Resource.class.getName() });
    properties.put(SERVICE_VENDOR, "neba.io");
    properties.put(SERVICE_DESCRIPTION, "Adapts Resources to @ResourceModels.");
    return properties;
}

From source file:org.apache.sling.hc.core.impl.JmxAdjustableStatusForTesting.java

private void registerMbean() {
    final Dictionary<String, String> mbeanProps = new Hashtable<String, String>();
    mbeanProps.put("jmx.objectname", OBJECT_NAME);
    AdjustableHealthCheckStatusMBean adjustableHealthCheckStatusMBean = new AdjustableHealthCheckStatusMBean();
    this.mbeanRegistration = bundleContext.registerService(DynamicMBean.class.getName(),
            adjustableHealthCheckStatusMBean, mbeanProps);
    LOG.debug("Registered mbean {} as {}", adjustableHealthCheckStatusMBean, OBJECT_NAME);
}

From source file:org.apache.sling.superimposing.impl.SuperimposingResourceProviderImpl.java

void registerService(BundleContext context) {
    final Dictionary<String, Object> props = new Hashtable<String, Object>();
    props.put(Constants.SERVICE_DESCRIPTION, "Provider of superimposed resources");
    props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
    props.put(ROOTS, new String[] { rootPath });

    registration = context.registerService(SERVICE_NAME, this, props);

    log.info("Registered {}", this);
}

From source file:com.liferay.portal.osgi.web.portlet.container.upload.test.UploadPortletTest.java

protected void registerMVCPortlet(Portlet portlet) throws Exception {
    Dictionary<String, Object> properties = new HashMapDictionary<>();

    properties.put("com.liferay.portlet.private-request-attributes", Boolean.FALSE.toString());
    properties.put("com.liferay.portlet.private-session-attributes", Boolean.FALSE.toString());
    properties.put("com.liferay.portlet.scopeable", Boolean.TRUE.toString());
    properties.put("com.liferay.portlet.struts-path", TestUploadPortlet.MVC_PATH);
    properties.put("com.liferay.portlet.use-default-template", Boolean.TRUE.toString());
    properties.put("com.liferay.portlet.webdav-storage-token", TestUploadPortlet.MVC_PATH);
    properties.put("javax.portlet.display-name", "Test Upload Portlet");
    properties.put("javax.portlet.expiration-cache", "0");
    properties.put("javax.portlet.init-param.check-auth-token", Boolean.FALSE.toString());
    properties.put("javax.portlet.init-param.single-page-application-cacheable", Boolean.FALSE.toString());
    properties.put("javax.portlet.init-param.template-path", "/");
    properties.put("javax.portlet.init-param.view-template",
            "/" + TestUploadPortlet.PORTLET_NAME + "/view.jsp");
    properties.put("javax.portlet.name", TestUploadPortlet.PORTLET_NAME);
    properties.put("javax.portlet.resource-bundle", "content.Language");
    properties.put("javax.portlet.security-role-ref", "guest,power-user,user");
    properties.put("javax.portlet.supports.mime-type", "text/html");

    setUpPortlet(portlet, properties, TestUploadPortlet.PORTLET_NAME);
}

From source file:org.eclipse.gemini.blueprint.blueprint.container.support.BlueprintContainerServicePublisher.java

private void registerService(ApplicationContext applicationContext) {
    final Dictionary<String, Object> serviceProperties = new Hashtable<String, Object>();

    Bundle bundle = bundleContext.getBundle();
    String symName = bundle.getSymbolicName();
    serviceProperties.put(Constants.BUNDLE_SYMBOLICNAME, symName);
    serviceProperties.put(BLUEPRINT_SYMNAME, symName);

    Version version = OsgiBundleUtils.getBundleVersion(bundle);
    serviceProperties.put(Constants.BUNDLE_VERSION, version);
    serviceProperties.put(BLUEPRINT_VERSION, version);

    log.info("Publishing BlueprintContainer as OSGi service with properties " + serviceProperties);

    // export just the interface
    final String[] serviceNames = new String[] { BlueprintContainer.class.getName() };

    if (log.isDebugEnabled())
        log.debug("Publishing service under classes " + ObjectUtils.nullSafeToString(serviceNames));

    AccessControlContext acc = SecurityUtils.getAccFrom(applicationContext);

    // publish service
    if (System.getSecurityManager() != null) {
        registration = AccessController.doPrivileged(new PrivilegedAction<ServiceRegistration>() {
            public ServiceRegistration run() {
                return bundleContext.registerService(serviceNames, blueprintContainer, serviceProperties);
            }/*from w ww.j  av a 2  s.  co m*/
        }, acc);
    } else {
        registration = bundleContext.registerService(serviceNames, blueprintContainer, serviceProperties);
    }
}