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.registry.resource.internal.RegistryMgtUIResourceServiceComponent.java

public void registerServlet(BundleContext bundleContext) throws Exception {

    if (registryService == null) {
        String msg = "Unable to Register Servlet. Registry Service Not Found.";
        log.error(msg);//  w ww.  j av  a  2  s  .c om
        throw new Exception(msg);
    }

    Dictionary servletParam = new Hashtable(2);
    servletParam.put("org.apache.abdera.protocol.server.Provider",
            "org.wso2.carbon.registry.app.RegistryProvider");
    Dictionary servletAttributes = new Hashtable(2);
    servletAttributes.put("registry", registryService);
    Dictionary params = new Hashtable(2);
    params.put("servlet-params", servletParam);
    params.put("url-pattern", "/registry/resources");
    params.put("servlet-attributes", servletAttributes);

    ResourceServlet resourceServlet = new ResourceServlet();
    // The HTTP Service must be available for this operation
    serviceRegistration = bundleContext.registerService(Servlet.class.getName(), resourceServlet, params);
}

From source file:org.apache.camel.itest.osgi.servlet.support.ServletActivator.java

protected void registerServlet(BundleContext bundleContext) throws Exception {
    httpServiceRef = bundleContext.getServiceReference(HttpService.class.getName());

    if (httpServiceRef != null && !registerService) {
        LOG.info("Regist the servlet service");
        final HttpService httpService = (HttpService) bundleContext.getService(httpServiceRef);
        if (httpService != null) {
            // create a default context to share between registrations
            final HttpContext httpContext = httpService.createDefaultHttpContext();
            // register the hello world servlet
            final Dictionary<String, String> initParams = new Hashtable<String, String>();
            initParams.put("matchOnUriPrefix", "false");
            initParams.put("servlet-name", "camelServlet");
            httpService.registerServlet("/camel/services", // alias
                    (Servlet) new CamelHttpTransportServlet(), // register servlet
                    initParams, // init params
                    httpContext // http context
            );// w  w w.  java  2s. com
            registerService = true;
        }
    }
}

From source file:org.opennaas.extensions.roadm.wonesys.transports.mock.MockTransport.java

protected Event createEvent(String eventTopic, String message) {
    Dictionary<String, Object> properties = new Hashtable<String, Object>();
    properties.put(RawSocketTransport.TRANSPORT_ID_PROPERTY_NAME, getTransportID());
    if (message != null)
        properties.put(RawSocketTransport.MESSAGE_PROPERTY_NAME, message);

    return new Event(eventTopic, properties);
}

From source file:org.ms123.common.system.log.LogServiceImpl.java

protected void activate(BundleContext bundleContext, Map<?, ?> props) {
    System.out.println("LogEventHandlerService.activate.props:" + props);
    try {/*  ww w  . j a v  a2  s.  c  o  m*/
        Bundle b = bundleContext.getBundle();
        m_bundleContext = bundleContext;
        Dictionary d = new Hashtable();
        d.put(EventConstants.EVENT_TOPIC, topics);
        b.getBundleContext().registerService(EventHandler.class.getName(), this, d);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.eclipse.virgo.snaps.core.internal.SnapUtilsTests.java

@Test
public void getSnapContextPath() {
    Dictionary<String, String> p = new Hashtable<String, String>();
    p.put(SnapUtils.HEADER_SNAP_CONTEXT_PATH, "snap");

    Bundle bundle = createMock(Bundle.class);
    expect(bundle.getHeaders()).andReturn(p);

    replay(bundle);//from w w  w.  ja  v  a  2s.co m
    assertEquals("snap", SnapUtils.getSnapContextPath(bundle));
    verify(bundle);
}

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

/**
 * OSGi callback on component activation.
 *
 * @param  ctx  the bundle context/*from  w  ww  .  ja va  2s.  c om*/
 */
void activate(BundleContext ctx) {
    logger.info("Activating regexp based DictionaryService");
    Dictionary<String, String> properties = new Hashtable<String, String>();
    properties.put(ARTIFACT, "dictionary");
    ctx.registerService(ReadinessIndicator.class.getName(), new ReadinessIndicator(), properties);
}

From source file:org.wso2.msf4j.osgi.test.MSF4JOSGiTest.java

@Test
public void testDynamicServiceRegistration() throws IOException {
    Dictionary<String, String> properties = new Hashtable<>();
    properties.put("contextPath", "/BasePathV1");
    bundleContext.registerService(Microservice.class, new TestService(), properties);

    // Register same service with different base path
    properties.put("contextPath", "/BasePathV2");
    bundleContext.registerService(Microservice.class, new TestService(), properties);

    //Register some other service
    bundleContext.registerService(Microservice.class, new SecondService(), null);

    HttpURLConnection urlConn = request("/BasePathV1/hello", HttpMethod.GET);
    assertEquals(200, urlConn.getResponseCode());
    String content = getContent(urlConn);
    assertEquals("Hello MSF4J from TestService", content);
    urlConn.disconnect();//www. j  a v  a 2  s .  c om

    urlConn = request("/BasePathV2/hello", HttpMethod.GET);
    assertEquals(200, urlConn.getResponseCode());
    content = getContent(urlConn);
    assertEquals("Hello MSF4J from TestService", content);
    urlConn.disconnect();
}

From source file:org.wso2.carbon.appfactory.ext.internal.AppFactoryExtDS.java

@SuppressWarnings("UnusedDeclaration")
protected void activate(ComponentContext context) {

    context.getBundleContext().registerService(UserOperationEventListener.class.getName(),
            new AppFactoryUserOperationEventListener(), null);

    context.getBundleContext().registerService(AuthorizationManagerListener.class.getName(),
            new AppFactoryAuthorizationManagerListener(), null);

    context.getBundleContext().registerService(ClaimManagerListener.class.getName(),
            new AppFactoryClaimManagerListener(), null);

    Dictionary props = new Hashtable();
    props.put(CarbonConstants.AXIS2_CONFIG_SERVICE, AxisObserver.class.getName());
    context.getBundleContext().registerService(AxisObserver.class.getName(), new ServiceDeploymentListener(),
            props);/*from  w  w  w  .j  av a  2s .c o  m*/

    PreAxisConfigurationPopulationObserver preAxisConfigObserver = new PreAxisConfigurationPopulationObserver() {
        public void createdAxisConfiguration(AxisConfiguration axisConfiguration) {
            axisConfiguration.addObservers(new ServiceDeploymentListener());
        }
    };
    context.getBundleContext().registerService(PreAxisConfigurationPopulationObserver.class.getName(),
            preAxisConfigObserver, null);

    leaderElector = LeaderElector.getInstance();
    if (log.isDebugEnabled()) {
        log.debug("appfactory.ext service bundle is activated");
    }
}

From source file:ddf.common.test.AdminConfig.java

public void setLogLevels() throws IOException {
    String logLevel = System.getProperty(TEST_LOGLEVEL_PROPERTY);

    Configuration logConfig = configAdmin.getConfiguration(LOG_CONFIG_PID, null);
    Dictionary<String, Object> properties = logConfig.getProperties();

    properties.put(LOGGER_PREFIX + "*", DEFAULT_LOG_LEVEL);

    if (!StringUtils.isEmpty(logLevel)) {
        properties.put(LOGGER_PREFIX + "ddf", logLevel);
        properties.put(LOGGER_PREFIX + "org.codice", logLevel);
    }//from   www . j  av  a 2 s  . c om

    logConfig.update(properties);
}

From source file:org.wso2.carbon.attachment.mgt.server.internal.AttachmentServiceComponent.java

/**
 * Register the Servlet used to download attachments
 *///from   w  w  w  .  ja v a  2 s  .  c  o  m
private void registerAttachmentDownloadServlet() {
    HttpServlet attachmentDownloadServlet = new AttachmentDownloadServlet();
    Dictionary redirectorParams = new Hashtable(1);
    redirectorParams.put("url-pattern", "/attachment-mgt/download");
    //redirectorParams.put("url-pattern", "/t/carbon.super" + AttachmentMgtConfigurationConstants.ATTACHMENT_DOWNLOAD_SERVELET_URL_PATTERN);
    bundleContext.registerService(Servlet.class.getName(), attachmentDownloadServlet, redirectorParams);
    if (log.isDebugEnabled()) {
        log.debug("Attachment Download Servlet registered.");
    }
}