Package: CacheingArtifactDescriptor

CacheingArtifactDescriptor

nameinstructionbranchcomplexitylinemethod
CacheingArtifactDescriptor(RepositoryAwareArtifactDescriptor, RepositoryCache)
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getAttribute(String)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getAttributes()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getFilename()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getName()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getRemoteUri()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getRepositoryName()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getType()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getUri()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getVersion()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2008, 2010 VMware Inc.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * VMware Inc. - initial contribution
10: *******************************************************************************/
11:
12: package org.eclipse.virgo.repository.internal.cacheing;
13:
14: import java.net.URI;
15: import java.util.Set;
16:
17: import org.eclipse.virgo.repository.Attribute;
18: import org.eclipse.virgo.repository.RepositoryAwareArtifactDescriptor;
19: import org.eclipse.virgo.repository.internal.cacheing.cache.RepositoryCache;
20: import org.osgi.framework.Version;
21:
22:
23: /**
24: * {@link CacheingArtifactDescriptor} maintains a local disk cache of remote artifacts keyed by type, name, and version
25: * and delivers URIs of cached artifacts instead of the corresponding remote URIs.
26: * <p />
27: *
28: * <strong>Concurrent Semantics</strong><br />
29: *
30: * This class is thread safe.
31: *
32: */
33: public final class CacheingArtifactDescriptor implements RepositoryAwareArtifactDescriptor {
34:
35: private final RepositoryAwareArtifactDescriptor source;
36:
37: private final RepositoryCache cache;
38:
39: CacheingArtifactDescriptor(RepositoryAwareArtifactDescriptor source, RepositoryCache cache) {
40: this.source = source;
41: this.cache = cache;
42: }
43:
44: /**
45: * {@inheritDoc}
46: */
47: public Set<Attribute> getAttribute(String name) {
48: return this.source.getAttribute(name);
49: }
50:
51: /**
52: * {@inheritDoc}
53: */
54: public Set<Attribute> getAttributes() {
55: return this.source.getAttributes();
56: }
57:
58: /**
59: * {@inheritDoc}
60: */
61: public String getFilename() {
62: return this.source.getFilename();
63: }
64:
65: /**
66: * {@inheritDoc}
67: */
68: public String getName() {
69: return this.source.getName();
70: }
71:
72: /**
73: * {@inheritDoc}
74: */
75: public String getRepositoryName() {
76: return this.source.getRepositoryName();
77: }
78:
79: /**
80: * {@inheritDoc}
81: */
82: public String getType() {
83: return this.source.getType();
84: }
85:
86: /**
87: * Returns the {@link URI} of the cached artifact. If the artifact cannot be downloaded, throws a <code>RuntimeException</code>.
88: *
89: * @return the cached <code>URI</code>
90: */
91: public URI getUri() {
92: return this.cache.getUri(this);
93: }
94:
95: /**
96: * Returns the remote (uncached) {@link URI} of the artifact.
97: *
98: * @return the remote (uncached) <code>URI</code>
99: */
100: public URI getRemoteUri() {
101: return this.source.getUri();
102: }
103:
104: /**
105: * {@inheritDoc}
106: */
107: public Version getVersion() {
108: return this.source.getVersion();
109: }
110:
111: }