Java Code Examples for java.util.Dictionary#put()
The following examples show how to use
java.util.Dictionary#put() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BeanConfigurationFactory.java From neoscada with Eclipse Public License 1.0 | 6 votes |
public Dictionary<String, ?> getProperties () { try { final Dictionary<String, Object> result = new Hashtable<String, Object> (); final Map<?, ?> properties = new BeanUtilsBean2 ().describe ( this.targetBean ); for ( final Map.Entry<?, ?> entry : properties.entrySet () ) { if ( entry.getValue () != null ) { result.put ( entry.getKey ().toString (), entry.getValue () ); } } return result; } catch ( final Exception e ) { logger.warn ( "Failed to get dictionary", e ); return new Hashtable<String, Object> ( 1 ); } }
Example 2
Source File: DefaultSwingBundleDisplayer.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
public ServiceRegistration<SwingBundleDisplayer> register() { if (reg != null) { return reg; } open(); final Dictionary<String, Object> props = new Hashtable<String, Object>(); props.put(SwingBundleDisplayer.PROP_NAME, getName()); props.put(SwingBundleDisplayer.PROP_DESCRIPTION, getDescription()); props.put(SwingBundleDisplayer.PROP_ISDETAIL, isDetail() ? Boolean.TRUE : Boolean.FALSE); reg = Activator.getBC() .registerService(SwingBundleDisplayer.class, this, props); return reg; }
Example 3
Source File: RestCollectorTest.java From karaf-decanter with Apache License 2.0 | 6 votes |
@Test public void testPut() throws Exception { EventAdminMock eventAdminMock = new EventAdminMock(); RestCollector collector = new RestCollector(); Dictionary<String, Object> config = new Hashtable<>(); config.put("request.method", "PUT"); config.put("request", "test"); config.put("url", "http://localhost:9090/test/submit"); collector.unmarshaller = new RawUnmarshaller(); collector.dispatcher = eventAdminMock; collector.activate(config); collector.run(); Assert.assertEquals(1, eventAdminMock.postedEvents.size()); Event event = eventAdminMock.postedEvents.get(0); Assert.assertEquals(200, event.getProperty("http.response.code")); Assert.assertEquals("hello put test\n", event.getProperty("payload")); }
Example 4
Source File: LoggingConfigurationOSGiTest.java From carbon-kernel with Apache License 2.0 | 6 votes |
@Test public void testLog4j2ConfigUpdate() throws IOException, ConfigurationException { Logger logger = LoggerFactory.getLogger(LoggingConfigurationOSGiTest.class); Assert.assertNotNull(managedService, "Managed Service is null"); //default log level is "ERROR" Assert.assertEquals(logger.isErrorEnabled(), true); Assert.assertEquals(logger.isDebugEnabled(), false); Dictionary<String, Object> properties = new Hashtable<>(); String log4jConfigFilePath = Paths.get(loggingConfigDirectory, LOG4J2_CONFIG_FILE).toString(); properties.put(LOG4J2_CONFIG_FILE_KEY, log4jConfigFilePath); managedService.updated(properties); //updated log level is "DEBUG" Assert.assertEquals(logger.isDebugEnabled(), true); }
Example 5
Source File: Activator.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private void registerConsole () { try { final Console console = new Console ( this.manager ); final Dictionary<String, Object> properties = new Hashtable<String, Object> (); properties.put ( "osgi.command.scope", "hds" ); //$NON-NLS-1$ properties.put ( "osgi.command.function", new String[] { "list", "purgeAll", "remove", "create" } ); //$NON-NLS-1$ context.registerService ( Console.class, console, properties ); } catch ( final Exception e ) { logger.warn ( "Failed to register console", e ); //$NON-NLS-1$ } }
Example 6
Source File: JmxWrapperForMessagingClient.java From roboconf-platform with Apache License 2.0 | 6 votes |
/** * Constructor for tests only. * @param messagingClient * @param osgiHelper */ JmxWrapperForMessagingClient( IMessagingClient messagingClient, OsgiHelper osgiHelper ) { this.messagingClient = messagingClient != null ? messagingClient : new DismissClient(); // Register the object as service in the OSGi registry. // Apache Aries should then map it to a MBean if the JMX management // is available. It is a little bit dirty. BundleContext bundleCtx = osgiHelper.findBundleContext(); if( bundleCtx != null ) { this.logger.fine( "Running in an OSGi environment. Trying to register a MBean for the messaging." ); Dictionary<String,String> properties = new Hashtable<> (); properties.put( "jmx.objectname", "net.roboconf:type=messaging" ); try { this.serviceReg = bundleCtx.registerService( MessagingApiMBean.class, this, properties ); this.logger.fine( "A MBean was successfully registered for the messaging." ); } catch( Exception e ) { this.logger.severe( "A MBean could not be registered for the messaging." ); Utils.logException( this.logger, e ); } } }
Example 7
Source File: InterpretCommandTest.java From smarthome with Eclipse Public License 2.0 | 6 votes |
@Before public void setUp() throws IOException, InterruptedException { ttsService = new TTSServiceStub(); hliStub = new HumanLanguageInterpreterStub(); voice = new VoiceStub(); registerService(voice); registerService(hliStub); registerService(ttsService); Dictionary<String, Object> config = new Hashtable<String, Object>(); config.put(CONFIG_DEFAULT_TTS, ttsService.getId()); config.put(CONFIG_DEFAULT_HLI, hliStub.getId()); config.put(CONFIG_DEFAULT_VOICE, voice.getUID()); ConfigurationAdmin configAdmin = super.getService(ConfigurationAdmin.class); String pid = "org.eclipse.smarthome.voice"; Configuration configuration = configAdmin.getConfiguration(pid); configuration.update(config); }
Example 8
Source File: GroupCommandTriggerHandler.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
public GroupCommandTriggerHandler(Trigger module, BundleContext bundleContext) { super(module); this.groupName = (String) module.getConfiguration().get(CFG_GROUPNAME); this.command = (String) module.getConfiguration().get(CFG_COMMAND); this.types = Collections.singleton(ItemCommandEvent.TYPE); this.bundleContext = bundleContext; Dictionary<String, Object> properties = new Hashtable<>(); this.topic = "smarthome/items/"; properties.put("event.topics", topic); eventSubscriberRegistration = this.bundleContext.registerService(EventSubscriber.class.getName(), this, properties); }
Example 9
Source File: FileInventoryServiceFactory.java From camelinaction2 with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public void init() { Dictionary properties = new Properties(); properties.put( Constants.SERVICE_PID, "camelinaction.fileinventoryroutefactory"); registration = bundleContext.registerService(ManagedServiceFactory.class.getName(), this, properties); LOG.info("FileInventoryRouteCamelServiceFactory ready to accept " + "new config with PID=camelinaction.fileinventoryroutefactory-xxx"); }
Example 10
Source File: ConfigurationFactoryImpl.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override protected Entry<DaveDevice> createService ( final UserInformation userInformation, final String configurationId, final BundleContext context, final Map<String, String> parameters ) throws Exception { final DaveDevice device = new DaveDevice ( this.context, configurationId, parameters ); final Dictionary<String, String> properties = new Hashtable<String, String> (); properties.put ( "daveDevice", configurationId ); return new Entry<DaveDevice> ( configurationId, device, context.registerService ( DaveDevice.class, device, properties ) ); }
Example 11
Source File: ControllerTest.java From onos with Apache License 2.0 | 5 votes |
/** * Tests configuring the controller. */ @Test public void testConfiguration() { Dictionary<String, String> properties = new Hashtable<>(); properties.put("openflowPorts", "1,2,3,4,5"); properties.put("workerThreads", "5"); controller.setConfigParams(properties); IntStream.rangeClosed(1, 5) .forEach(i -> assertThat(controller.openFlowPorts, hasItem(i))); assertThat(controller.workerThreads, is(5)); }
Example 12
Source File: DataStoreSourceFactory.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override protected Entry<DataStoreDataSource> createService ( final UserInformation userInformation, final String configurationId, final BundleContext context, final Map<String, String> parameters ) throws Exception { logger.debug ( "Creating new memory source: {}", configurationId ); final DataStoreDataSource source = new DataStoreDataSource ( context, configurationId, this.executor, this.dataNodeTracker ); source.update ( parameters ); final Dictionary<String, String> properties = new Hashtable<String, String> (); properties.put ( DataSource.DATA_SOURCE_ID, configurationId ); this.objectPool.addService ( configurationId, source, properties ); return new Entry<DataStoreDataSource> ( configurationId, source ); }
Example 13
Source File: PCEPTopologyProviderBean.java From bgpcep with Eclipse Public License 1.0 | 5 votes |
PCEPTopologyProviderBeanCSS(final PCEPTopologyConfiguration configDependencies, final InstructionScheduler instructionScheduler, final PCEPTopologyProviderBean bean) { this.scheduler = instructionScheduler; this.sgi = this.scheduler.getIdentifier(); this.pcepTopoProvider = PCEPTopologyProvider.create(bean, this.scheduler, configDependencies); final Dictionary<String, String> properties = new Hashtable<>(); properties.put(PCEPTopologyProvider.class.getName(), configDependencies.getTopologyId().getValue()); this.serviceRegistration = bean.bundleContext .registerService(DefaultTopologyReference.class.getName(), this.pcepTopoProvider, properties); LOG.info("PCEP Topology Provider service {} registered", getIdentifier().getName()); this.cssRegistration = bean.cssp.registerClusterSingletonService(this); }
Example 14
Source File: FactoryImpl.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override protected Entry<AttributeDataSourceSummarizer> createService ( final UserInformation userInformation, final String configurationId, final BundleContext context, final Map<String, String> parameters ) throws Exception { final AttributeDataSourceSummarizer service = new AttributeDataSourceSummarizer ( this.executor, this.tracker ); service.update ( parameters ); final Dictionary<String, String> properties = new Hashtable<String, String> (); properties.put ( DataSource.DATA_SOURCE_ID, configurationId ); this.pool.addService ( configurationId, service, properties ); return new Entry<AttributeDataSourceSummarizer> ( configurationId, service ); }
Example 15
Source File: ConfigController.java From packagedrone with Eclipse Public License 1.0 | 5 votes |
private void put ( final Dictionary<String, Object> properties, final String key, final Object value ) { if ( value instanceof String && ( (String)value ).isEmpty () ) { return; } if ( value != null ) { properties.put ( key, value ); } }
Example 16
Source File: ThingManagerOSGiJavaTest.java From smarthome with Eclipse Public License 2.0 | 5 votes |
private void configureAutoLinking(Boolean on) throws IOException { ConfigurationAdmin configAdmin = getService(ConfigurationAdmin.class); org.osgi.service.cm.Configuration config = configAdmin.getConfiguration("org.eclipse.smarthome.links", null); Dictionary<String, Object> properties = config.getProperties(); if (properties == null) { properties = new Hashtable<>(); } properties.put("autoLinks", on.toString()); config.update(properties); }
Example 17
Source File: ChannelEventTriggerHandler.java From openhab-core with Eclipse Public License 2.0 | 5 votes |
public ChannelEventTriggerHandler(Trigger module, BundleContext bundleContext) { super(module); this.eventOnChannel = (String) module.getConfiguration().get(CFG_CHANNEL_EVENT); this.channelUID = (String) module.getConfiguration().get(CFG_CHANNEL); this.bundleContext = bundleContext; this.types.add("ChannelTriggeredEvent"); Dictionary<String, Object> properties = new Hashtable<>(); properties.put("event.topics", TOPIC); eventSubscriberRegistration = this.bundleContext.registerService(EventSubscriber.class.getName(), this, properties); }
Example 18
Source File: TestHelper.java From aries-jax-rs-whiteboard with Apache License 2.0 | 4 votes |
protected ServiceRegistration<Application> registerApplication( ServiceFactory<Application> serviceFactory, Object... keyValues) { Dictionary<String, Object> properties = new Hashtable<>(); properties.put(JAX_RS_APPLICATION_BASE, "/test-application"); for (int i = 0; i < keyValues.length; i = i + 2) { properties.put(keyValues[i].toString(), keyValues[i + 1]); } ServiceRegistration<Application> serviceRegistration = bundleContext.registerService( Application.class, serviceFactory, properties); _registrations.add(serviceRegistration); return serviceRegistration; }
Example 19
Source File: Loader.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * @return String (pid) -> Dictionary */ public static List<Dictionary<String, Object>> loadValues(MetaTypeProvider mtp, XMLElement el) { // assertTagName(el, DEFAULTVALUES); final List<Dictionary<String, Object>> propList = new ArrayList<Dictionary<String, Object>>(); // String (pid) -> Integer (count) final Map<String, Integer> countMap = new HashMap<String, Integer>(); for (final Enumeration<?> e = el.enumerateChildren(); e.hasMoreElements();) { final XMLElement childEl = (XMLElement) e.nextElement(); final String pid = childEl.getName(); ObjectClassDefinition ocd = null; try { ocd = mtp.getObjectClassDefinition(pid, null); } catch (final Exception ignored) { } if (ocd == null) { throw new XMLException("Undefined pid '" + pid + "'", childEl); } final Dictionary<String, Object> props = loadValues(ocd.getAttributeDefinitions(ObjectClassDefinition.ALL), childEl); int maxInstances = 1; if (ocd instanceof OCD) { maxInstances = ((OCD) ocd).maxInstances; } Integer count = countMap.get(pid); if (count == null) { count = new Integer(0); } count = new Integer(count.intValue() + 1); if (count.intValue() > maxInstances) { throw new XMLException("PID " + pid + " can only have " + maxInstances + " instance(s), found " + count, el); } countMap.put(pid, count); props.put(maxInstances > 1 ? "factory.pid" : SERVICE_PID, pid); propList.add(props); } return propList; }
Example 20
Source File: Activator.java From neoscada with Eclipse Public License 1.0 | 4 votes |
private void addFactory ( final BundleContext context, final ComponentFactory componentFactory ) { final Dictionary<String, Object> properties = new Hashtable<> ( 1 ); properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" ); //$NON-NLS-1$ this.regs.add ( context.registerService ( ComponentFactory.class, componentFactory, properties ) ); }