Exemplo n.º 1
0
 /**
  * list the configurations of resource model providers.
  *
  * @return a list of maps containing:
  *     <ul>
  *       <li>type - provider type name
  *       <li>props - configuration properties
  *     </ul>
  */
 @Override
 public synchronized List<Map<String, Object>> listResourceModelConfigurations() {
   Map propertiesMap = projectConfig.getProperties();
   Properties properties = new Properties();
   properties.putAll(propertiesMap);
   return listResourceModelConfigurations(properties);
 }
Exemplo n.º 2
0
 /**
  * Return a list of resource model configuration
  *
  * @param props properties
  * @return List of Maps, each map containing "type": String, "props":Properties
  */
 public static List<Map<String, Object>> listResourceModelConfigurations(final Properties props) {
   final ArrayList<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
   int i = 1;
   boolean done = false;
   while (!done) {
     final String prefix = RESOURCES_SOURCE_PROP_PREFIX + "." + i;
     if (props.containsKey(prefix + ".type")) {
       final String providerType = props.getProperty(prefix + ".type");
       final Properties configProps = new Properties();
       final int len = (prefix + ".config.").length();
       for (final Object o : props.keySet()) {
         final String key = (String) o;
         if (key.startsWith(prefix + ".config.")) {
           configProps.setProperty(key.substring(len), props.getProperty(key));
         }
       }
       final HashMap<String, Object> map = new HashMap<String, Object>();
       map.put("type", providerType);
       map.put("props", configProps);
       list.add(map);
     } else {
       done = true;
     }
     i++;
   }
   return list;
 }
Exemplo n.º 3
0
  private ResourceModelSource loadResourceModelSource(
      String type, Properties configuration, boolean useCache, String ident)
      throws ExecutionServiceException {

    final ResourceModelSourceService nodesSourceService = getResourceModelSourceService();
    configuration.put("project", projectConfig.getName());
    ResourceModelSource sourceForConfiguration =
        nodesSourceService.getSourceForConfiguration(type, configuration);

    if (useCache) {
      ResourceModelSourceFactory provider = nodesSourceService.providerOfType(type);
      String name = ident;
      if (provider instanceof Describable) {
        Describable desc = (Describable) provider;
        Description description = desc.getDescription();
        name = ident + " (" + description.getTitle() + ")";
      }
      return createCachingSource(sourceForConfiguration, ident, name);
    } else {
      return sourceForConfiguration;
    }
  }