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


Java Configuration类代码示例

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


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

示例1: addSyncRoot

import org.osgi.service.cm.Configuration; //导入依赖的package包/类
/**
 * Add the specified directory to the sync roots, enabling the service when
 * necessary.
 * 
 * @param syncRoot
 *            directory to add
 * @param expectedSyncTime
 *            the expected sync time as result of adding this directory
 */
protected void addSyncRoot(final File syncRoot, final Long expectedSyncTime) throws IllegalStateException {
	logger.debug("addSyncRoot(): syncRoot = {}, expectedSyncTime = {}", syncRoot, expectedSyncTime);
	final Configuration configuration = getConfiguration();
	final Dictionary<String, Object> properties = getProperties(configuration);

	final Set<String> syncRoots = getSyncRoots(properties);

	syncRoots.add(syncRoot.getAbsolutePath());
	if (syncRoots.size() == 1) {
		enableSync(properties);
	}

	properties.put(PROP_SYNCROOTS, syncRoots.toArray(new String[syncRoots.size()]));
	update(configuration, properties, expectedSyncTime);
}
 
开发者ID:daniel-lima,项目名称:aem-vltsync,代码行数:25,代码来源:ServiceSettingsConsumerImpl.java

示例2: removeSyncRoot

import org.osgi.service.cm.Configuration; //导入依赖的package包/类
/**
 * Remove the specified directory from the sync roots, disabling the service
 * when necessary.
 * 
 * @param syncRoot
 *            directory to remove
 */
protected void removeSyncRoot(final File syncRoot) throws IllegalStateException {
	logger.debug("removeSyncRoot(): syncRoot = {}", syncRoot);
	final Configuration configuration = getConfiguration();
	final Dictionary<String, Object> properties = getProperties(configuration);

	final Set<String> syncRoots = getSyncRoots(properties);

	syncRoots.remove(syncRoot.getAbsolutePath());
	properties.put(PROP_SYNCROOTS, syncRoots.toArray(new String[syncRoots.size()]));

	if (syncRoots.size() == 0) {
		disableSync(properties);
	}

	update(configuration, properties, null);
}
 
开发者ID:daniel-lima,项目名称:aem-vltsync,代码行数:24,代码来源:ServiceSettingsConsumerImpl.java

示例3: 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

示例4: handleChangeDiscoveryValue

import org.osgi.service.cm.Configuration; //导入依赖的package包/类
private void handleChangeDiscoveryValue(ChangedValue 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("Updating configuration {} with new value for key {} and value " + event.getNewValue(), config.getPid(), event.getKey());

            if(event.getNewValue() == null) {
                // Value should be removed
                config.getProperties().remove(event.getKey());
            } else {
                // Value should be set
                config.getProperties().put(event.getKey(), event.getNewValue());
            }
        } catch (IOException e) {
            logger.error("Error while updating configuration {}", path.toString(), e);
        }
    }
}
 
开发者ID:INAETICS,项目名称:Drones-Simulator,代码行数:23,代码来源:EtcdDiscovererService.java

示例5: loadExistingValues

import org.osgi.service.cm.Configuration; //导入依赖的package包/类
private void loadExistingValues(String componentName) {
    try {
        Configuration cfg = cfgAdmin.getConfiguration(componentName, null);
        Map<String, ConfigProperty> map = properties.get(componentName);
        Dictionary<String, Object> props = cfg.getProperties();
        if (props != null) {
            Enumeration<String> it = props.keys();
            while (it.hasMoreElements()) {
                String name = it.nextElement();
                ConfigProperty p = map.get(name);
                if (p != null) {
                    map.put(name, ConfigProperty.setProperty(p, (String) props.get(name)));
                }
            }
        }
    } catch (IOException e) {
        log.error("Unable to get configuration for " + componentName, e);
    }

}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:ComponentConfigManager.java

示例6: 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

示例7: execute

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

    if (schedulerManager.getScheduler(schedulerName) == null) {
        throw new IllegalArgumentException("Scheduler with that name doesn't exists");
    }

    for (Configuration configuration : configurationAdmin.listConfigurations(VolatileSchedulerProvider.CONFIG_FACTORY_NAME)) {
        String name = (String)configuration.getProperties().get(VolatileSchedulerProvider.PROPERTY_NAME);
        if (name.equalsIgnoreCase(schedulerName)) {
            configuration.delete();
            return null;
        }
    }

    throw new IllegalArgumentException("Scheduler configuration not found!");

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

示例8: 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

示例9: 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

示例10: 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

示例11: getProperties

import org.osgi.service.cm.Configuration; //导入依赖的package包/类
/**
 * Get properties as a map.
 * <p>
 * Returns an empty map if configAdmin is null, or the configuration is null, etc.
 * </p>
 *
 * @param pid OSGI configAdmin pid.
 * @return map of properties
 */
public Map<String, String> getProperties(final String pid) throws Exception {
    final Map<String, String> props = new HashMap<>();
    if (configAdmin != null) {
        final Configuration c = configAdmin.getConfiguration(pid);
        if (c != null) {
            final Dictionary<String, Object> dict = c.getProperties();
            if (dict != null) {
                final Enumeration<String> keys = dict.keys();
                while (keys.hasMoreElements()) {
                    final String key = keys.nextElement();
                    props.put(key, dict.get(key).toString());
                }
            }
        }
    }

    return props;
}
 
开发者ID:fcrepo4-labs,项目名称:fcrepo-api-x,代码行数:28,代码来源:ConfigHelper.java

示例12: doGet

import org.osgi.service.cm.Configuration; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  String PID;
  PID = request.getParameter("pid");
  if (PID == null) {
    response.sendError(404);
    return;
  }
  Configuration config = getConfig(PID);
  if (config == null) {
    response.sendError(404);
    return;
  }
  Dictionary props = config.getProperties();
  response.setContentType("application/json");
  response.setStatus(200);
  try (PrintWriter writer = response.getWriter()) {
    if (props == null) {
      writer.write("{}");
    } else {
      writer.write(dictionaryToJson(props).toString());
    }
    writer.flush();
  }
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:26,代码来源:WebConfigurator.java

示例13: getConfig

import org.osgi.service.cm.Configuration; //导入依赖的package包/类
private Configuration getConfig(String pid) throws IOException {
  //If bundle's serviceReference is null (e.g., when you only install driver without start),
  //use loc, it setup bundle's location forcibly
  //String loc = null;
  BundleContext ctx = context;
  Bundle[] bundles = ctx.getBundles();
  for (Bundle bun : bundles) {
    if (bun.getSymbolicName().contains(pid)) {
      ctx = bun.getBundleContext();
      //loc = bun.getLocation();
      break;
    }
  }
  ServiceReference configurationAdminReference
      = ctx.getServiceReference(ConfigurationAdmin.class.getName());
  if (configurationAdminReference != null) {
    ConfigurationAdmin configurationAdmin = (ConfigurationAdmin) ctx.getService(configurationAdminReference);
    Configuration config = (Configuration) configurationAdmin.getConfiguration(pid);
    return config;
  }
  return null;
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:23,代码来源:WebConfigurator.java

示例14: configuringBundle

import org.osgi.service.cm.Configuration; //导入依赖的package包/类
public void configuringBundle(BundleContext ctx, HashMap<String, BundleContext> contextBundles) {
  if (pid != null && properties != null) {
    if(contextBundles.containsKey(pid)) {
      ctx = contextBundles.get(pid);
    }
    ServiceReference configurationAdminReference =
        ctx.getServiceReference(ConfigurationAdmin.class.getName());

    if (configurationAdminReference != null) {
      ConfigurationAdmin configurationAdmin =
          (ConfigurationAdmin) ctx.getService(configurationAdminReference);
      try {
        Configuration config = configurationAdmin.getConfiguration(pid);
        config.update(properties);
      } catch (IOException e) {
        logger.error(e.getMessage(), e);
      }
    }
  }
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:21,代码来源:ABundle.java

示例15: config

import org.osgi.service.cm.Configuration; //导入依赖的package包/类
@RequestMapping
public ModelAndView config ()
{
    final Map<String, Object> model = new HashMap<> ();

    final StorageConfiguration command = new StorageConfiguration ();

    try
    {
        final Configuration cfg = this.configurationAdmin.getConfiguration ( PID_STORAGE_MANAGER, null );
        if ( cfg != null && cfg.getProperties () != null )
        {
            command.setBasePath ( (String)cfg.getProperties ().get ( "basePath" ) );
        }
    }
    catch ( final Exception e )
    {
        // ignore
    }

    model.put ( "command", command );
    fillData ( model );

    return new ModelAndView ( "/config/index", model );
}
 
开发者ID:eclipse,项目名称:packagedrone,代码行数:26,代码来源:ConfigController.java


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