Search in sources :

Example 11 with Dictionary

use of java.util.Dictionary in project camel by apache.

the class AbstractFeatureTest method overridePropertiesWithConfigAdmin.

protected void overridePropertiesWithConfigAdmin(String pid, Properties props) throws IOException {
    ConfigurationAdmin configAdmin = getOsgiService(bundleContext, ConfigurationAdmin.class);
    // passing null as second argument ties the configuration to correct bundle.
    Configuration config = configAdmin.getConfiguration(pid, null);
    if (config == null) {
        throw new IllegalArgumentException("Cannot find configuration with pid " + pid + " in OSGi ConfigurationAdmin service.");
    }
    // let's merge configurations
    Dictionary<String, Object> currentProperties = config.getProperties();
    Dictionary newProps = new Properties();
    if (currentProperties == null) {
        currentProperties = newProps;
    }
    for (Enumeration<String> ek = currentProperties.keys(); ek.hasMoreElements(); ) {
        String k = ek.nextElement();
        newProps.put(k, currentProperties.get(k));
    }
    for (String p : props.stringPropertyNames()) {
        newProps.put(p, props.getProperty(p));
    }
    LOG.info("Updating ConfigAdmin {} by overriding properties {}", config, newProps);
    config.update(newProps);
}
Also used : Dictionary(java.util.Dictionary) Configuration(org.osgi.service.cm.Configuration) Properties(java.util.Properties) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin)

Example 12 with Dictionary

use of java.util.Dictionary in project opennms by OpenNMS.

the class HeartbeatSinkPerfIT method addServicesOnStartup.

@SuppressWarnings("rawtypes")
@Override
protected void addServicesOnStartup(Map<String, KeyValueHolder<Object, Dictionary>> services) {
    services.put(MinionIdentity.class.getName(), new KeyValueHolder<Object, Dictionary>(new MinionIdentity() {

        @Override
        public String getId() {
            return "0";
        }

        @Override
        public String getLocation() {
            return REMOTE_LOCATION_NAME;
        }
    }, new Properties()));
    Properties props = new Properties();
    props.setProperty("alias", "opennms.broker");
    services.put(Component.class.getName(), new KeyValueHolder<Object, Dictionary>(queuingservice, props));
}
Also used : Dictionary(java.util.Dictionary) MinionIdentity(org.opennms.minion.core.api.MinionIdentity) Properties(java.util.Properties) Component(org.apache.camel.Component)

Example 13 with Dictionary

use of java.util.Dictionary in project opennms by OpenNMS.

the class EchoRpcBlueprintIT method addServicesOnStartup.

@SuppressWarnings("rawtypes")
@Override
protected void addServicesOnStartup(Map<String, KeyValueHolder<Object, Dictionary>> services) {
    services.put(MinionIdentity.class.getName(), new KeyValueHolder<Object, Dictionary>(new MockMinionIdentity(REMOTE_LOCATION_NAME), new Properties()));
    Properties props = new Properties();
    props.setProperty("alias", "opennms.broker");
    services.put(Component.class.getName(), new KeyValueHolder<Object, Dictionary>(queuingservice, props));
}
Also used : Dictionary(java.util.Dictionary) MinionIdentity(org.opennms.minion.core.api.MinionIdentity) Properties(java.util.Properties) Component(org.apache.camel.Component)

Example 14 with Dictionary

use of java.util.Dictionary in project opennms by OpenNMS.

the class SinkBlueprintMessageFailureIT method addServicesOnStartup.

@SuppressWarnings("rawtypes")
@Override
protected void addServicesOnStartup(Map<String, KeyValueHolder<Object, Dictionary>> services) {
    services.put(MinionIdentity.class.getName(), new KeyValueHolder<Object, Dictionary>(new MinionIdentity() {

        @Override
        public String getId() {
            return "0";
        }

        @Override
        public String getLocation() {
            return REMOTE_LOCATION_NAME;
        }
    }, new Properties()));
    Properties props = new Properties();
    props.setProperty("alias", "opennms.broker");
    services.put(Component.class.getName(), new KeyValueHolder<Object, Dictionary>(queuingservice, props));
}
Also used : Dictionary(java.util.Dictionary) MinionIdentity(org.opennms.minion.core.api.MinionIdentity) Properties(java.util.Properties) Component(org.apache.camel.Component)

Example 15 with Dictionary

use of java.util.Dictionary in project opennms by OpenNMS.

the class ApplicationFactoryServiceTracker method addingService.

@SuppressWarnings({ "unchecked" })
@Override
public Object addingService(ServiceReference reference) {
    ApplicationFactory factory = (ApplicationFactory) super.addingService(reference);
    if (factory == null)
        return null;
    FactoryServlet servlet = new FactoryServlet(factory, reference.getBundle().getBundleContext());
    Dictionary props = new Properties();
    for (String key : reference.getPropertyKeys()) {
        props.put(key, reference.getProperty(key));
    }
    if (props.get(Constants.ALIAS) == null) {
        logger.warn("You have not set the alias property for ApplicationFactory: " + factory);
    }
    m_serviceRegistration.put(factory, context.registerService(Servlet.class.getName(), servlet, props));
    return factory;
}
Also used : Dictionary(java.util.Dictionary) ApplicationFactory(org.opennms.vaadin.extender.ApplicationFactory) Properties(java.util.Properties)

Aggregations

Dictionary (java.util.Dictionary)161 Hashtable (java.util.Hashtable)61 Test (org.junit.Test)48 Configuration (org.osgi.service.cm.Configuration)33 Enumeration (java.util.Enumeration)27 Properties (java.util.Properties)24 BundleContext (org.osgi.framework.BundleContext)21 ServiceReference (org.osgi.framework.ServiceReference)21 HashMap (java.util.HashMap)19 ServiceRegistration (org.osgi.framework.ServiceRegistration)19 Map (java.util.Map)17 ArrayList (java.util.ArrayList)15 Bundle (org.osgi.framework.Bundle)15 IOException (java.io.IOException)13 LinkedHashMap (java.util.LinkedHashMap)12 Matchers.anyString (org.mockito.Matchers.anyString)11 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)10 ComponentContext (org.osgi.service.component.ComponentContext)10 TreeMap (java.util.TreeMap)9 MinionIdentity (org.opennms.minion.core.api.MinionIdentity)9