本文整理汇总了Java中org.apache.ivy.plugins.repository.Resource类的典型用法代码示例。如果您正苦于以下问题:Java Resource类的具体用法?Java Resource怎么用?Java Resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Resource类属于org.apache.ivy.plugins.repository包,在下文中一共展示了Resource类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: transferProgress
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
public void transferProgress(TransferEvent evt) {
final Resource resource = evt.getResource();
if (resource.isLocal()) {
return;
}
final int eventType = evt.getEventType();
if (eventType == TransferEvent.TRANSFER_STARTED) {
resourceOperation = createResourceOperation(resource.getName(), getRequestType(evt), loggingClass, evt.getTotalLength());
}
if (eventType == TransferEvent.TRANSFER_PROGRESS) {
resourceOperation.logProcessedBytes(evt.getLength());
}
if (eventType == TransferEvent.TRANSFER_COMPLETED) {
resourceOperation.completed();
}
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:17,代码来源:ProgressLoggingTransferListener.java
示例2: get
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
/**
* Handles a request to retrieve a file from the repository.
*
* @param source Path to the resource to retrieve, including the repository root.
* @param destination The location where the file should be retrieved to.
* @throws IOException If an error occurs retrieving the file.
*/
public void get(String source, File destination) throws IOException {
fireTransferInitiated(getResource(source), TransferEvent.REQUEST_GET);
String repositorySource = source;
if (!source.startsWith(repositoryRoot)) {
repositorySource = getRepositoryRoot() + source;
}
Message.debug("Getting file for user " + userName + " from " + repositorySource + " [revision="
+ svnRetrieveRevision + "] to " + destination.getAbsolutePath());
try {
SVNURL url = SVNURL.parseURIEncoded(repositorySource);
SVNRepository repository = getRepository(url, true);
repository.setLocation(url, false);
Resource resource = getResource(source);
fireTransferInitiated(resource, TransferEvent.REQUEST_GET);
SvnDao svnDAO = new SvnDao(repository);
svnDAO.getFile(url, destination, svnRetrieveRevision);
fireTransferCompleted(destination.length());
} catch (SVNException e) {
Message.error("Error retrieving" + repositorySource + " [revision=" + svnRetrieveRevision + "]");
throw (IOException) new IOException().initCause(e);
}
}
开发者ID:massdosage,项目名称:ivysvn,代码行数:33,代码来源:SvnRepository.java
示例3: getResource
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
public Resource getResource(String source) throws IOException {
source = encode(source);
Resource res = resourcesCache.get(source);
if (res == null) {
URI uri;
try {
uri = new URI(source);
} catch (URISyntaxException e) {
// very weird URL, let's assume it is absolute
uri = null;
}
if (uri == null || uri.isAbsolute()) {
res = new URLResource(new URL(source), getTimeoutConstraint());
} else {
res = new URLResource(new URL(baseUrl + source), getTimeoutConstraint());
}
resourcesCache.put(source, res);
}
return res;
}
开发者ID:apache,项目名称:ant-ivy,代码行数:21,代码来源:RelativeURLRepository.java
示例4: checkCacheUptodate
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
/**
* Check that a cached file can be considered up to date and thus not downloaded
*
* @param archiveFile
* the file in the cache
* @param resource
* the remote resource to check
* @param savedOrigin
* the saved origin which contains that last checked date
* @param origin
* the origin in which to store the new last checked date
* @param ttl
* the time to live to consider the cache up to date
* @return <code>true</code> if the cache is considered up to date
*/
private boolean checkCacheUptodate(File archiveFile, Resource resource,
ArtifactOrigin savedOrigin, ArtifactOrigin origin, long ttl) {
long time = System.currentTimeMillis();
if (savedOrigin.getLastChecked() != null
&& (time - savedOrigin.getLastChecked()) < ttl) {
// still in the ttl period, no need to check, trust the cache
return archiveFile.exists() || !savedOrigin.isExists();
}
if (!archiveFile.exists()) {
// the the file doesn't exist in the cache, obviously not up to date
return false;
}
origin.setLastChecked(time);
// check if the local resource is up to date regarding the remote one
return archiveFile.lastModified() >= resource.getLastModified();
}
开发者ID:apache,项目名称:ant-ivy,代码行数:32,代码来源:DefaultRepositoryCacheManager.java
示例5: resolveResource
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
/**
* This method is similar to getResource, except that the returned resource is fully initialized
* (resolved in the sftp repository), and that the given string is a full remote path
*
* @param path
* the full remote path in the repository of the resource
* @return a fully initialized resource, able to answer to all its methods without needing any
* further connection
*/
@SuppressWarnings("unchecked")
public Resource resolveResource(String path) {
try {
List<LsEntry> r = getSftpChannel(path).ls(getPath(path));
if (r != null) {
SftpATTRS attrs = r.get(0).getAttrs();
return new BasicResource(path, true, attrs.getSize(),
attrs.getMTime() * MILLIS_PER_SECOND, false);
}
} catch (Exception e) {
Message.debug("Error while resolving resource " + path, e);
// silent fail, return nonexistent resource
}
return new BasicResource(path, false, 0, 0, false);
}
开发者ID:apache,项目名称:ant-ivy,代码行数:26,代码来源:SFTPRepository.java
示例6: lslToResource
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
/**
* Parses a ls -l line and transforms it in a resource
*
* @param file ditto
* @param responseLine ditto
* @return Resource
*/
protected Resource lslToResource(String file, String responseLine) {
if (responseLine == null || responseLine.startsWith("ls")) {
return new BasicResource(file, false, 0, 0, false);
} else {
String[] parts = responseLine.split("\\s+");
if (parts.length != LS_PARTS_NUMBER) {
Message.debug("unrecognized ls format: " + responseLine);
return new BasicResource(file, false, 0, 0, false);
} else {
try {
long contentLength = Long.parseLong(parts[LS_SIZE_INDEX]);
String date = parts[LS_DATE_INDEX1] + " " + parts[LS_DATE_INDEX2] + " "
+ parts[LS_DATE_INDEX3] + " " + parts[LS_DATE_INDEX4];
return new BasicResource(file, true, contentLength, FORMAT.parse(date)
.getTime(), false);
} catch (Exception ex) {
Message.warn("impossible to parse server response: " + responseLine, ex);
return new BasicResource(file, false, 0, 0, false);
}
}
}
}
开发者ID:apache,项目名称:ant-ivy,代码行数:30,代码来源:VsftpRepository.java
示例7: get
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
public void get(String source, File destination) throws IOException {
fireTransferInitiated(getResource(source), TransferEvent.REQUEST_GET);
try {
Resource res = getResource(source);
long totalLength = res.getContentLength();
if (totalLength > 0) {
progress.setTotalLength(totalLength);
}
FileUtil.copy(new URL(source), destination, progress, getTimeoutConstraint());
} catch (IOException | RuntimeException ex) {
fireTransferError(ex);
throw ex;
} finally {
progress.setTotalLength(null);
}
}
开发者ID:apache,项目名称:ant-ivy,代码行数:17,代码来源:URLRepository.java
示例8: getResource
import org.apache.ivy.plugins.repository.Resource; //导入依赖的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
示例9: getRMDParser
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
protected ResourceMDParser getRMDParser(final DependencyDescriptor dd, final ResolveData data) {
return new ResourceMDParser() {
public MDResolvedResource parse(Resource resource, String rev) {
try {
ResolvedModuleRevision rmr = BasicResolver.this.parse(new ResolvedResource(
resource, rev), dd, data);
if (rmr != null) {
return new MDResolvedResource(resource, rev, rmr);
}
} catch (ParseException e) {
Message.warn("Failed to parse the file '" + resource + "'", e);
}
return null;
}
};
}
开发者ID:apache,项目名称:ant-ivy,代码行数:18,代码来源:BasicResolver.java
示例10: download
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
@Override
public ArtifactDownloadReport download(final ArtifactOrigin origin, DownloadOptions options) {
Checks.checkNotNull(origin, "origin");
return getRepositoryCacheManager().download(origin.getArtifact(),
new ArtifactResourceResolver() {
public ResolvedResource resolve(Artifact artifact) {
try {
Resource resource = getResource(origin.getLocation());
if (resource != null) {
String revision = origin.getArtifact().getModuleRevisionId().getRevision();
return new ResolvedResource(resource, revision);
}
} catch (IOException e) {
Message.debug(e);
}
return null;
}
}, downloader, getCacheDownloadOptions(options));
}
开发者ID:apache,项目名称:ant-ivy,代码行数:20,代码来源:BasicResolver.java
示例11: findIvyFileRef
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
@Override
public ResolvedResource findIvyFileRef( DependencyDescriptor depDescriptor, ResolveData data )
{
Artifact artifact = DefaultArtifact.newIvyArtifact( depDescriptor.getDependencyRevisionId(), null );
ResolutionRequest request = new ResolutionRequest();
request.setArtifact( ivy2aether( artifact.getModuleRevisionId(), "pom" ) );
ResolutionResult result = getResolver().resolve( request );
Path pomPath = result.getArtifactPath();
if ( pomPath == null )
return null;
Resource fileResource = new FileResource( new FileRepository(), pomPath.toFile() );
return new ResolvedResource( fileResource, resolvedVersion( result ) );
}
开发者ID:fedora-java,项目名称:xmvn,代码行数:16,代码来源:IvyResolver.java
示例12: existOnRepo
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
private boolean existOnRepo(String dest) {
try {
final String path = completePath(dest);
final Resource resource = resolver.getRepository().getResource(path);
return resource.exists();
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:jerkar,项目名称:jerkar,代码行数:10,代码来源:IvyPublisherForMaven.java
示例13: loadMavenMedatata
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
private MavenMetadata loadMavenMedatata(String path) {
try {
final Resource resource = resolver.getRepository().getResource(completePath(path));
if (resource.exists()) {
final InputStream inputStream = resource.openStream();
final MavenMetadata mavenMetadata = MavenMetadata.of(inputStream);
inputStream.close();
return mavenMetadata;
}
return null;
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:jerkar,项目名称:jerkar,代码行数:15,代码来源:IvyPublisherForMaven.java
示例14: downloadAndCacheArtifactFile
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
private File downloadAndCacheArtifactFile(final ModuleVersionArtifactMetaData id, Artifact artifact, ResourceDownloader resourceDownloader, Resource resource) throws IOException {
final File tmpFile = temporaryFileProvider.createTemporaryFile("gradle_download", "bin");
try {
resourceDownloader.download(artifact, resource, tmpFile);
return cacheLockingManager.useCache(String.format("Store %s", id), new Factory<File>() {
public File create() {
return fileStore.move(id, tmpFile).getFile();
}
});
} finally {
tmpFile.delete();
}
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:14,代码来源:DownloadingRepositoryCacheManager.java
示例15: parseModuleDescriptor
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
protected ModuleDescriptor parseModuleDescriptor(DependencyResolver resolver, Artifact moduleArtifact, CacheMetadataOptions options, File artifactFile, Resource resource) throws ParseException {
ModuleRevisionId moduleRevisionId = moduleArtifact.getId().getModuleRevisionId();
try {
IvySettings ivySettings = IvyContextualiser.getIvyContext().getSettings();
ParserSettings parserSettings = new LegacyResolverParserSettings(ivySettings, resolver, moduleRevisionId);
ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(resource);
return parser.parseDescriptor(parserSettings, new URL(artifactFile.toURI().toASCIIString()), resource, options.isValidate());
} catch (IOException e) {
throw UncheckedException.throwAsUncheckedException(e);
}
}
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:12,代码来源:AbstractRepositoryCacheManager.java
示例16: getModuleDescriptor
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
public ModuleDescriptor getModuleDescriptor(ParserSettings settings, InputStream input,
Resource res, boolean validate) throws ParseException, IOException {
Parser parser = newParser(settings);
parser.setValidate(validate);
parser.setResource(res);
parser.setInput(input);
parser.parse();
return parser.getModuleDescriptor();
}
开发者ID:alancnet,项目名称:artifactory,代码行数:10,代码来源:IvyParser.java
示例17: getResource
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
/**
* Gets a SvnResource.
*
* @param source Path to the resource in Subversion, relative to the repository root.
* @return The resource.
* @throws IOException Never thrown, just here to satisfy interface.
*/
public Resource getResource(String source) throws IOException {
String repositorySource = getRepositoryRoot() + source;
Resource resource = (Resource) resourcesCache.get(repositorySource);
if (resource == null) {
resource = new SvnResource(this, repositorySource);
resourcesCache.put(repositorySource, resource);
}
return resource;
}
开发者ID:massdosage,项目名称:ivysvn,代码行数:17,代码来源:SvnRepository.java
示例18: buildBundleURI
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
protected URI buildBundleURI(String location) throws IOException {
Resource resource = repo.getResource(location);
// We have a resource to transform into an URI, let's use some heuristics
try {
return new URI(resource.getName());
} catch (URISyntaxException e) {
return new File(resource.getName()).toURI();
}
}
开发者ID:apache,项目名称:ant-ivy,代码行数:10,代码来源:RepositoryManifestIterable.java
示例19: findArtifactRef
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
@Override
public ResolvedResource findArtifactRef(Artifact artifact, Date date) {
URL url = artifact.getUrl();
if (url == null) {
// not an artifact resolved by this resolver
return null;
}
Message.verbose("\tusing url for " + artifact + ": " + url);
logArtifactAttempt(artifact, url.toExternalForm());
final Resource resource = new URLResource(url, this.getTimeoutConstraint());
return new ResolvedResource(resource, artifact.getModuleRevisionId().getRevision());
}
开发者ID:apache,项目名称:ant-ivy,代码行数:13,代码来源:AbstractOSGiResolver.java
示例20: get
import org.apache.ivy.plugins.repository.Resource; //导入依赖的package包/类
@Override
protected long get(Resource resource, File dest) throws IOException {
Message.verbose("\t" + getName() + ": downloading " + resource.getName());
Message.debug("\t\tto " + dest);
if (dest.getParentFile() != null) {
dest.getParentFile().mkdirs();
}
getRepository().get(resource.getName(), dest);
return dest.length();
}
开发者ID:apache,项目名称:ant-ivy,代码行数:11,代码来源:AbstractOSGiResolver.java
注:本文中的org.apache.ivy.plugins.repository.Resource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论