當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。