本文整理匯總了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);
}
}
示例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();
}
示例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);
}
示例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);
}
示例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 );
}
示例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;
}
}
示例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());
}
}
示例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);
}
}
}
}
示例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;
}
示例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);
}
}
示例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 ) );
}
示例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
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
}