org.apache.ivy.Ivy.pushContext()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.apache.ivy.Ivy.pushContext()方法的一些代码示例,展示了Ivy.pushContext()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ivy.pushContext()方法的具体详情如下:
包路径:org.apache.ivy.Ivy
类名称:Ivy
方法名:pushContext

Ivy.pushContext介绍

[英]Pushes a new IvyContext bound to this Ivy instance if the current context is not already bound to this Ivy instance. If the current context is already bound to this Ivy instance, it pushes the current context on the context stack, so that you can (and must) always call #popContext() when you're done.

Alternatively, you can use the #execute(org.apache.ivy.Ivy.IvyCallback) method which takes care of everything for you.
[中]如果当前上下文尚未绑定到此Ivy实例,则推送绑定到此Ivy实例的新IvyContext。如果当前上下文已绑定到此Ivy实例,则它会将当前上下文推送到上下文堆栈上,以便您可以(而且必须)在完成时始终调用#popContext()。
或者,您可以使用#execute(org.apache.ivy.ivy.IvyCallback)方法为您处理所有事情。

代码示例

代码示例来源:origin: vipshop/Saturn

public List<URL> get(String org, String name, String rev, String[] confs, Set<Map<String, Object>> artifacts)
    throws IOException, ParseException {
  Set<URL> artifactsGeted = new HashSet<URL>();
  try {
    ivy.getSettings().addAllVariables(System.getProperties());
    ivy.pushContext();
    File ivyfile = getIvyfile(org, name, rev, confs, artifacts);
    String[] conf2 = new String[] { "default" };
    ResolveOptions resolveOptions = new ResolveOptions().setConfs(conf2).setValidate(true).setResolveMode(null)
        .setArtifactFilter(FilterHelper.getArtifactTypeFilter("jar,bundle,zip"));
    ResolveReport report = ivy.resolve(ivyfile.toURI().toURL(), resolveOptions);
    if (report.hasError()) {
      List<?> problemMessages = report.getAllProblemMessages();
      for (Object message : problemMessages) {
        log.error(message.toString());
      }
    } else {
      artifactsGeted.addAll(getCachePath(report.getModuleDescriptor(), conf2));
    }
  } catch (IOException e) {
    throw e;
  } catch (ParseException e) {
    throw e;
  } finally {
    ivy.popContext();
  }
  List<URL> result = new ArrayList<URL>();
  result.addAll(artifactsGeted);
  return result;
}

代码示例来源:origin: org.apache.ivy/ivy

public ResolveReport resolve(File ivySource) throws ParseException, IOException {
  pushContext();
  try {
    return resolveEngine.resolve(ivySource);
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public void deliver(String revision, String destIvyPattern, DeliverOptions options)
    throws IOException, ParseException {
  pushContext();
  try {
    deliverEngine.deliver(revision, destIvyPattern, options);
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public String[] listModules(String org) {
  pushContext();
  try {
    return searchEngine.listModules(org);
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public String[] listRevisions(String org, String module) {
  pushContext();
  try {
    return searchEngine.listRevisions(org, module);
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public int retrieve(ModuleRevisionId mrid, String destFilePattern, RetrieveOptions options)
    throws IOException {
  pushContext();
  try {
    return retrieveEngine.retrieve(mrid, destFilePattern, options);
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public Collection publish(ModuleRevisionId mrid, Collection srcArtifactPattern,
    String resolverName, PublishOptions options) throws IOException {
  pushContext();
  try {
    return publishEngine.publish(mrid, srcArtifactPattern, resolverName, options);
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public ModuleId[] listModules(ModuleId criteria, PatternMatcher matcher) {
  pushContext();
  try {
    return searchEngine.listModules(criteria, matcher);
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public RevisionEntry[] listRevisionEntries(ModuleEntry module) {
  pushContext();
  try {
    return searchEngine.listRevisionEntries(module);
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public ResolveReport resolve(ModuleRevisionId mrid, ResolveOptions options, boolean changing)
    throws ParseException, IOException {
  pushContext();
  try {
    return resolveEngine.resolve(mrid, options, changing);
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public ResolveReport install(ModuleRevisionId mrid, String from, String to,
    InstallOptions options) throws IOException {
  pushContext();
  try {
    return installEngine.install(mrid, from, to, options);
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public ResolveReport resolve(URL ivySource, ResolveOptions options) throws ParseException,
    IOException {
  pushContext();
  try {
    return resolveEngine.resolve(ivySource, options);
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public ModuleRevisionId[] listModules(ModuleRevisionId criteria, PatternMatcher matcher) {
  pushContext();
  try {
    return searchEngine.listModules(criteria, matcher);
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

/**
 * Sorts the collection of IvyNode from the less dependent to the more dependent
 */
public List sortNodes(Collection nodes, SortOptions options) {
  pushContext();
  try {
    return getSortEngine().sortNodes(nodes, options);
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public void setVariable(String varName, String value) {
  pushContext();
  try {
    assertBound();
    settings.setVariable(varName, value);
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public void deliver(ModuleRevisionId mrid, String revision, String destIvyPattern)
    throws IOException, ParseException {
  pushContext();
  try {
    deliverEngine.deliver(mrid, revision, destIvyPattern,
      DeliverOptions.newInstance(settings));
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public void configure(File settingsFile) throws ParseException, IOException {
  pushContext();
  try {
    assertBound();
    settings.load(settingsFile);
    postConfigure();
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public void configure(URL settingsURL) throws ParseException, IOException {
  pushContext();
  try {
    assertBound();
    settings.load(settingsURL);
    postConfigure();
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public void configureDefault() throws ParseException, IOException {
  pushContext();
  try {
    assertBound();
    settings.loadDefault();
    postConfigure();
  } finally {
    popContext();
  }
}

代码示例来源:origin: org.apache.ivy/ivy

public ResolvedModuleRevision findModule(ModuleRevisionId mrid) {
  pushContext();
  try {
    ResolveOptions options = new ResolveOptions();
    options.setValidate(false);
    return resolveEngine.findModule(mrid, options);
  } finally {
    popContext();
  }
}

相关文章