Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2011-03-29 12:04:08 -0400
committerGlyn Normington2011-03-29 12:04:08 -0400
commit0d25116ac552e19442cfc0bdc89951788c5fbc00 (patch)
tree7596028649f9d6b8fd6bdaef78fb4686b3a9bfce /org.eclipse.virgo.kernel.shell
parent5fc7144956b3c515c6556032ed63aa6e2dc675bc (diff)
downloadorg.eclipse.virgo.kernel-0d25116ac552e19442cfc0bdc89951788c5fbc00.tar.gz
org.eclipse.virgo.kernel-0d25116ac552e19442cfc0bdc89951788c5fbc00.tar.xz
org.eclipse.virgo.kernel-0d25116ac552e19442cfc0bdc89951788c5fbc00.zip
bug 336941: state dumping and analysis with region digraph
Diffstat (limited to 'org.eclipse.virgo.kernel.shell')
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/StateService.java75
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java44
-rw-r--r--org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubQuasiFrameworkFactory.java10
-rw-r--r--org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubStateService.java32
4 files changed, 86 insertions, 75 deletions
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/StateService.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/StateService.java
index 64d21ae2..87bf8e60 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/StateService.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/StateService.java
@@ -15,95 +15,84 @@ import java.io.File;
import java.util.List;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiBundle;
-import org.eclipse.virgo.kernel.osgi.quasi.QuasiFramework;
import org.eclipse.virgo.kernel.osgi.quasi.QuasiResolutionFailure;
/**
* <p>
- * <code>StateService</code>
+ * <code>StateService</code>
* </p>
*
* <strong>Concurrent Semantics</strong><br />
*
- * Implementations should be thread-safe.
+ * Implementations must be thread-safe.
*
*/
public interface StateService {
- /**
- * Obtains {@link QuasiBundle} representations of all the bundles present
- * in the underlying state.
- *
- * @param source can be null to request the live state
- * @return all the bundles or the empty list if the source can't be found
- */
+ /**
+ * Obtains {@link QuasiBundle} representations of all the bundles present in the live state or the given dump
+ * directory.
+ *
+ * @param source can be <code>null</code> to request the live state
+ * @return all the bundles or the empty list if the source can't be found
+ */
public List<QuasiBundle> getAllBundles(File source);
/**
- * Obtains {@link QuasiLiveService} representations of all the services present
- * in the underlying osgi instance.
+ * Obtains {@link QuasiLiveService} representations of all the services present in the live state or the given dump
+ * directory.
*
- * @param source can be null to request the live state
+ * @param source can be <code>null</code> to request the live state
* @return all the services or the empty list if the source can't be found
*/
public List<QuasiLiveService> getAllServices(File source);
/**
- * Looks at all the bundles in the underlying state and return the one with
- * the given id, if no such bundle exists then null is returned.
+ * Looks at all the bundles in the live state or the given dump directory and return the one with the given id, if
+ * no such bundle exists then <code>null</code> is returned.
*
- * @param source can be null to request the live state
+ * @param source can be <code>null</code> to request the live state
* @param bundleId of required bundle
- * @return the requested bundle or null
+ * @return the requested bundle or <code>null</code>
*/
public QuasiBundle getBundle(File source, long bundleId);
-
+
/**
- * Returns the {@link QuasiLiveService} that represents the service with
- * the requested service Id. If no such service exists then null is
- * returned.
+ * Returns the {@link QuasiLiveService} that represents the service with the requested service Id in the live state
+ * or the given dump directory. If no such service exists then <code>null</code> is returned.
*
- * @param source can be null to request the live state
+ * @param source can be <code>null</code> to request the live state
* @param serviceId
* @return the service with id serviceId
*/
- public QuasiLiveService getService(File source, long serviceId) ;
-
+ public QuasiLiveService getService(File source, long serviceId);
+
/**
- * Will return {@link QuasiResolutionFailure} for the requested bundle.
- * If there are no resolution failures then null will be returned.
+ * Returns {@link QuasiResolutionFailure} for the requested bundle in the live state or the given dump
+ * directory. If there are no resolution failures then <code>null</code> will be returned.
*
- * @param source can be null to request the live state
+ * @param source can be <code>null</code> to request the live state
* @param bundleId of the fail bundle
* @return <code>QuasiResolutionFailure</code>
*/
public List<QuasiResolutionFailure> getResolverReport(File source, long bundleId);
-
- /**
- * Installs a bundle into the requested {@link QuasiFramework} using the given
- * {@link String} location and returns a {@link QuasiBundle}.
- *
- * @param source can be null to request the live state
- * @param location
- * @return the bundle installed
- */
- public QuasiBundle installBundle(File source, String location);
-
+
/**
+ * Returns the {@link QuasiPackage QuasiPackages} with the given name in the live state or the given dump directory.
*
- * @param source can be null to request the live state
+ * @param source can be <code>null</code> to request the live state
* @param packageName to find
* @return the package found
*/
public QuasiPackage getPackages(File source, String packageName);
-
+
/**
- * Search the requested state for bundles matching the given string
+ * Searches the live state or the given dump directory for bundles matching the given string.
*
- * @param source can be null to request the live state
+ * @param source can be <code>null</code> to request the live state
* @param term to search for
* @return a list of matched bundles
*/
public List<QuasiBundle> search(File source, String term);
-
+
}
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java
index 0fc2da6d..1d4d5cef 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardStateService.java
@@ -29,15 +29,17 @@ import org.eclipse.virgo.kernel.osgi.region.RegionDigraph;
import org.eclipse.virgo.kernel.shell.state.QuasiLiveService;
import org.eclipse.virgo.kernel.shell.state.QuasiPackage;
import org.eclipse.virgo.kernel.shell.state.StateService;
-import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.springframework.util.AntPathMatcher;
/**
- *
+ * {@link StandardStateService} is the default implementation of {@link StateService}.
+ * <p />
+ *
+ * <strong>Concurrent Semantics</strong><br />
+ * Thread safe.
*/
final public class StandardStateService implements StateService {
@@ -65,6 +67,7 @@ final public class StandardStateService implements StateService {
/**
* {@inheritDoc}
*/
+ @Override
public List<QuasiBundle> getAllBundles(File source) {
List<QuasiBundle> bundles = this.getQuasiFramework(source).getBundles();
if (source == null) {
@@ -88,6 +91,7 @@ final public class StandardStateService implements StateService {
/**
* {@inheritDoc}
*/
+ @Override
public QuasiBundle getBundle(File source, long bundleId) {
return this.getQuasiFramework(source).getBundle(bundleId);
}
@@ -95,6 +99,7 @@ final public class StandardStateService implements StateService {
/**
* {@inheritDoc}
*/
+ @Override
public List<QuasiLiveService> getAllServices(File source) {
List<QuasiLiveService> quasiLiveServices = new ArrayList<QuasiLiveService>();
if (source == null) {
@@ -131,6 +136,7 @@ final public class StandardStateService implements StateService {
/**
* {@inheritDoc}
*/
+ @Override
public QuasiLiveService getService(File source, long serviceId) {
if (source == null) {
SortedMap<Long, QuasiLiveService> services = getServicesSortedMap(this.getQuasiFramework(source));
@@ -142,6 +148,7 @@ final public class StandardStateService implements StateService {
/**
* {@inheritDoc}
*/
+ @Override
public List<QuasiResolutionFailure> getResolverReport(File source, long bundleId) {
QuasiFramework framework = this.getQuasiFramework(source);
return framework.diagnose(bundleId);
@@ -150,29 +157,7 @@ final public class StandardStateService implements StateService {
/**
* {@inheritDoc}
*/
- public QuasiBundle installBundle(File source, String location) {
- if (source != null) {
- throw new IllegalStateException("Unable to install a bundle in to a non-live state.");
- }
- Bundle installBundle = null;
- try {
- installBundle = this.bundleContext.installBundle(location);
- } catch (BundleException e) {
- throw new IllegalStateException(String.format("Unable to install the bundle '%s'.", e.getMessage()), e);
- }
- if (installBundle == null) {
- return null;
- }
- QuasiFramework framework = this.getQuasiFramework(null);
- if (framework == null) {
- return null;
- }
- return framework.getBundle(installBundle.getBundleId());
- }
-
- /**
- * {@inheritDoc}
- */
+ @Override
public QuasiPackage getPackages(File source, String packageName) {
QuasiFramework framework = this.getQuasiFramework(source);
if (packageName != null) {
@@ -197,6 +182,7 @@ final public class StandardStateService implements StateService {
/**
* {@inheritDoc}
*/
+ @Override
public List<QuasiBundle> search(File source, String term) {
QuasiFramework framework = this.getQuasiFramework(source);
List<QuasiBundle> matchingBundles = new ArrayList<QuasiBundle>();
@@ -218,7 +204,11 @@ final public class StandardStateService implements StateService {
if (source == null) {
return new StandardQuasiLiveFramework(this.quasiFrameworkFactory.create(), this.bundleContext);
} else {
- return this.quasiFrameworkFactory.create(source);
+ try {
+ return this.quasiFrameworkFactory.create(source);
+ } catch (Exception e) {
+ throw new RuntimeException("Error creating quasi-framework", e);
+ }
}
}
diff --git a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubQuasiFrameworkFactory.java b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubQuasiFrameworkFactory.java
index ef3c6b3a..4eab1d96 100644
--- a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubQuasiFrameworkFactory.java
+++ b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubQuasiFrameworkFactory.java
@@ -20,12 +20,20 @@ import org.eclipse.virgo.kernel.osgi.quasi.QuasiFrameworkFactory;
*/
public class StubQuasiFrameworkFactory implements QuasiFrameworkFactory {
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public QuasiFramework create() {
return new StubQuasiFramework();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public QuasiFramework create(File arg0) {
return new StubQuasiFramework();
}
-
+
}
diff --git a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubStateService.java b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubStateService.java
index 458f44be..5c32c4cc 100644
--- a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubStateService.java
+++ b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/stubs/StubStateService.java
@@ -30,14 +30,26 @@ public class StubStateService implements StateService {
private StubQuasiLiveBundle stubQuasiBundle = new StubQuasiLiveBundle(STUB_STATE_BUNDLE_ID, new StubBundle());
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public List<QuasiBundle> getAllBundles(File source) {
return new ArrayList<QuasiBundle>();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public List<QuasiLiveService> getAllServices(File source) {
return new ArrayList<QuasiLiveService>();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public QuasiBundle getBundle(File source, long bundleId) {
if (bundleId == stubQuasiBundle.getBundleId()) {
return this.stubQuasiBundle;
@@ -46,22 +58,34 @@ public class StubStateService implements StateService {
}
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public List<QuasiResolutionFailure> getResolverReport(File source, long bundleId) {
return new ArrayList<QuasiResolutionFailure>();
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public QuasiLiveService getService(File source, long serviceId) {
return new StubQuasiLiveService(STUB_STATE_SERVICE_ID, this.stubQuasiBundle);
}
- public QuasiBundle installBundle(File source, String location) {
- return this.stubQuasiBundle;
- }
-
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public QuasiPackage getPackages(File source, String packageName) {
return new StubQuasiPackage(packageName);
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
public List<QuasiBundle> search(File source, String term) {
ArrayList<QuasiBundle> arrayList = new ArrayList<QuasiBundle>();
if (term.contains("*")) {

Back to the top