Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2011-04-03 14:00:38 -0400
committerGlyn Normington2011-04-03 14:00:38 -0400
commit7e6e9e51dc50671f5b6a47c1ee9b85b1e66c1055 (patch)
tree12d444a80cdb7421c5502affd831a09ead2b67de /org.eclipse.virgo.kernel.shell
parentf225255ba1c7bb3c0ca00ba66add09d0bc7c9a92 (diff)
downloadorg.eclipse.virgo.kernel-7e6e9e51dc50671f5b6a47c1ee9b85b1e66c1055.tar.gz
org.eclipse.virgo.kernel-7e6e9e51dc50671f5b6a47c1ee9b85b1e66c1055.tar.xz
org.eclipse.virgo.kernel-7e6e9e51dc50671f5b6a47c1ee9b85b1e66c1055.zip
allow vsh command to examine kernel bundles
Diffstat (limited to 'org.eclipse.virgo.kernel.shell')
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/AbstractInstallArtifactBasedCommands.java22
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/BundleCommands.java8
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/ConfigCommands.java2
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/ParCommands.java2
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/PlanCommands.java2
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java12
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/resources/META-INF/spring/module-context.xml1
-rw-r--r--org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubAbstractCompositeInstallArtifactBasedCommands.java2
8 files changed, 39 insertions, 12 deletions
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/AbstractInstallArtifactBasedCommands.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/AbstractInstallArtifactBasedCommands.java
index f99531e0..3d4cde83 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/AbstractInstallArtifactBasedCommands.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/AbstractInstallArtifactBasedCommands.java
@@ -27,6 +27,8 @@ import org.osgi.framework.Version;
import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
import org.eclipse.virgo.kernel.model.management.RuntimeArtifactModelObjectNameCreator;
+import org.eclipse.virgo.kernel.osgi.region.Region;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.shell.Command;
import org.eclipse.virgo.kernel.shell.internal.formatting.InstallArtifactCommandFormatter;
import org.eclipse.virgo.kernel.shell.internal.util.ArtifactRetriever;
@@ -53,12 +55,15 @@ abstract class AbstractInstallArtifactBasedCommands<T extends ManageableArtifact
private final ArtifactRetriever<T> artifactRetriever;
+ private final Region kernelRegion;
+
public AbstractInstallArtifactBasedCommands(String type, RuntimeArtifactModelObjectNameCreator objectNameCreator,
- InstallArtifactCommandFormatter<T> formatter, Class<T> artifactType) {
+ InstallArtifactCommandFormatter<T> formatter, Class<T> artifactType, RegionDigraph regionDigraph) {
this.type = type;
this.objectNameCreator = objectNameCreator;
this.formatter = formatter;
this.artifactRetriever = new ArtifactRetriever<T>(type, objectNameCreator, artifactType);
+ this.kernelRegion = regionDigraph == null ? null : regionDigraph.getRegion(0L);
}
@Command("list")
@@ -77,13 +82,22 @@ abstract class AbstractInstallArtifactBasedCommands<T extends ManageableArtifact
}
@Command("examine")
- public List<String> examine(String name, String version) {
+ public List<String> examine(String name, String versionString) {
+ Version version = convertToVersion(versionString);
try {
- return this.formatter.formatExamine(this.artifactRetriever.getArtifact(name, convertToVersion(version)));
+ return this.formatter.formatExamine(this.artifactRetriever.getArtifact(name, version));
} catch (IllegalArgumentException iae) {
return Arrays.asList(iae.getMessage());
} catch (InstanceNotFoundException e) {
- return getDoesNotExistMessage(this.type, name, version);
+ if (this.kernelRegion != null) {
+ try {
+ return this.formatter.formatExamine(this.artifactRetriever.getArtifact(name, version, this.kernelRegion));
+ } catch (InstanceNotFoundException _) {
+ return getDoesNotExistMessage(this.type, name, versionString);
+ }
+ } else {
+ return getDoesNotExistMessage(this.type, name, versionString);
+ }
}
}
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/BundleCommands.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/BundleCommands.java
index 1c740396..cb1bae39 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/BundleCommands.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/BundleCommands.java
@@ -14,16 +14,16 @@ package org.eclipse.virgo.kernel.shell.internal.commands;
import java.util.Arrays;
import java.util.List;
-import org.osgi.framework.Version;
-
import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
import org.eclipse.virgo.kernel.model.management.RuntimeArtifactModelObjectNameCreator;
import org.eclipse.virgo.kernel.module.ModuleContextAccessor;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiBundle;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiResolutionFailure;
+import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.shell.Command;
import org.eclipse.virgo.kernel.shell.internal.formatting.BundleInstallArtifactCommandFormatter;
import org.eclipse.virgo.kernel.shell.state.StateService;
+import org.osgi.framework.Version;
/**
* <p>
@@ -49,8 +49,8 @@ final class BundleCommands extends AbstractInstallArtifactBasedCommands<Manageab
private final StateService stateService;
public BundleCommands(RuntimeArtifactModelObjectNameCreator objectNameCreator, StateService stateService,
- ModuleContextAccessor moduleContextAccessor) {
- super(TYPE, objectNameCreator, new BundleInstallArtifactCommandFormatter(stateService, moduleContextAccessor), ManageableArtifact.class);
+ ModuleContextAccessor moduleContextAccessor, RegionDigraph regionDigraph) {
+ super(TYPE, objectNameCreator, new BundleInstallArtifactCommandFormatter(stateService, moduleContextAccessor), ManageableArtifact.class, regionDigraph);
this.stateService = stateService;
this.formatter = new BundleInstallArtifactCommandFormatter(stateService, moduleContextAccessor);
}
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/ConfigCommands.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/ConfigCommands.java
index 8a6044d8..71366423 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/ConfigCommands.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/ConfigCommands.java
@@ -46,7 +46,7 @@ final class ConfigCommands extends AbstractInstallArtifactBasedCommands<Manageab
private static final String STATE_ACTIVE = "ACTIVE";
public ConfigCommands(RuntimeArtifactModelObjectNameCreator objectNameCreator, ConfigurationAdmin configurationAdmin) {
- super(TYPE, objectNameCreator, new ConfigInstallArtifactCommandFormatter(configurationAdmin), ManageableArtifact.class);
+ super(TYPE, objectNameCreator, new ConfigInstallArtifactCommandFormatter(configurationAdmin), ManageableArtifact.class, null);
}
@Command("examine")
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/ParCommands.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/ParCommands.java
index 04437e28..d1486669 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/ParCommands.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/ParCommands.java
@@ -22,6 +22,6 @@ final class ParCommands extends AbstractInstallArtifactBasedCommands<ManageableC
private static final String TYPE = "par";
public ParCommands(RuntimeArtifactModelObjectNameCreator objectNameCreator) {
- super(TYPE, objectNameCreator, new CompositeInstallArtifactCommandFormatter(), ManageableCompositeArtifact.class);
+ super(TYPE, objectNameCreator, new CompositeInstallArtifactCommandFormatter(), ManageableCompositeArtifact.class, null);
}
}
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/PlanCommands.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/PlanCommands.java
index 14999abd..0a9d18d5 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/PlanCommands.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/commands/PlanCommands.java
@@ -22,7 +22,7 @@ final class PlanCommands extends AbstractInstallArtifactBasedCommands<Manageable
private static final String TYPE = "plan";
public PlanCommands(RuntimeArtifactModelObjectNameCreator objectNameCreator) {
- super(TYPE, objectNameCreator, new CompositeInstallArtifactCommandFormatter(), ManageableCompositeArtifact.class);
+ super(TYPE, objectNameCreator, new CompositeInstallArtifactCommandFormatter(), ManageableCompositeArtifact.class, null);
}
}
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java
index 3903770f..9b2695b6 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/internal/util/ArtifactRetriever.java
@@ -22,6 +22,7 @@ import org.osgi.framework.Version;
import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
import org.eclipse.virgo.kernel.model.management.RuntimeArtifactModelObjectNameCreator;
+import org.eclipse.virgo.kernel.osgi.region.Region;
/**
* <p>
@@ -68,6 +69,17 @@ public final class ArtifactRetriever<T extends ManageableArtifact> {
public T getArtifact(String name, Version version) throws InstanceNotFoundException {
return getArtifact(this.objectNameCreator.create(this.type, name, version));
}
+
+ /**
+ * @param name
+ * @param version
+ * @param region
+ * @return
+ * @throws InstanceNotFoundException
+ */
+ public T getArtifact(String name, Version version, Region region) throws InstanceNotFoundException {
+ return getArtifact(this.objectNameCreator.create(this.type, name, version, region));
+ }
/**
*
diff --git a/org.eclipse.virgo.kernel.shell/src/main/resources/META-INF/spring/module-context.xml b/org.eclipse.virgo.kernel.shell/src/main/resources/META-INF/spring/module-context.xml
index 6835911e..0fb88cb1 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/resources/META-INF/spring/module-context.xml
+++ b/org.eclipse.virgo.kernel.shell/src/main/resources/META-INF/spring/module-context.xml
@@ -37,6 +37,7 @@
<constructor-arg ref="objectNameCreator"/>
<constructor-arg ref="stateService" />
<constructor-arg ref="moduleContextAccessor" />
+ <constructor-arg ref="regionDigraph" />
</bean>
<bean id="serviceCommands" class="org.eclipse.virgo.kernel.shell.internal.commands.ServiceCommands">
diff --git a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubAbstractCompositeInstallArtifactBasedCommands.java b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubAbstractCompositeInstallArtifactBasedCommands.java
index 27fa8298..9a1bfbb0 100644
--- a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubAbstractCompositeInstallArtifactBasedCommands.java
+++ b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/internal/commands/StubAbstractCompositeInstallArtifactBasedCommands.java
@@ -17,7 +17,7 @@ import org.eclipse.virgo.kernel.shell.internal.commands.AbstractInstallArtifactB
final class StubAbstractCompositeInstallArtifactBasedCommands extends AbstractInstallArtifactBasedCommands<ManageableCompositeArtifact> {
public StubAbstractCompositeInstallArtifactBasedCommands() {
- super("test", new StubRuntimeArtifactModelObjectNameCreator(), new StubInstallArtifactCommandFormatter(), ManageableCompositeArtifact.class);
+ super("test", new StubRuntimeArtifactModelObjectNameCreator(), new StubInstallArtifactCommandFormatter(), ManageableCompositeArtifact.class, null);
}
}

Back to the top