List of usage examples for java.util Dictionary put
public abstract V put(K key, V value);
From source file:org.apache.sling.extensions.logback.integration.ITJULIntegration.java
/** * Checks the default settings. It runs the bundle with minimum dependencies */// www. j ava 2 s. c o m @Test public void testJULLogging() throws Exception { java.util.logging.Logger julLogger = java.util.logging.Logger.getLogger("foo.jul.1"); org.slf4j.Logger slf4jLogger = LoggerFactory.getLogger("foo.jul.1"); assertEquals(java.util.logging.Level.FINEST, julLogger.getLevel()); assertTrue(slf4jLogger.isTraceEnabled()); //Now add an appender and see if JUL logs are handled TestAppender ta = new TestAppender(); Dictionary<String, Object> props = new Hashtable<String, Object>(); String[] loggers = { "foo.jul.1:INFO", }; props.put("loggers", loggers); ServiceRegistration sr = bundleContext.registerService(Appender.class.getName(), ta, props); delay(); //Level should be INFO now assertEquals(java.util.logging.Level.INFO, julLogger.getLevel()); julLogger.info("Info message"); julLogger.fine("Fine message"); assertEquals(1, ta.events.size()); }
From source file:org.ow2.chameleon.fuchsia.importer.jsonrpc.it.JSONRPCImporterTest.java
@Before public void setUpFinal() { // instantiate the importer Dictionary<String, String> conf = new Hashtable<String, String>(); conf.put(INSTANCE_NAME_PROPERTY, IMPORTER_NAME); conf.put(TARGET_FILTER_PROPERTY, "(" + CONFIGS + "=jsonrpc)"); ComponentInstance importer = ipojoHelper .createComponentInstance("org.ow2.chameleon.fuchsia.importer.jsonrpc.JSONRPCImporter", conf, 20000); if (importer == null) { fail("Fail to create the JSONRPC Importer."); }//from w w w . jav a 2s. co m // create HttpServer try { httpServer = HttpServer.create(new InetSocketAddress(HTTP_PORT), 0); } catch (IOException e) { fail("Creation of httpServer fail", e); } httpServer.setExecutor(Executors.newCachedThreadPool()); httpServer.start(); }
From source file:net.di2e.ddf.argo.probe.responselistener.ProbeResponseEndpoint.java
private void createSource(String factoryPid, String sourceId, String url) { try {//from w w w.j a va 2 s . co m // need to use the 2 parameter method and pass in null, otherwise we will get an error Configuration siteConfig = configAdmin.createFactoryConfiguration(factoryPid, null); Dictionary<String, Object> properties = new Hashtable<>(); properties.put("url", url); properties.put("id", sourceId); LOGGER.debug("Creating new source named '{}' that points to '{}'", sourceId, url); siteConfig.update(properties); } catch (IOException ioe) { LOGGER.warn("Could not create new source due to error with config admin.", ioe); } }
From source file:org.ops4j.pax.scanner.common.AbstractScannerActivator.java
/** * Registers a managed service to listen on configuration updates. *///from w w w . j a va2s .co m private void registerManagedService() { final Dictionary<String, String> props = new Hashtable<String, String>(); props.put(Constants.SERVICE_PID, getPID()); m_managedServiceReg = m_bundleContext.registerService(ManagedService.class.getName(), new ManagedService() { /** * Sets the resolver on scanner. * * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary) */ public void updated(final Dictionary config) throws ConfigurationException { if (config == null) { setResolver(new BundleContextPropertyResolver(m_bundleContext)); } else { setResolver(new DictionaryPropertyResolver(config, new BundleContextPropertyResolver(m_bundleContext))); } } }, props); }
From source file:com.adobe.acs.commons.http.injectors.AbstractHtmlRequestInjector.java
@SuppressWarnings("squid:S1149") protected final void registerAsSlingFilter(ComponentContext ctx, int ranking, String pattern) { Dictionary<String, String> filterProps = new Hashtable<String, String>(); filterProps.put("service.ranking", String.valueOf(ranking)); filterProps.put("sling.filter.scope", "REQUEST"); filterProps.put("sling.filter.pattern", StringUtils.defaultIfEmpty(pattern, ".*")); filterRegistration = ctx.getBundleContext().registerService(Filter.class.getName(), this, filterProps); }
From source file:org.wso2.carbon.identity.authenticator.saml2.sso.ui.internal.SAML2SSOAuthenticatorUIDSComponent.java
protected void activate(ComponentContext ctxt) { try {//w w w . java2s . c om if (Util.isAuthenticatorEnabled()) { // initialize the SSO Config params during the start-up boolean initSuccess = Util.initSSOConfigParams(); if (initSuccess) { HttpServlet loginServlet = new HttpServlet() { @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { throw new UnsupportedOperationException(); } }; Filter loginPageFilter = new LoginPageFilter(); Dictionary loginPageFilterProps = new Hashtable(2); Dictionary redirectorParams = new Hashtable(3); redirectorParams.put("url-pattern", Util.getLoginPage()); redirectorParams.put("associated-filter", loginPageFilter); redirectorParams.put("servlet-attributes", loginPageFilterProps); ctxt.getBundleContext().registerService(Servlet.class.getName(), loginServlet, redirectorParams); // register the UI authenticator SAML2SSOUIAuthenticator authenticator = new SAML2SSOUIAuthenticator(); Hashtable<String, String> props = new Hashtable<String, String>(); props.put(CarbonConstants.AUTHENTICATOR_TYPE, authenticator.getAuthenticatorName()); ctxt.getBundleContext().registerService(CarbonUIAuthenticator.class.getName(), authenticator, props); if (log.isDebugEnabled()) { log.debug("SAML2 SSO Authenticator BE Bundle activated successfully."); } } else { log.warn( "Initialization failed for SSO Authenticator. Starting with the default authenticator"); } } else { if (log.isDebugEnabled()) { log.debug("SAML2 SSO Authenticator is disabled"); } } } catch (Throwable e) { log.error("Saml Authentication Failed"); } }
From source file:com.adobe.acs.commons.http.injectors.AbstractHtmlRequestInjector.java
@SuppressWarnings("squid:S1149") protected final void registerAsFilter(ComponentContext ctx, int ranking, String pattern) { Dictionary<String, String> filterProps = new Hashtable<String, String>(); filterProps.put("service.ranking", String.valueOf(ranking)); filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_REGEX, StringUtils.defaultIfEmpty(pattern, ".*")); filterProps.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT, "(" + HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME + "=*)"); filterRegistration = ctx.getBundleContext().registerService(Filter.class.getName(), this, filterProps); }
From source file:org.opencastproject.runtimeinfo.Activator.java
@Override public void start(BundleContext bundleContext) throws Exception { this.bundleContext = bundleContext; Dictionary<String, String> props = new Hashtable<String, String>(); props.put("alias", "/docs.html"); prepareMacros();/*from w w w . ja v a 2s . c om*/ bundleContext.registerService(Servlet.class.getName(), this, props); }
From source file:org.codice.ddf.registry.publication.action.provider.RegistryPublicationActionProviderTest.java
@Test public void testCanHandleRegistryConfig() throws Exception { Dictionary<String, Object> properties = new Hashtable<>(); properties.put(RegistryConstants.CONFIGURATION_REGISTRY_ID_PROPERTY, "regId1"); when(configuration.getProperties()).thenReturn(properties); assertThat(publicationActionProvider.canHandle(configuration), is(true)); }
From source file:org.eclipse.swordfish.core.configuration.ConfigurationConsumerRegistry.java
@Override protected void doRegister(ConfigurationConsumer configurationConsumer, Map<String, ?> properties) throws Exception { Assert.notNull(configurationConsumer); Dictionary props = new Hashtable(); LOG.info("Registering configurationConsumer with id = " + configurationConsumer.getId()); Assert.notNull(configurationConsumer.getId()); props.put(Constants.SERVICE_PID, configurationConsumer.getId()); registrations.put(configurationConsumer, bundleContext.registerService(ManagedService.class.getName(), new ManagedServiceAdapter(configurationConsumer), props)); super.doRegister(configurationConsumer, properties); }