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.ITConfigAdminSupport.java
@Test public void testChangeGlobalConfig() throws Exception { //Set log level to debug for Root logger Configuration config = ca.getConfiguration(PID, null); Dictionary<String, Object> p = new Hashtable<String, Object>(); p.put(LOG_LEVEL, "DEBUG"); config.update(p);/* w ww . j av a 2 s . c o m*/ delay(); assertTrue(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME).isDebugEnabled()); //Reset back to Info config = ca.getConfiguration(PID, null); p = new Hashtable<String, Object>(); p.put(LOG_LEVEL, "INFO"); config.update(p); delay(); assertTrue(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME).isInfoEnabled()); assertFalse(LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME).isDebugEnabled()); }
From source file:io.neba.core.resourcemodels.registration.MappableTypeHierarchyChangeListenerTest.java
private void withChangeOn(String path) { Dictionary<String, Object> properties = new Hashtable<>(); properties.put("path", path); Event event = new Event("test/topic", properties); this.testee.handleEvent(event); }
From source file:org.apache.jackrabbit.oak.spi.blob.osgi.FileBlobStoreService.java
@Activate protected void activate(ComponentContext context, Map<String, Object> config) { String homeDir = lookup(context, PROP_HOME); if (homeDir != null) { log.info("Initializing the FileBlobStore with homeDir [{}]", homeDir); }/*w w w .j ava 2 s.co m*/ BlobStore blobStore = new FileBlobStore(FilenameUtils.concat(homeDir, "datastore")); PropertiesUtil.populate(blobStore, config, false); Dictionary<String, Object> props = new Hashtable<String, Object>(); if (context.getProperties().get(PROP_SPLIT_BLOBSTORE) != null) { props.put(PROP_SPLIT_BLOBSTORE, context.getProperties().get(PROP_SPLIT_BLOBSTORE)); } reg = context.getBundleContext().registerService( new String[] { BlobStore.class.getName(), GarbageCollectableBlobStore.class.getName() }, blobStore, props); }
From source file:org.ops4j.pax.scanner.common.AbstractScannerActivator.java
/** * Registers the scanner. Will be used by provisioning service via white box pattern. *//*from w w w .j av a 2 s . c o m*/ private void registerScanner() { m_scanner = createScanner(m_bundleContext); final Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put(Scanner.SCHEMA_PROPERTY, getSchema()); m_scannerReg = m_bundleContext.registerService(Scanner.class.getName(), m_scanner, props); }
From source file:com.machinelinking.stanbol.enhancer.engines.machinelinking.impl.MLAnnotateEnhancementEngineTest.java
@Before public void setUp() throws IOException, ConfigurationException { annotateEngine = new MLAnnotateEnhancementEngine(); // Activation. Dictionary<String, Object> properties = new Hashtable<String, Object>(); properties.put(EnhancementEngine.PROPERTY_NAME, "machinelinkingLangId"); properties.put(MLConstants.APP_ID, System.getProperty(MLConstants.APP_ID, MLTestConstants.APP_ID)); properties.put(MLConstants.APP_KEY, System.getProperty(MLConstants.APP_KEY, MLTestConstants.APP_KEY)); properties.put(MLConstants.CONNECTION_TIMEOUT, 30 * 1000); //enable topic properties.put(MLConstants.TOPIC, Boolean.TRUE); annotateEngine.activate(new MockComponentContext(properties)); }
From source file:org.wso2.carbon.apimgt.authenticator.oidc.ui.internal.OIDCAuthenticatorUIDSComponent.java
protected void activate(ComponentContext ctxt) { if (Util.isAuthenticatorEnabled()) { // initialize the OIDC Config params during the start-up boolean initSuccess = Util.initOIDCConfigParams(); if (initSuccess) { HttpServlet loginServlet = new HttpServlet() { @Override//from w w w . ja v a 2 s . c o m protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { } }; Filter loginPageFilter = new LoginPageFilter(); Dictionary loginPageFilterProps = new Hashtable(2); Dictionary redirectionParams = new Hashtable(3); redirectionParams.put("url-pattern", Util.getLoginPage()); redirectionParams.put("associated-filter", loginPageFilter); redirectionParams.put("servlet-attributes", loginPageFilterProps); ctxt.getBundleContext().registerService(Servlet.class.getName(), loginServlet, redirectionParams); // register the UI authenticator OIDCUIAuthenticator authenticator = new OIDCUIAuthenticator(); 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("OIDC Authenticator FE Bundle activated successfully."); } } else { log.warn("Initialization failed for OIDC Authenticator. Starting with the default authenticator"); } } else { if (log.isDebugEnabled()) { log.debug("OIDC Authenticator is disabled"); } } }
From source file:org.opencastproject.workflow.handler.ResumableWorkflowOperationHandlerBase.java
/** * Registers the resource identified by <code>resourcePath</code> as the ui to be displayed during hold. * //w w w . j av a 2s . c om * @param resourcePath * the path to the resource * @return the URL that was created when registering the resource */ protected String registerHoldStateUserInterface(final String resourcePath) { String alias = "/workflow/hold/" + getClass().getName().toLowerCase(); if (resourcePath == null) throw new IllegalArgumentException("Classpath must not be null"); String path = FilenameUtils.getPathNoEndSeparator(resourcePath); String welcomeFile = FilenameUtils.getName(resourcePath); staticResource = new StaticResource(getClass().getClassLoader(), path, alias, welcomeFile); Dictionary<String, String> props = new Hashtable<String, String>(); props.put("contextId", RestConstants.HTTP_CONTEXT_ID); props.put("alias", alias); staticResourceRegistration = componentContext.getBundleContext().registerService(Servlet.class.getName(), staticResource, props); return staticResource.getDefaultUrl(); }
From source file:com.adobe.acs.commons.logging.impl.SyslogAppender.java
@Activate @SuppressWarnings("squid:S1149") protected void activate(ComponentContext ctx) { final Dictionary<?, ?> properties = ctx.getProperties(); final String[] loggers = PropertiesUtil.toStringArray(properties.get(PROP_LOGGERS), new String[] { ROOT }); final String suffixPattern = PropertiesUtil.toString(properties.get(PROP_SUFFIX_PATTERN), DEFAULT_SUFFIX_PATTERN);/*from w w w . j a v a 2 s.co m*/ final int port = PropertiesUtil.toInteger(properties.get(PROP_PORT), DEFAULT_PORT); final String host = PropertiesUtil.toString(properties.get(PROP_HOST), null); final String facility = PropertiesUtil.toString(properties.get(PROP_FACILITY), DEFAULT_FACILITY); final String stackTracePattern = PropertiesUtil.toString(properties.get(PROP_STACK_TRACE_PATTERN), null); final boolean throwableExcluded = PropertiesUtil.toBoolean(properties.get(PROP_THROWABLE_EXCLUDED), DEFAULT_THROWABLE_EXCLUDED); if (host == null || port == -1) { throw new IllegalArgumentException( "Syslog Appender not configured correctly. Both host and port need to be provided."); } // throws a descriptive IllegalArgumentException if facility is not valid. SyslogAppenderBase.facilityStringToint(facility); final BundleContext bundleContext = ctx.getBundleContext(); appender = new ch.qos.logback.classic.net.SyslogAppender(); appender.setSyslogHost(host); appender.setPort(port); appender.setFacility(facility); appender.setSuffixPattern(suffixPattern); if (StringUtils.isNotEmpty(stackTracePattern)) { appender.setStackTracePattern(stackTracePattern); } appender.setThrowableExcluded(throwableExcluded); Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put("loggers", loggers); appenderRegistration = bundleContext.registerService(Appender.class.getName(), appender, props); }
From source file:org.paxle.tools.ieporter.cm.impl.ConfigurationIEPorterTest.java
public void testExportConfiguration() throws ParserConfigurationException { final Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put("myProperty.Integer", Integer.valueOf(1)); props.put("myProperty.intArray", new int[] { 1, 2, 3, 4 }); props.put("myProperty.String", "test"); props.put("myProperty.StringArray", new String[] { "test1", "test2", "test3" }); final Configuration config = mock(Configuration.class); checking(new Expectations() { {//from w ww.ja va 2 s. c o m atLeast(1).of(config).getPid(); will(returnValue("testPid")); atLeast(1).of(config).getProperties(); will(returnValue(props)); never(config); } }); Map<String, Document> configs = this.ieporter.exportConfiguration(config); assertNotNull(configs); assertEquals(1, configs.size()); assertTrue(configs.containsKey("testPid")); Document doc = configs.get("testPid"); assertNotNull(doc); JXPathContext objContext = JXPathContext.newContext(doc); assertEquals("testPid", objContext.getValue("//service.pid")); assertEquals(props.size(), ((Double) objContext.getValue("count(//property)")).intValue()); assertEquals(props.get("myProperty.Integer").toString(), objContext.getValue("//property[@key='myProperty.Integer']/value")); assertEquals(Array.getLength(props.get("myProperty.intArray")), ((Double) objContext.getValue("count(//property[@key='myProperty.intArray']/values/value)")) .intValue()); assertEquals(props.get("myProperty.String").toString(), objContext.getValue("//property[@key='myProperty.String']/value")); assertEquals(Array.getLength(props.get("myProperty.StringArray")), ((Double) objContext.getValue("count(//property[@key='myProperty.StringArray']/values/value)")) .intValue()); }
From source file:org.apache.sling.commons.log.logback.integration.ITConfigPrinter.java
@Test public void includeOnlyLastNFiles() throws Exception { waitForPrinter();/* www . j ava 2 s.c o m*/ Configuration config = ca.getConfiguration(PID, null); Dictionary<String, Object> p = new Hashtable<String, Object>(); p.put(LogConfigManager.PRINTER_MAX_INCLUDED_FILES, 3); p.put(LogConfigManager.LOG_LEVEL, "INFO"); config.update(p); delay(); createLogConfig("error.log", "includeOnlyLastNFiles", "includeOnlyLastNFiles.1"); //txt mode log should at least have mention of all files for (int i = 0; i < 10; i++) { FileUtils.touch(new File(logDir, "error.log." + i)); } StringWriter sw = new StringWriter(); invoke("printConfiguration", new PrintWriter(sw), "txt"); assertThat(sw.toString(), containsString("error.log")); for (int i = 0; i < 10; i++) { assertThat(sw.toString(), containsString("error.log." + i)); } //Attachment should only be upto 3 assertTrue(((URL[]) invoke("getAttachments", "zip")).length > 3); }