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 2014/04/09 15:25:36 UTC
[3/3] git commit: [KARAF-2888] Add a simulation option
[KARAF-2888] Add a simulation option
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/2b13959e
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/2b13959e
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/2b13959e
Branch: refs/heads/master
Commit: 2b13959eeae1512dd5de8b4e083239130c89df39
Parents: b348022
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Wed Apr 9 15:23:05 2014 +0200
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Wed Apr 9 15:23:29 2014 +0200
----------------------------------------------------------------------
.../features/command/InstallFeatureCommand.java | 5 +++++
.../command/UninstallFeatureCommand.java | 6 ++++++
.../apache/karaf/features/FeaturesService.java | 1 +
.../internal/service/FeaturesServiceImpl.java | 22 ++++++++++++--------
4 files changed, 25 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b13959e/features/command/src/main/java/org/apache/karaf/features/command/InstallFeatureCommand.java
----------------------------------------------------------------------
diff --git a/features/command/src/main/java/org/apache/karaf/features/command/InstallFeatureCommand.java b/features/command/src/main/java/org/apache/karaf/features/command/InstallFeatureCommand.java
index b73dd3f..675d0fe 100644
--- a/features/command/src/main/java/org/apache/karaf/features/command/InstallFeatureCommand.java
+++ b/features/command/src/main/java/org/apache/karaf/features/command/InstallFeatureCommand.java
@@ -44,6 +44,8 @@ public class InstallFeatureCommand extends FeaturesCommandSupport {
boolean noStart;
@Option(name = "-v", aliases = "--verbose", description = "Explain what is being done", required = false, multiValued = false)
boolean verbose;
+ @Option(name = "-t", aliases = "--simulate", description = "Perform a simulation only", required = false, multiValued = false)
+ boolean simulate;
protected void doExecute(FeaturesService admin) throws Exception {
for (String feature : features) {
@@ -57,6 +59,9 @@ public class InstallFeatureCommand extends FeaturesCommandSupport {
version = DEFAULT_VERSION;
}
EnumSet<FeaturesService.Option> options = EnumSet.of(FeaturesService.Option.PrintBundlesToRefresh);
+ if (simulate) {
+ options.add(FeaturesService.Option.Simulate);
+ }
if (noStart) {
options.add(FeaturesService.Option.NoAutoStartBundles);
}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b13959e/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java
----------------------------------------------------------------------
diff --git a/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java b/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java
index b56eac6..14d6be2 100644
--- a/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java
+++ b/features/command/src/main/java/org/apache/karaf/features/command/UninstallFeatureCommand.java
@@ -41,9 +41,15 @@ public class UninstallFeatureCommand extends FeaturesCommandSupport {
@Option(name = "-v", aliases = "--verbose", description = "Explain what is being done", required = false, multiValued = false)
boolean verbose;
+ @Option(name = "-t", aliases = "--simulate", description = "Perform a simulation only", required = false, multiValued = false)
+ boolean simulate;
+
protected void doExecute(FeaturesService admin) throws Exception {
// iterate in the provided feature
EnumSet<FeaturesService.Option> options = EnumSet.noneOf(FeaturesService.Option.class);
+ if (simulate) {
+ options.add(FeaturesService.Option.Simulate);
+ }
if (noRefresh) {
options.add(FeaturesService.Option.NoAutoRefreshBundles);
}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b13959e/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java
----------------------------------------------------------------------
diff --git a/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java b/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java
index 289303c..7855ca4 100644
--- a/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java
+++ b/features/core/src/main/java/org/apache/karaf/features/FeaturesService.java
@@ -33,6 +33,7 @@ public interface FeaturesService {
NoAutoRefreshBundles,
NoAutoStartBundles,
ContinueBatchOnFailure,
+ Simulate,
Verbose
}
http://git-wip-us.apache.org/repos/asf/karaf/blob/2b13959e/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 85a25dd..add1034 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
@@ -735,6 +735,7 @@ public class FeaturesServiceImpl implements FeaturesService {
boolean noRefresh = options.contains(Option.NoAutoRefreshBundles);
boolean noStart = options.contains(Option.NoAutoStartBundles);
boolean verbose = options.contains(Option.Verbose);
+ boolean simulate = options.contains(Option.Simulate);
// Get a list of resolved and unmanaged bundles to use as capabilities during resolution
List<Resource> systemBundles = new ArrayList<Resource>();
@@ -818,8 +819,11 @@ public class FeaturesServiceImpl implements FeaturesService {
//
// Log deployment
//
- logDeployment(deployment);
+ logDeployment(deployment, verbose);
+ if (simulate) {
+ return;
+ }
Set<Bundle> toRefresh = new HashSet<Bundle>();
Set<Bundle> toStart = new HashSet<Bundle>();
@@ -1054,24 +1058,24 @@ public class FeaturesServiceImpl implements FeaturesService {
}
}
- protected void logDeployment(Deployment deployment) {
- LOGGER.info("Changes to perform:");
+ protected void logDeployment(Deployment deployment, boolean verbose) {
+ print("Changes to perform:", verbose);
if (!deployment.toDelete.isEmpty()) {
- LOGGER.info(" Bundles to uninstall:");
+ print(" Bundles to uninstall:", verbose);
for (Bundle bundle : deployment.toDelete) {
- LOGGER.info(" " + bundle.getSymbolicName() + " / " + bundle.getVersion());
+ print(" " + bundle.getSymbolicName() + " / " + bundle.getVersion(), verbose);
}
}
if (!deployment.toUpdate.isEmpty()) {
- LOGGER.info(" Bundles to update:");
+ print(" Bundles to update:", verbose);
for (Map.Entry<Bundle, Resource> entry : deployment.toUpdate.entrySet()) {
- LOGGER.info(" " + entry.getKey().getSymbolicName() + " / " + entry.getKey().getVersion() + " with " + UriNamespace.getUri(entry.getValue()));
+ print(" " + entry.getKey().getSymbolicName() + " / " + entry.getKey().getVersion() + " with " + UriNamespace.getUri(entry.getValue()), verbose);
}
}
if (!deployment.toInstall.isEmpty()) {
- LOGGER.info(" Bundles to install:");
+ print(" Bundles to install:", verbose);
for (Resource resource : deployment.toInstall) {
- LOGGER.info(" " + UriNamespace.getUri(resource));
+ print(" " + UriNamespace.getUri(resource), verbose);
}
}
}