You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2017/07/25 19:42:00 UTC
[2/6] karaf git commit: Make the Deployer.Callback class sufficient
Make the Deployer.Callback class sufficient
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/bc9adda4
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/bc9adda4
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/bc9adda4
Branch: refs/heads/master
Commit: bc9adda43e33c8c1a8f83c14944844427f0a384d
Parents: ef83085
Author: Guillaume Nodet <gn...@apache.org>
Authored: Mon Jul 24 22:51:27 2017 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Tue Jul 25 21:40:14 2017 +0200
----------------------------------------------------------------------
.../features/internal/service/Deployer.java | 59 +++++---
.../internal/service/FeaturesServiceImpl.java | 63 +++++++-
.../features/internal/service/DeployerTest.java | 149 ++++++++++++-------
.../apache/karaf/profile/assembly/Builder.java | 2 +-
.../org/apache/karaf/tooling/VerifyMojo.java | 2 +-
5 files changed, 195 insertions(+), 80 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/bc9adda4/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
index 4996b9b..5f7b105 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/Deployer.java
@@ -61,6 +61,7 @@ import org.eclipse.equinox.region.RegionDigraph;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
import org.osgi.framework.namespace.BundleNamespace;
@@ -114,6 +115,20 @@ public class Deployer {
void persistResolveRequest(DeploymentRequest request) throws IOException;
void callListeners(DeploymentEvent deployEvent);
void callListeners(FeatureEvent featureEvent);
+
+ Bundle installBundle(String region, String uri, InputStream is) throws BundleException;
+ void updateBundle(Bundle bundle, String uri, InputStream is) throws BundleException;
+ void uninstall(Bundle bundle) throws BundleException;
+ void startBundle(Bundle bundle) throws BundleException;
+ void stopBundle(Bundle bundle, int options) throws BundleException;
+ void setBundleStartLevel(Bundle bundle, int startLevel);
+ void resolveBundles(Set<Bundle> bundles, Map<Resource, List<Wire>> wiring,
+ Map<Resource, Bundle> resToBnd);
+ void refreshPackages(Collection<Bundle> bundles) throws InterruptedException;
+ void replaceDigraph(Map<String, Map<String, Map<String, Set<String>>>> policies,
+ Map<String, Set<Long>> bundles) throws BundleException, InvalidSyntaxException;
+ void installConfigs(Feature feature) throws IOException, InvalidSyntaxException;
+ void installLibraries(Feature feature) throws IOException;
}
@SuppressWarnings("serial")
@@ -184,13 +199,11 @@ public class Deployer {
private final DownloadManager manager;
private final Resolver resolver;
- private final BundleInstallSupport installSupport;
private final DeployCallback callback;
- public Deployer(DownloadManager manager, Resolver resolver, BundleInstallSupport installSupport, DeployCallback callback) {
+ public Deployer(DownloadManager manager, Resolver resolver, DeployCallback callback) {
this.manager = manager;
this.resolver = resolver;
- this.installSupport = installSupport;
this.callback = callback;
}
@@ -357,7 +370,7 @@ public class Deployer {
Set<? extends Resource> unmanaged = apply(flatten(unmanagedBundles), adapt(BundleRevision.class));
Set<Resource> requested = new HashSet<>();
// Gather bundles required by a feature
- if (resolver != null && resolver.getWiring() != null) {
+ if (resolver.getWiring() != null) {
for (List<Wire> wires : resolver.getWiring().values()) {
for (Wire wire : wires) {
if (features.contains(wire.getRequirer()) && unmanaged.contains(wire.getProvider())) {
@@ -369,7 +382,7 @@ public class Deployer {
// Now, we know which bundles are completely unmanaged
unmanaged.removeAll(requested);
// Check if bundles have wires from really unmanaged bundles
- if (resolver != null && resolver.getWiring() != null) {
+ if (resolver.getWiring() != null) {
for (List<Wire> wires : resolver.getWiring().values()) {
for (Wire wire : wires) {
if (requested.contains(wire.getProvider()) && unmanaged.contains(wire.getRequirer())) {
@@ -597,14 +610,14 @@ public class Deployer {
dstate.bundles.values(),
Collections.emptyMap(),
Collections.emptyMap());
- installSupport.stopBundle(serviceBundle, STOP_TRANSIENT);
+ callback.stopBundle(serviceBundle, STOP_TRANSIENT);
try (
InputStream is = getBundleInputStream(resource, providers)
) {
- installSupport.updateBundle(serviceBundle, uri, is);
+ callback.updateBundle(serviceBundle, uri, is);
}
- installSupport.refreshPackages(toRefresh.keySet());
- installSupport.startBundle(serviceBundle);
+ callback.refreshPackages(toRefresh.keySet());
+ callback.startBundle(serviceBundle);
return;
}
@@ -630,7 +643,7 @@ public class Deployer {
print(" " + bundle.getSymbolicName() + "/" + bundle.getVersion(), verbose);
// If the bundle start level will be changed, stop it persistently to
// avoid a restart when the start level is actually changed
- installSupport.stopBundle(bundle, toUpdateStartLevel.containsKey(bundle) ? 0 : STOP_TRANSIENT);
+ callback.stopBundle(bundle, toUpdateStartLevel.containsKey(bundle) ? 0 : STOP_TRANSIENT);
toStop.remove(bundle);
}
}
@@ -652,7 +665,7 @@ public class Deployer {
Deployer.RegionDeployment regionDeployment = entry.getValue();
for (Bundle bundle : regionDeployment.toDelete) {
print(" " + bundle.getSymbolicName() + "/" + bundle.getVersion(), verbose);
- installSupport.uninstall(bundle);
+ callback.uninstall(bundle);
removeFromMapSet(managedBundles, name, bundle.getBundleId());
}
}
@@ -692,7 +705,7 @@ public class Deployer {
}
}
// Apply all changes
- installSupport.replaceDigraph(policies, bundles);
+ callback.replaceDigraph(policies, bundles);
}
@@ -716,7 +729,7 @@ public class Deployer {
try (
InputStream is = getBundleInputStream(resource, providers)
) {
- installSupport.updateBundle(bundle, uri, is);
+ callback.updateBundle(bundle, uri, is);
}
toStart.add(bundle);
}
@@ -728,7 +741,7 @@ public class Deployer {
for (Map.Entry<Bundle, Integer> entry : toUpdateStartLevel.entrySet()) {
Bundle bundle = entry.getKey();
int sl = entry.getValue();
- bundle.adapt(BundleStartLevel.class).setStartLevel(sl);
+ callback.setBundleStartLevel(bundle, sl);
}
//
// Install bundles
@@ -753,7 +766,7 @@ public class Deployer {
try (
ChecksumUtils.CRCInputStream is = new ChecksumUtils.CRCInputStream(getBundleInputStream(resource, providers))
) {
- bundle = installSupport.installBundle(name, uri, is);
+ bundle = callback.installBundle(name, uri, is);
crc = is.getCRC();
}
addToMapSet(managedBundles, name, bundle.getBundleId());
@@ -808,14 +821,14 @@ public class Deployer {
Set<String> featureIds = flatten(newFeatures);
for (Feature feature : dstate.features.values()) {
if (featureIds.contains(feature.getId())) {
- installSupport.installConfigs(feature);
- installSupport.installLibraries(feature);
+ callback.installConfigs(feature);
+ callback.installLibraries(feature);
}
for (Conditional cond : feature.getConditional()) {
Feature condFeature = cond.asFeature();
if (featureIds.contains(condFeature.getId())) {
- installSupport.installConfigs(condFeature);
- installSupport.installLibraries(condFeature);
+ callback.installConfigs(condFeature);
+ callback.installLibraries(condFeature);
}
}
}
@@ -838,7 +851,7 @@ public class Deployer {
List<Bundle> bs = getBundlesToStop(toStop);
for (Bundle bundle : bs) {
print(" " + bundle.getSymbolicName() + "/" + bundle.getVersion(), verbose);
- installSupport.stopBundle(bundle, STOP_TRANSIENT);
+ callback.stopBundle(bundle, STOP_TRANSIENT);
toStop.remove(bundle);
toStart.add(bundle);
}
@@ -855,7 +868,7 @@ public class Deployer {
if (serviceBundle != null && toRefresh.containsKey(serviceBundle)) {
ensureAllClassesLoaded(serviceBundle);
}
- installSupport.refreshPackages(toRefresh.keySet());
+ callback.refreshPackages(toRefresh.keySet());
}
}
@@ -865,7 +878,7 @@ public class Deployer {
toResolve.addAll(toRefresh.keySet());
removeBundlesInState(toResolve, UNINSTALLED);
callback.callListeners(DeploymentEvent.BUNDLES_INSTALLED);
- installSupport.resolveBundles(toResolve, resolver.getWiring(), deployment.resToBnd);
+ callback.resolveBundles(toResolve, resolver.getWiring(), deployment.resToBnd);
callback.callListeners(DeploymentEvent.BUNDLES_RESOLVED);
// Compute bundles to start
@@ -879,7 +892,7 @@ public class Deployer {
for (Bundle bundle : bs) {
print(" " + bundle.getSymbolicName() + "/" + bundle.getVersion(), verbose);
try {
- installSupport.startBundle(bundle);
+ callback.startBundle(bundle);
} catch (BundleException e) {
exceptions.add(e);
}
http://git-wip-us.apache.org/repos/asf/karaf/blob/bc9adda4/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
index e5a8b54..353d40d 100644
--- a/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
+++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/FeaturesServiceImpl.java
@@ -20,6 +20,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
@@ -70,7 +71,12 @@ import org.apache.karaf.util.collections.CopyOnWriteArrayIdentityList;
import org.eclipse.equinox.region.RegionDigraph;
import org.ops4j.pax.url.mvn.MavenResolver;
import org.ops4j.pax.url.mvn.MavenResolvers;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.Version;
+import org.osgi.resource.Resource;
+import org.osgi.resource.Wire;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
import org.osgi.service.resolver.Resolver;
@@ -1045,7 +1051,7 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
try {
Deployer.DeploymentState dstate = getDeploymentState(state);
Deployer.DeploymentRequest request = getDeploymentRequest(requirements, stateChanges, options, outputFile);
- new Deployer(manager, this.resolver, this.installSupport, this).deploy(dstate, request);
+ new Deployer(manager, this.resolver, this).deploy(dstate, request);
break;
} catch (Deployer.PartialDeploymentException e) {
if (!prereqs.containsAll(e.getMissing())) {
@@ -1104,6 +1110,61 @@ public class FeaturesServiceImpl implements FeaturesService, Deployer.DeployCall
writeResolve(request.requirements, request.options);
}
+ @Override
+ public void refreshPackages(Collection<Bundle> bundles) throws InterruptedException {
+ installSupport.refreshPackages(bundles);
+ }
+
+ @Override
+ public Bundle installBundle(String region, String uri, InputStream is) throws BundleException {
+ return installSupport.installBundle(region, uri, is);
+ }
+
+ @Override
+ public void updateBundle(Bundle bundle, String uri, InputStream is) throws BundleException {
+ installSupport.updateBundle(bundle, uri, is);
+ }
+
+ @Override
+ public void uninstall(Bundle bundle) throws BundleException {
+ installSupport.uninstall(bundle);
+ }
+
+ @Override
+ public void startBundle(Bundle bundle) throws BundleException {
+ installSupport.startBundle(bundle);
+ }
+
+ @Override
+ public void stopBundle(Bundle bundle, int options) throws BundleException {
+ installSupport.stopBundle(bundle, options);
+ }
+
+ @Override
+ public void setBundleStartLevel(Bundle bundle, int startLevel) {
+ installSupport.setBundleStartLevel(bundle, startLevel);
+ }
+
+ @Override
+ public void resolveBundles(Set<Bundle> bundles, Map<Resource, List<Wire>> wiring, Map<Resource, Bundle> resToBnd) {
+ installSupport.resolveBundles(bundles, wiring, resToBnd);
+ }
+
+ @Override
+ public void replaceDigraph(Map<String, Map<String, Map<String, Set<String>>>> policies, Map<String, Set<Long>> bundles) throws BundleException, InvalidSyntaxException {
+ installSupport.replaceDigraph(policies, bundles);
+ }
+
+ @Override
+ public void installConfigs(Feature feature) throws IOException, InvalidSyntaxException {
+ installSupport.installConfigs(feature);
+ }
+
+ @Override
+ public void installLibraries(Feature feature) throws IOException {
+ installSupport.installLibraries(feature);
+ }
+
private Pattern getFeaturePattern(String name, String version) {
String req = FEATURE_OSGI_REQUIREMENT_PREFIX + getFeatureRequirement(name, version);
req = req.replace("[", "\\[");
http://git-wip-us.apache.org/repos/asf/karaf/blob/bc9adda4/features/core/src/test/java/org/apache/karaf/features/internal/service/DeployerTest.java
----------------------------------------------------------------------
diff --git a/features/core/src/test/java/org/apache/karaf/features/internal/service/DeployerTest.java b/features/core/src/test/java/org/apache/karaf/features/internal/service/DeployerTest.java
index bdad44c..651f88e 100644
--- a/features/core/src/test/java/org/apache/karaf/features/internal/service/DeployerTest.java
+++ b/features/core/src/test/java/org/apache/karaf/features/internal/service/DeployerTest.java
@@ -19,11 +19,13 @@ package org.apache.karaf.features.internal.service;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.jar.Manifest;
@@ -37,7 +39,6 @@ import org.apache.karaf.features.FeaturesService;
import org.apache.karaf.features.internal.resolver.Slf4jResolverLog;
import org.apache.karaf.features.internal.support.TestBundle;
import org.apache.karaf.features.internal.support.TestDownloadManager;
-import org.easymock.Capture;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
import org.easymock.IArgumentMatcher;
@@ -45,6 +46,9 @@ import org.easymock.IMocksControl;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.resource.Resource;
+import org.osgi.resource.Wire;
import org.osgi.service.resolver.Resolver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -52,8 +56,6 @@ import org.slf4j.LoggerFactory;
import static org.apache.karaf.features.FeaturesService.*;
import static org.apache.karaf.features.internal.util.MapUtils.addToMapSet;
import static org.easymock.EasyMock.anyInt;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.expectLastCall;
import static org.junit.Assert.fail;
public class DeployerTest {
@@ -74,25 +76,24 @@ public class DeployerTest {
Feature f101 = repo.getFeatures()[1];
Deployer.DeployCallback callback = c.createMock(Deployer.DeployCallback.class);
- BundleInstallSupport installSupport = c.createMock(BundleInstallSupportImpl.class);
- Deployer deployer = new Deployer(manager, resolver, installSupport, callback);
+ Deployer deployer = new Deployer(manager, resolver, callback);
callback.print(EasyMock.anyString(), EasyMock.anyBoolean());
EasyMock.expectLastCall().anyTimes();
callback.callListeners(DeploymentEvent.DEPLOYMENT_STARTED);
EasyMock.expectLastCall();
- installSupport.replaceDigraph(EasyMock.anyObject(),
+ callback.replaceDigraph(EasyMock.anyObject(),
EasyMock.anyObject());
EasyMock.expectLastCall();
callback.saveState(EasyMock.anyObject());
EasyMock.expectLastCall();
- installSupport.installConfigs(f100);
+ callback.installConfigs(f100);
EasyMock.expectLastCall();
- installSupport.installLibraries(f100);
+ callback.installLibraries(f100);
EasyMock.expectLastCall();
callback.callListeners(DeploymentEvent.BUNDLES_INSTALLED);
EasyMock.expectLastCall();
- installSupport.resolveBundles(EasyMock.anyObject(),
+ callback.resolveBundles(EasyMock.anyObject(),
EasyMock.anyObject(),
EasyMock.anyObject());
EasyMock.expectLastCall();
@@ -104,7 +105,7 @@ public class DeployerTest {
EasyMock.expectLastCall();
Bundle bundleA = createTestBundle(1, Bundle.ACTIVE, dataDir, "a100");
- EasyMock.expect(installSupport.installBundle(EasyMock.eq(ROOT_REGION), EasyMock.eq("a100"), EasyMock.anyObject()))
+ EasyMock.expect(callback.installBundle(EasyMock.eq(ROOT_REGION), EasyMock.eq("a100"), EasyMock.anyObject()))
.andReturn(bundleA);
c.replay();
@@ -149,8 +150,7 @@ public class DeployerTest {
Feature f101 = repo.getFeatures()[1];
Deployer.DeployCallback callback = c.createMock(Deployer.DeployCallback.class);
- BundleInstallSupport installSupport = c.createMock(BundleInstallSupportImpl.class);
- Deployer deployer = new Deployer(manager, resolver, installSupport, callback);
+ Deployer deployer = new Deployer(manager, resolver, callback);
final TestBundle bundleA = createTestBundle(1L, Bundle.ACTIVE, dataDir, "a100");
@@ -159,12 +159,12 @@ public class DeployerTest {
callback.callListeners(DeploymentEvent.DEPLOYMENT_STARTED);
EasyMock.expectLastCall();
- installSupport.stopBundle(EasyMock.eq(bundleA), anyInt());
+ callback.stopBundle(EasyMock.eq(bundleA), anyInt());
EasyMock.expectLastCall().andStubAnswer(() -> {
bundleA.state = Bundle.RESOLVED;
return null;
});
- installSupport.updateBundle(EasyMock.eq(bundleA), EasyMock.anyObject(), EasyMock.anyObject());
+ callback.updateBundle(EasyMock.eq(bundleA), EasyMock.anyObject(), EasyMock.anyObject());
EasyMock.expectLastCall().andStubAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
@@ -178,27 +178,27 @@ public class DeployerTest {
return null;
}
});
- installSupport.startBundle(EasyMock.eq(bundleA));
+ callback.startBundle(EasyMock.eq(bundleA));
EasyMock.expectLastCall();
- installSupport.replaceDigraph(EasyMock.anyObject(),
+ callback.replaceDigraph(EasyMock.anyObject(),
EasyMock.anyObject());
EasyMock.expectLastCall();
callback.saveState(EasyMock.anyObject());
EasyMock.expectLastCall();
- installSupport.installConfigs(f101);
+ callback.installConfigs(f101);
EasyMock.expectLastCall();
- installSupport.installLibraries(f101);
+ callback.installLibraries(f101);
EasyMock.expectLastCall();
callback.callListeners(DeploymentEvent.BUNDLES_INSTALLED);
EasyMock.expectLastCall();
- installSupport.resolveBundles(EasyMock.eq(Collections.singleton(bundleA)),
+ callback.resolveBundles(EasyMock.eq(Collections.singleton(bundleA)),
EasyMock.anyObject(),
EasyMock.anyObject());
EasyMock.expectLastCall();
callback.callListeners(DeploymentEvent.BUNDLES_RESOLVED);
EasyMock.expectLastCall();
- installSupport.refreshPackages(EasyMock.eq(Collections.singleton(bundleA)));
+ callback.refreshPackages(EasyMock.eq(Collections.singleton(bundleA)));
EasyMock.expectLastCall();
callback.callListeners(FeatureEventMatcher.eq(new FeatureEvent(FeatureEvent.EventType.FeatureUninstalled, f100, FeaturesService.ROOT_REGION, false)));
EasyMock.expectLastCall();
@@ -253,25 +253,24 @@ public class DeployerTest {
Bundle serviceBundle = createTestBundle(1, Bundle.ACTIVE, dataDir, "a100");
Deployer.DeployCallback callback = c.createMock(Deployer.DeployCallback.class);
- BundleInstallSupport installSupport = c.createMock(BundleInstallSupportImpl.class);
- Deployer deployer = new Deployer(manager, resolver, installSupport, callback);
+ Deployer deployer = new Deployer(manager, resolver, callback);
callback.print(EasyMock.anyString(), EasyMock.anyBoolean());
EasyMock.expectLastCall().anyTimes();
callback.callListeners(DeploymentEvent.DEPLOYMENT_STARTED);
EasyMock.expectLastCall();
- installSupport.replaceDigraph(EasyMock.anyObject(),
+ callback.replaceDigraph(EasyMock.anyObject(),
EasyMock.anyObject());
EasyMock.expectLastCall();
callback.saveState(EasyMock.anyObject());
EasyMock.expectLastCall();
callback.callListeners(DeploymentEvent.BUNDLES_INSTALLED);
EasyMock.expectLastCall();
- installSupport.installConfigs(f1);
+ callback.installConfigs(f1);
EasyMock.expectLastCall();
- installSupport.installLibraries(f1);
+ callback.installLibraries(f1);
EasyMock.expectLastCall();
- installSupport.resolveBundles(EasyMock.anyObject(),
+ callback.resolveBundles(EasyMock.anyObject(),
EasyMock.anyObject(),
EasyMock.anyObject());
EasyMock.expectLastCall();
@@ -327,27 +326,26 @@ public class DeployerTest {
Bundle serviceBundle2 = createTestBundle(2, Bundle.ACTIVE, dataDir, "b100");
Deployer.DeployCallback callback = c.createMock(Deployer.DeployCallback.class);
- BundleInstallSupport installSupport = c.createMock(BundleInstallSupportImpl.class);
- Deployer deployer = new Deployer(manager, resolver, installSupport, callback);
+ Deployer deployer = new Deployer(manager, resolver, callback);
callback.print(EasyMock.anyString(), EasyMock.anyBoolean());
EasyMock.expectLastCall().anyTimes();
callback.callListeners(DeploymentEvent.DEPLOYMENT_STARTED);
EasyMock.expectLastCall();
- installSupport.installBundle(EasyMock.eq(ROOT_REGION), EasyMock.eq("a100"), EasyMock.anyObject());
+ callback.installBundle(EasyMock.eq(ROOT_REGION), EasyMock.eq("a100"), EasyMock.anyObject());
EasyMock.expectLastCall().andReturn(serviceBundle1);
- installSupport.replaceDigraph(EasyMock.anyObject(),
+ callback.replaceDigraph(EasyMock.anyObject(),
EasyMock.anyObject());
EasyMock.expectLastCall();
callback.saveState(EasyMock.anyObject());
EasyMock.expectLastCall();
- installSupport.installConfigs(EasyMock.anyObject());
+ callback.installConfigs(EasyMock.anyObject());
EasyMock.expectLastCall();
- installSupport.installLibraries(EasyMock.anyObject());
+ callback.installLibraries(EasyMock.anyObject());
EasyMock.expectLastCall();
callback.callListeners(DeploymentEvent.BUNDLES_INSTALLED);
EasyMock.expectLastCall();
- installSupport.resolveBundles(EasyMock.anyObject(),
+ callback.resolveBundles(EasyMock.anyObject(),
EasyMock.anyObject(),
EasyMock.anyObject());
EasyMock.expectLastCall();
@@ -396,20 +394,20 @@ public class DeployerTest {
EasyMock.expectLastCall().anyTimes();
callback.callListeners(DeploymentEvent.DEPLOYMENT_STARTED);
EasyMock.expectLastCall();
- installSupport.installBundle(EasyMock.eq(ROOT_REGION), EasyMock.eq("b100"), EasyMock.anyObject());
+ callback.installBundle(EasyMock.eq(ROOT_REGION), EasyMock.eq("b100"), EasyMock.anyObject());
EasyMock.expectLastCall().andReturn(serviceBundle2);
- installSupport.replaceDigraph(EasyMock.anyObject(),
+ callback.replaceDigraph(EasyMock.anyObject(),
EasyMock.anyObject());
EasyMock.expectLastCall();
callback.saveState(EasyMock.anyObject());
EasyMock.expectLastCall();
- installSupport.installConfigs(f2);
+ callback.installConfigs(f2);
EasyMock.expectLastCall();
- installSupport.installLibraries(f2);
+ callback.installLibraries(f2);
EasyMock.expectLastCall();
callback.callListeners(DeploymentEvent.BUNDLES_INSTALLED);
EasyMock.expectLastCall();
- installSupport.resolveBundles(EasyMock.anyObject(),
+ callback.resolveBundles(EasyMock.anyObject(),
EasyMock.anyObject(),
EasyMock.anyObject());
EasyMock.expectLastCall();
@@ -509,21 +507,8 @@ public class DeployerTest {
request.stateChanges = Collections.emptyMap();
request.updateSnaphots = UPDATE_SNAPSHOTS_NONE;
- MyDeployCallback callback = new MyDeployCallback(dstate);
- BundleInstallSupport installSupport = c.createMock(BundleInstallSupportImpl.class);
- Capture<String> capture = Capture.newInstance();
- installSupport.installBundle(EasyMock.anyString(), EasyMock.capture(capture), anyObject(InputStream.class));
- EasyMock.expectLastCall().andAnswer(() -> bundles.get(capture.getValue())).atLeastOnce();
- installSupport.installConfigs(EasyMock.anyObject());
- EasyMock.expectLastCall().atLeastOnce();
- installSupport.installLibraries(EasyMock.anyObject());
- EasyMock.expectLastCall().atLeastOnce();
- installSupport.replaceDigraph(EasyMock.anyObject(),
- EasyMock.anyObject());
- expectLastCall().atLeastOnce();
- installSupport.resolveBundles(anyObject(Set.class), anyObject(Map.class), anyObject(Map.class));
- expectLastCall().atLeastOnce();
- Deployer deployer = new Deployer(manager, resolver, installSupport, callback);
+ MyDeployCallback callback = new MyDeployCallback(dstate, bundles);
+ Deployer deployer = new Deployer(manager, resolver, callback);
c.replay();
for (int i = 1; i <= 4; i++) {
@@ -586,9 +571,11 @@ public class DeployerTest {
private static class MyDeployCallback implements Deployer.DeployCallback {
final Deployer.DeploymentState dstate;
+ final Map<String, Bundle> bundles;
- public MyDeployCallback(Deployer.DeploymentState dstate) {
+ public MyDeployCallback(Deployer.DeploymentState dstate, Map<String, Bundle> bundles) {
this.dstate = dstate;
+ this.bundles = bundles;
}
@Override
@@ -612,5 +599,59 @@ public class DeployerTest {
public void callListeners(DeploymentEvent deployEvent) {
}
+ @Override
+ public Bundle installBundle(String region, String uri, InputStream is) throws BundleException {
+ return bundles.get(uri);
+ }
+
+ @Override
+ public void updateBundle(Bundle bundle, String uri, InputStream is) throws BundleException {
+
+ }
+
+ @Override
+ public void uninstall(Bundle bundle) throws BundleException {
+
+ }
+
+ @Override
+ public void startBundle(Bundle bundle) throws BundleException {
+
+ }
+
+ @Override
+ public void stopBundle(Bundle bundle, int options) throws BundleException {
+
+ }
+
+ @Override
+ public void setBundleStartLevel(Bundle bundle, int startLevel) {
+
+ }
+
+ @Override
+ public void resolveBundles(Set<Bundle> bundles, Map<Resource, List<Wire>> wiring, Map<Resource, Bundle> resToBnd) {
+
+ }
+
+ @Override
+ public void refreshPackages(Collection<Bundle> bundles) throws InterruptedException {
+
+ }
+
+ @Override
+ public void replaceDigraph(Map<String, Map<String, Map<String, Set<String>>>> policies, Map<String, Set<Long>> bundles) throws BundleException, InvalidSyntaxException {
+
+ }
+
+ @Override
+ public void installConfigs(Feature feature) throws IOException, InvalidSyntaxException {
+
+ }
+
+ @Override
+ public void installLibraries(Feature feature) throws IOException {
+
+ }
}
}
http://git-wip-us.apache.org/repos/asf/karaf/blob/bc9adda4/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
----------------------------------------------------------------------
diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
index 74ef8b0..e20080c 100644
--- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
+++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
@@ -1421,7 +1421,7 @@ public class Builder {
Collection<String> optionals) throws Exception {
BundleRevision systemBundle = getSystemBundle();
AssemblyDeployCallback callback = new AssemblyDeployCallback(manager, this, systemBundle, repositories);
- Deployer deployer = new Deployer(manager, resolver, callback, callback);
+ Deployer deployer = new Deployer(manager, resolver, callback);
// Install framework
Deployer.DeploymentRequest request = createDeploymentRequest();
http://git-wip-us.apache.org/repos/asf/karaf/blob/bc9adda4/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
index d4595c2..5ed7522 100644
--- a/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
+++ b/tooling/karaf-maven-plugin/src/main/java/org/apache/karaf/tooling/VerifyMojo.java
@@ -422,7 +422,7 @@ public class VerifyMojo extends MojoSupport {
try {
Bundle systemBundle = getSystemBundle(getMetadata(properties, "metadata#"));
DummyDeployCallback callback = new DummyDeployCallback(systemBundle, repositories.values());
- Deployer deployer = new Deployer(manager, new ResolverImpl(new MavenResolverLog()), callback, callback);
+ Deployer deployer = new Deployer(manager, new ResolverImpl(new MavenResolverLog()), callback);
// Install framework