当前位置: 首页>>代码示例>>Java>>正文


Java Configuration.update方法代码示例

本文整理汇总了Java中org.osgi.service.cm.Configuration.update方法的典型用法代码示例。如果您正苦于以下问题:Java Configuration.update方法的具体用法?Java Configuration.update怎么用?Java Configuration.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.osgi.service.cm.Configuration的用法示例。


在下文中一共展示了Configuration.update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: update

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
private void update(final Configuration configuration, final Dictionary<String, Object> properties,
		final Long timeToWaitBeforeNextUpdate) throws IllegalStateException {
	logger.debug("update(): configuration = {}, properties = {}", configuration, properties);

	waitBeforeUpdate(timeToWaitBeforeNextUpdate);

	/*
	 * Now, change its configuration!
	 */

	try {
		configuration.update(properties);
	} catch (IOException e) {
		throw new IllegalStateException(e);
	}
}
 
开发者ID:daniel-lima,项目名称:aem-vltsync,代码行数:17,代码来源:ServiceSettingsConsumerImpl.java

示例2: execute

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
@Override
public Object execute() throws Exception {

    if (schedulerManager.getSchedulerNames().contains(schedulerName)) {
        throw new IllegalArgumentException("Scheduler with that name already exists");
    }

    Configuration configuration = configurationAdmin.createFactoryConfiguration(VolatileSchedulerProvider.CONFIG_FACTORY_NAME, "?");
    Dictionary<String, Object> dict = new Hashtable<>();
    dict.put(VolatileSchedulerProvider.PROPERTY_NAME, schedulerName);
    dict.put(VolatileSchedulerProvider.PROPERTY_THREADS, threads);
    dict.put(VolatileSchedulerProvider.PROPERTY_PRIORITY, priority);
    configuration.update(dict);

    return configuration.getPid();


}
 
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:19,代码来源:VolatileCreateScheduler.java

示例3: ranking

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
public void ranking() throws IOException {
    Configuration configOnline = 
    		this.admin.getConfiguration( "org.fipro.ds.data.online.OnlineDataService", null);
    Dictionary<String, Object> propsOnline = null;
    if (configOnline != null && configOnline.getProperties() != null) {
        propsOnline = configOnline.getProperties();
    } else {
        propsOnline = new Hashtable<>();
    }

    int onlineRanking = 7;
    if (configOnline != null && configOnline.getProperties() != null) {
        Object rank = configOnline.getProperties().get("service.ranking");
        if (rank != null) {
            onlineRanking = (Integer)rank;
        }
    }

    // toggle between 3 and 7
    onlineRanking = (onlineRanking == 7) ? 3 : 7;

    propsOnline.put("service.ranking", onlineRanking);
    configOnline.update(propsOnline);
}
 
开发者ID:fipro78,项目名称:osgi-ds-getting-started-pde,代码行数:25,代码来源:ToggleRankingCommand.java

示例4: toggle

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
public void toggle() throws IOException {
    Configuration config =
        this.admin.getConfiguration("org.fipro.ds.configurator.DataRetriever");

    Dictionary<String, Object> props = null;
    Object target = null;
    if (config != null && config.getProperties() != null) {
    	props = config.getProperties();
    	target = props.get("DataService.target");
    } else {
        props = new Hashtable<String, Object>();
    }

    boolean isOnline = (target == null || target.toString().contains("online"));

    // toggle the state
    StringBuilder filter = new StringBuilder("(fipro.connectivity=");
    filter.append(isOnline ? "offline" : "online").append(")");

    props.put("DataService.target", filter.toString());
    config.update(props);
}
 
开发者ID:fipro78,项目名称:osgi-ds-getting-started-pde,代码行数:23,代码来源:ToggleConnectivityCommand.java

示例5: start

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
@Override
public void start(BundleContext bundleContext) throws Exception {
    _context = bundleContext;
    _log.info("start called");

    ServiceReference configAdminServiceRef = bundleContext.getServiceReference(ConfigurationAdmin.class.getName());
    ConfigurationAdmin configAdminService = (ConfigurationAdmin) bundleContext.getService( configAdminServiceRef );

    Configuration configuration = configAdminService.createFactoryConfiguration("com.pronoia.controlservice");

    Properties props = new Properties();
    props.put( "control.name", "FredControlOne" );
    configuration.update( (Dictionary)props );

    configuration = configAdminService.createFactoryConfiguration( "com.pronoia.controlservice");
    props = new Properties();
    props.put( "control.name", "FredControlTwo" );
    configuration.update( (Dictionary)props );
}
 
开发者ID:hqstevenson,项目名称:osgi-dynamic-service,代码行数:20,代码来源:ManagedControlServiceClientActivator.java

示例6: applyConfiguration

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
private boolean applyConfiguration ( final String basePath ) throws IOException
{
    final Configuration cfg = this.configurationAdmin.getConfiguration ( PID_STORAGE_MANAGER, null );
    if ( basePath == null || basePath.isEmpty () )
    {
        cfg.update ( new Hashtable<> () );
        return false;
    }
    else
    {
        final Dictionary<String, Object> data = new Hashtable<> ();
        data.put ( "basePath", basePath );
        cfg.update ( data );
        return true;
    }
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:17,代码来源:ConfigController.java

示例7: doPost

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	String length = request.getParameter("length");
	String width = request.getParameter("width");
	String height = request.getParameter("height");
	try { 
		ConfigurationAdmin c = (ConfigurationAdmin) new InitialContext().lookup("blueprint:comp/configAdminRef");
		Configuration config = c.getConfiguration (PID, null);
		Dictionary<String, Object> dict = new Hashtable<String, Object>();
		dict.put("length", length);
		dict.put("width", width);
		dict.put("height", height);
		config.update(dict);
		response.getWriter().println ("<html><head/><body>Config updated. Click <a href=\"/test.wab.frontEnd/index.html\">here</a> to input new configuration.</body></html>");
		
		// Exercise the custom blueprint namespace handler
		SomeService s = (SomeService) new InitialContext().lookup("blueprint:comp/someServiceRef");
		s.doSomething();

	} catch (Exception e) { 
		e.printStackTrace(response.getWriter());
	}
}
 
开发者ID:WASdev,项目名称:sample.osgi.blueprint-cm,代码行数:23,代码来源:TestServlet.java

示例8: internalReceiveCommand

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
/**
 * @{inheritDoc
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected void internalReceiveCommand(String itemName, Command command) {
	if (configAdmin != null) {
		for (ConfigAdminBindingProvider provider : this.providers) {
			ConfigAdminBindingConfig bindingConfig = provider.getBindingConfig(itemName);
			Configuration config = getConfiguration(bindingConfig);
			if (config != null) {
				Dictionary props = config.getProperties();
				props.put(bindingConfig.configParameter, command.toString());
				try {
					config.update(props);
				} catch (IOException ioe) {
					logger.error("updating Configuration '{}' with '{}' failed", bindingConfig.normalizedPid,
							command.toString());
				}
				logger.debug("successfully updated configuration (pid={}, value={})", bindingConfig.normalizedPid,
						command.toString());
			} else {
				logger.info("There is no configuration found for pid '{}'", bindingConfig.normalizedPid);
			}
		}
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:28,代码来源:ConfigAdminBinding.java

示例9: setProperty

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
/**
 * Set the value of an OSGi configuration property for a given PID.
 *
 * @param pid The PID of the OSGi component to update
 * @param property The property of the config to update
 * @param value The value to assign the provided property
 * @return true if the property was updated successfully
 */
public boolean setProperty(final String pid, final String property, final Object value) {
    try {
        Configuration conf = configAdmin.getConfiguration(pid);

        @SuppressWarnings("unchecked")
        Dictionary<String, Object> props = conf.getProperties();

        if (props == null) {
            props = new Hashtable<String, Object>();
        }

        props.put(property, value != null ? value : StringUtils.EMPTY);
        conf.update(props);
    } catch (IOException e) {
        LOGGER.error("Could not set property", e);
        return false;
    }

    return true;
}
 
开发者ID:nateyolles,项目名称:publick-sling-blog,代码行数:29,代码来源:OsgiConfigurationServiceImpl.java

示例10: persistConfiguration

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
@Override
public void persistConfiguration(Map<String, Object> newConfiguration) throws InvocationException {
    Dictionary<String, Object> newConfigDictionary = new Hashtable<>();
    for(String key : newConfiguration.keySet()){
        newConfigDictionary.put(key, newConfiguration.get(key));
    }
    
    ConfigurationAdmin admin = configurationAdminTracker.getService();
    
    
    try {
        Configuration config = admin.getConfiguration(ocd.getID());
        config.update(newConfigDictionary);
    } catch (IOException | IllegalArgumentException | IllegalStateException ex) {
        throw new InvocationException("Failed to update configuration", ex);
    }
}
 
开发者ID:TDC-Netdesign,项目名称:ManagedProperties,代码行数:18,代码来源:ConfigurationAdminProvider.java

示例11: testScalar

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
public void testScalar() throws IOException
{
    Configuration cimpl = getConfiguration();
    Dictionary props = cimpl.getProperties();
    assertNull( "Configuration is fresh", props );

    props = new Hashtable();
    props.put( SCALAR, STRING_VALUE );
    cimpl.update( props );

    Dictionary newProps = cimpl.getProperties();
    assertNotNull( "Configuration is not fresh", newProps );
    assertEquals( "Expect 2 elements", 2, newProps.size() );
    assertEquals( "Service.pid must match", TEST_PID, newProps.get( Constants.SERVICE_PID ) );
    assertEquals( "Scalar value must match", STRING_VALUE, newProps.get( SCALAR ) );
}
 
开发者ID:mcculls,项目名称:osgi-in-action,代码行数:17,代码来源:ConfigurationAdapterTest.java

示例12: configure

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
protected Configuration configure( final String pid, final String location, final boolean withProps )
{
    final ConfigurationAdmin ca = getConfigurationAdmin();
    try
    {
        final Configuration config = ca.getConfiguration( pid, location );
        if ( withProps )
        {
            config.update( theConfig );
        }
        return config;
    }
    catch ( IOException ioe )
    {
        TestCase.fail( "Failed updating configuration " + pid + ": " + ioe.toString() );
        return null; // keep the compiler quiet
    }
}
 
开发者ID:mcculls,项目名称:osgi-in-action,代码行数:19,代码来源:ConfigurationTestBase.java

示例13: prepareConfiguration

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
private void prepareConfiguration() throws Exception {

		ServiceReference ref = OsgiServiceReferenceUtils.getServiceReference(bundleContext,
			ConfigurationAdmin.class.getName(), null);

		ConfigurationAdmin admin = (ConfigurationAdmin) bundleContext.getService(ref);
		Configuration config = admin.getConfiguration(ID);
		config.update(DICT);
	}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:10,代码来源:PropertyPlaceholderTest.java

示例14: handleAddDiscoveryNode

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
private void handleAddDiscoveryNode(AddedNode event) {
    DiscoveryNode node = event.getNode();
    DiscoveryPath path = node.getPath();

    // Only do something with config paths
    if (path.isConfigPath()) {
        try {
            Configuration config = this.getConfig(path);
            logger.debug("Registering configuration {}", config.getPid());
            config.update(new Hashtable<>(node.getValues()));
        } catch (IOException e) {
            logger.error("Error while registering configuration {}", path.toString(), e);
        }
    }
}
 
开发者ID:INAETICS,项目名称:Drones-Simulator,代码行数:16,代码来源:EtcdDiscovererService.java

示例15: preSet

import org.osgi.service.cm.Configuration; //导入方法依赖的package包/类
private void preSet(String componentName, String name, String value) {
    try {
        Configuration config = cfgAdmin.getConfiguration(componentName, null);
        Dictionary<String, Object> property = config.getProperties();
        if (property == null) {
            property = new Hashtable<>();
        }
        property.put(name, value);
        config.update(property);
    } catch (IOException e) {
        log.error("Failed to preset configuration for {}", componentName);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:ComponentConfigManager.java


注:本文中的org.osgi.service.cm.Configuration.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。