Package org.springframework.xd.module

Examples of org.springframework.xd.module.ModuleDefinition


    // List is in reverse order
    ModuleDescriptor lastModule = parsed.get(0);
    String lastModuleName = lastModule.getModuleName();
    ModuleType lastModuleType = lastModule.getType();
    ModuleDefinition lastModuleDefinition = moduleRegistry.findDefinition(lastModuleName, lastModuleType);

    Set<String> alreadyPresentOptions = new HashSet<String>(lastModule.getParameters().keySet().size());
    // If we're providing completions for a composed module, some options
    // may already have a value appearing from the definition of the module itself, yet
    // the user *may* want to override them anyways. So pretend they're not there
View Full Code Here


   * @return a list of ModuleDefinitions
   */
  private List<ModuleDefinition> createModuleDefinitions(List<ModuleDescriptor> moduleDescriptors) {
    List<ModuleDefinition> moduleDefinitions = new ArrayList<ModuleDefinition>(moduleDescriptors.size());
    for (ModuleDescriptor moduleDescriptor : moduleDescriptors) {
      ModuleDefinition moduleDefinition = ModuleDefinitions.dummy(moduleDescriptor.getModuleName(),
          moduleDescriptor.getType());
      moduleDefinitions.add(moduleDefinition);
    }
    return moduleDefinitions;
  }
View Full Code Here

      List<String> proposals) {
    // List is in reverse order
    ModuleDescriptor lastModule = parseResult.get(0);
    String lastModuleName = lastModule.getModuleName();
    ModuleType lastModuleType = lastModule.getType();
    ModuleDefinition lastModuleDefinition = moduleRegistry.findDefinition(lastModuleName, lastModuleType);

    Set<String> alreadyPresentOptions = new HashSet<String>(lastModule.getParameters().keySet());
    for (ModuleOption option : moduleOptionsMetadataResolver.resolve(lastModuleDefinition)) {
      if (shouldShowOption(option, detailLevel) && !alreadyPresentOptions.contains(option.getName())) {
        proposals.add(String.format("%s%s--%s=", text, text.endsWith(" ") ? "" : " ", option.getName()));
View Full Code Here

    // List is in reverse order
    ModuleDescriptor lastModule = parsed.get(0);
    String lastModuleName = lastModule.getModuleName();
    ModuleType lastModuleType = lastModule.getType();
    ModuleDefinition lastModuleDefinition = moduleRegistry.findDefinition(lastModuleName, lastModuleType);

    Set<String> alreadyPresentOptions = new HashSet<String>(lastModule.getParameters().keySet());
    for (ModuleOption option : moduleOptionsMetadataResolver.resolve(lastModuleDefinition)) {
      if (shouldShowOption(option, detailLevel) && !alreadyPresentOptions.contains(option.getName())
          && option.getName().startsWith(prefix.toString())) {
View Full Code Here

    List<ModuleDescriptor> result = new ArrayList<ModuleDescriptor>(builders.size());
    for (ModuleDescriptor.Builder builder : builders) {
      builder.setType(determineType(builder, builders.size() - 1, parsingContext));

      // definition is guaranteed to be non-null here
      ModuleDefinition moduleDefinition = moduleRegistry.findDefinition(builder.getModuleName(), builder.getType());
      builder.setModuleDefinition(moduleDefinition);
      ModuleOptionsMetadata optionsMetadata = moduleOptionsMetadataResolver.resolve(moduleDefinition);
      if (parsingContext.shouldBindAndValidate()) {
        try {
          optionsMetadata.interpolate(builder.getParameters());
View Full Code Here

   *
   * @param builder builder object
   * @return new instance of {@code ModuleDescriptor}
   */
  private ModuleDescriptor buildModuleDescriptor(ModuleDescriptor.Builder builder) {
    ModuleDefinition def = moduleRegistry.findDefinition(builder.getModuleName(), builder.getType());
    if (def.isComposed()) {
      String dsl = ((CompositeModuleDefinition) def).getDslDefinition();
      List<ModuleDescriptor> children = parse(def.getName(), dsl, ParsingContext.module);

      // Preserve the options set for the "parent" module in the parameters map
      Map<String, String> parameters = new HashMap<String, String>(builder.getParameters());

      // Pretend that options were set on the composed module itself
View Full Code Here

   * @throws NoSuchModuleException if no module with this name exists for one of
   *                               the types present in {@code candidates}
   */
  private ModuleType resolveModuleType(String moduleName, ModuleType... candidates) {
    for (ModuleType type : candidates) {
      ModuleDefinition def = moduleRegistry.findDefinition(moduleName, type);
      if (def != null) {
        return type;
      }
    }
    throw new NoSuchModuleException(moduleName, candidates);
View Full Code Here

    }
    catch (IllegalArgumentException e) {
      // Not an actual type name, skip
      return;
    }
    ModuleDefinition found = ModuleDefinitions.simple(name, type, "file:" + canonicalPath + (isDir ? "/" : ""));
    if (holder.contains(found)) {
      SimpleModuleDefinition one = (SimpleModuleDefinition) found;
      SimpleModuleDefinition two = (SimpleModuleDefinition) holder.get(holder.indexOf(found));
      throw new IllegalStateException(String.format("Duplicate module definitions for '%s:%s' found at '%s' " +
              "and" +
              " " +
              "'%s'",
          found.getType(), found.getName(), one.getLocation(), two.getLocation()));
    }
    else {
      holder.add(found);
    }
  }
View Full Code Here

        byte[] data = zooKeeperConnection.getClient().getData().forPath(
            Paths.build(Paths.MODULES, type.toString(), child));
        // Check for data (only composed modules have definitions)
        if (data != null && data.length > 0) {

          ModuleDefinition composed = this.findDefinition(child, type);
          results.add(composed);
        }
      }
    }
    catch (Exception e) {
View Full Code Here

      throw new ModuleAlreadyExistsException(name, type);
    }

    // TODO: XD-2284 need more than ModuleDefinitions (need to capture passed in options, etc)
    List<ModuleDefinition> composedModuleDefinitions = createComposedModuleDefinitions(parseResult);
    ModuleDefinition moduleDefinition = ModuleDefinitions.composed(name, type, dslDefinition, composedModuleDefinitions);

    Assert.isTrue(this.registry.registerNew(moduleDefinition), moduleDefinition + " could not be saved");
    return moduleDefinition;
  }
View Full Code Here

TOP

Related Classes of org.springframework.xd.module.ModuleDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.