本文整理汇总了Java中org.apache.ivy.plugins.repository.Repository.getResource方法的典型用法代码示例。如果您正苦于以下问题:Java Repository.getResource方法的具体用法?Java Repository.getResource怎么用?Java Repository.getResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ivy.plugins.repository.Repository
的用法示例。
在下文中一共展示了Repository.getResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getResource
import org.apache.ivy.plugins.repository.Repository; //导入方法依赖的package包/类
public Resource getResource(String source) throws IOException {
for (Repository repository : repositories) {
logTry(repository);
try {
Resource r = repository.getResource(source);
if (r != null && r.exists()) {
logSuccess(repository);
return r;
}
} catch (Exception e) {
logFailed(repository, e);
}
}
// resource that basically doesn't exists
return new BasicResource(source, false, 0, 0, true);
}
示例2: listResources
import org.apache.ivy.plugins.repository.Repository; //导入方法依赖的package包/类
@Override
protected ResolvedResource[] listResources(Repository repository, ModuleRevisionId mrid,
String pattern, Artifact artifact) {
if (shouldUseMavenMetadata(pattern)) {
List<String> revs = listRevisionsWithMavenMetadata(repository, mrid.getModuleId()
.getAttributes());
if (revs != null) {
Message.debug("\tfound revs: " + revs);
List<ResolvedResource> rres = new ArrayList<>();
for (String rev : revs) {
ModuleRevisionId historicalMrid = ModuleRevisionId.newInstance(mrid, rev);
String patternForRev = pattern;
if (rev.endsWith("SNAPSHOT")) {
String snapshotVersion = findTimestampedSnapshotVersion(historicalMrid);
if (snapshotVersion != null) {
patternForRev = pattern.replaceFirst("\\-\\[revision\\]", "-"
+ snapshotVersion);
}
}
String resolvedPattern = IvyPatternHelper.substitute(patternForRev,
historicalMrid, artifact);
try {
Resource res = repository.getResource(resolvedPattern);
if (res != null) {
// we do not test if the resource actually exist here, it would cause
// a lot of checks which are not always necessary depending on the usage
// which is done of the returned ResolvedResource array
rres.add(new ResolvedResource(res, rev));
}
} catch (IOException e) {
Message.warn(
"impossible to get resource from name listed by maven-metadata.xml:"
+ rres, e);
}
}
return rres.toArray(new ResolvedResource[rres.size()]);
} else {
// maven metadata not available or something went wrong,
// use default listing capability
return super.listResources(repository, mrid, pattern, artifact);
}
} else {
return super.listResources(repository, mrid, pattern, artifact);
}
}