Package: CacheingQuery

CacheingQuery

nameinstructionbranchcomplexitylinemethod
CacheingQuery(Query, 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%
addFilter(String, String)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
addFilter(String, String, Map)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
run()
M: 0 C: 33
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
setVersionRangeFilter(VersionRange)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
setVersionRangeFilter(VersionRange, Query.VersionRangeMatchingStrategy)
M: 8 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

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.util.Collections;
15: import java.util.HashSet;
16: import java.util.Map;
17: import java.util.Set;
18:
19: import org.eclipse.virgo.repository.Query;
20: import org.eclipse.virgo.repository.RepositoryAwareArtifactDescriptor;
21: import org.eclipse.virgo.repository.internal.cacheing.cache.RepositoryCache;
22: import org.eclipse.virgo.util.osgi.manifest.VersionRange;
23:
24: /**
25: * {@link CacheingQuery} wraps a {@link Query} and provides cacheing in the run method.
26: * <p />
27: *
28: * <strong>Concurrent Semantics</strong><br />
29: *
30: * Thread safe.
31: *
32: */
33: final class CacheingQuery implements Query {
34:
35: private final Query delegate;
36:
37: private final RepositoryCache cache;
38:
39: public CacheingQuery(Query delegate, RepositoryCache cache) {
40: this.delegate = delegate;
41: this.cache = cache;
42: }
43:
44: /**
45: * {@inheritDoc}
46: */
47: public Query addFilter(String name, String value) {
48: this.delegate.addFilter(name, value);
49: return this;
50: }
51:
52: /**
53: * {@inheritDoc}
54: */
55: public Query addFilter(String name, String value, Map<String, Set<String>> properties) {
56: this.delegate.addFilter(name, value, properties);
57: return this;
58: }
59:
60: /**
61: * {@inheritDoc}
62: */
63: @Override
64: public Query setVersionRangeFilter(VersionRange versionRange) {
65: this.delegate.setVersionRangeFilter(versionRange);
66: return this;
67: }
68:
69: /**
70: * {@inheritDoc}
71: */
72: @Override
73: public Query setVersionRangeFilter(VersionRange versionRange, VersionRangeMatchingStrategy strategy) {
74: this.delegate.setVersionRangeFilter(versionRange, strategy);
75: return this;
76: }
77:
78: /**
79: * {@inheritDoc}
80: */
81: public Set<RepositoryAwareArtifactDescriptor> run() {
82: Set<RepositoryAwareArtifactDescriptor> descriptors = this.delegate.run();
83:
84: Set<RepositoryAwareArtifactDescriptor> cacheingDescriptors = new HashSet<RepositoryAwareArtifactDescriptor>(descriptors.size());
85:• for (RepositoryAwareArtifactDescriptor descriptor : descriptors) {
86: cacheingDescriptors.add(new CacheingArtifactDescriptor(descriptor, this.cache));
87: }
88:
89: return Collections.unmodifiableSet(cacheingDescriptors);
90: }
91:
92: }