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


Java Repository.getResource方法代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:ant-ivy,代码行数:17,代码来源:ChainedRepository.java

示例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);
    }
}
 
开发者ID:apache,项目名称:ant-ivy,代码行数:47,代码来源:IBiblioResolver.java


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