Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2012-06-19 16:12:47 +0000
committerThomas Watson2012-06-19 16:12:47 +0000
commit6a4cfc15d5e1c51d412b9f68d3743e62f523dd2d (patch)
tree123b63c6e3fc9d67016ebabaaee676ea45e5c993 /bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container
parent497e4cccb125a39a7ce688b244a347e074b1229d (diff)
downloadrt.equinox.framework-6a4cfc15d5e1c51d412b9f68d3743e62f523dd2d.tar.gz
rt.equinox.framework-6a4cfc15d5e1c51d412b9f68d3743e62f523dd2d.tar.xz
rt.equinox.framework-6a4cfc15d5e1c51d412b9f68d3743e62f523dd2d.zip
Allow for revision info objects to be specified.
Diffstat (limited to 'bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container')
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java10
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java10
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java17
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java13
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisionBuilder.java9
5 files changed, 43 insertions, 16 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java
index 6a79bf413..8960a3277 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainer.java
@@ -147,11 +147,12 @@ public final class ModuleContainer {
* @param origin the module performing the install, may be {@code null}.
* @param location The location identifier of the module to install.
* @param builder the builder used to create the revision to install.
+ * @param revisionInfo the revision info for the new revision, may be {@code null}.
* @return a new module or a existing module if one exists at the
* specified location.
* @throws BundleException if some error occurs installing the module
*/
- public Module install(Module origin, String location, ModuleRevisionBuilder builder) throws BundleException {
+ public Module install(Module origin, String location, ModuleRevisionBuilder builder, Object revisionInfo) throws BundleException {
String name = builder.getSymbolicName();
boolean locationLocked = false;
boolean nameLocked = false;
@@ -215,7 +216,7 @@ public final class ModuleContainer {
throw new BundleException("A bundle is already installed with name \"" + name + "\" and version \"" + builder.getVersion(), BundleException.DUPLICATE_BUNDLE_ERROR);
}
- Module result = moduleDatabase.install(location, builder);
+ Module result = moduleDatabase.install(location, builder, revisionInfo);
adaptor.publishEvent(ModuleEvent.INSTALLED, result);
@@ -235,9 +236,10 @@ public final class ModuleContainer {
* revision of the new module.
* @param module the module to update
* @param builder the builder used to create the revision for the update.
+ * @param revisionInfo the revision info for the new revision, may be {@code null}.
* @throws BundleException if some error occurs updating the module
*/
- public void update(Module module, ModuleRevisionBuilder builder) throws BundleException {
+ public void update(Module module, ModuleRevisionBuilder builder, Object revisionInfo) throws BundleException {
String name = builder.getSymbolicName();
boolean nameLocked = false;
try {
@@ -300,7 +302,7 @@ public final class ModuleContainer {
module.setState(State.INSTALLED);
adaptor.publishEvent(ModuleEvent.UNRESOLVED, module);
}
- moduleDatabase.update(module, builder);
+ moduleDatabase.update(module, builder, revisionInfo);
} catch (BundleException e) {
updateError = e;
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
index b0caae051..4b7be7899 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleContainerAdaptor.java
@@ -155,4 +155,14 @@ public abstract class ModuleContainerAdaptor {
* @return the system module
*/
public abstract SystemModule createSystemModule();
+
+ /**
+ * Returns the current revision info for a module with the specified location and id
+ * @param location the location of the module
+ * @param id the id of the module
+ * @return the revision info, may be {@code null}
+ */
+ public Object getRevisionInfo(String location, long id) {
+ return null;
+ }
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
index 76465a63a..c60da3d87 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleDatabase.java
@@ -234,14 +234,15 @@ public class ModuleDatabase {
* A write operation protected by the {@link #lockWrite() write} lock.
* @param location the location to use for the installation
* @param builder the builder to use to create the new revision
+ * @param revisionInfo the revision info for the new revision, may be {@code null}.
* @return the installed module
*/
- final Module install(String location, ModuleRevisionBuilder builder) {
+ final Module install(String location, ModuleRevisionBuilder builder, Object revisionInfo) {
lockWrite();
try {
int startlevel = Constants.SYSTEM_BUNDLE_LOCATION.equals(location) ? 0 : getInitialModuleStartLevel();
long id = Constants.SYSTEM_BUNDLE_LOCATION.equals(location) ? 0 : getNextIdAndIncrement();
- Module module = load(location, builder, id, null, startlevel);
+ Module module = load(location, builder, revisionInfo, id, null, startlevel);
module.setlastModified(System.currentTimeMillis());
incrementTimestamp();
return module;
@@ -250,7 +251,7 @@ public class ModuleDatabase {
}
}
- final Module load(String location, ModuleRevisionBuilder builder, long id, EnumSet<Settings> settings, int startlevel) {
+ final Module load(String location, ModuleRevisionBuilder builder, Object revisionInfo, long id, EnumSet<Settings> settings, int startlevel) {
// sanity check
checkWrite();
if (modulesByLocations.containsKey(location))
@@ -263,7 +264,7 @@ public class ModuleDatabase {
} else {
module = adaptor.createModule(location, id, settings, startlevel);
}
- builder.addRevision(module);
+ builder.addRevision(module, revisionInfo);
modulesByLocations.put(location, module);
modulesById.put(id, module);
if (settings != null)
@@ -340,12 +341,13 @@ public class ModuleDatabase {
* A write operation protected by the {@link #lockWrite() write} lock.
* @param module the module for which the revision provides an update for
* @param builder the builder to use to create the new revision
+ * @param revisionInfo the revision info for the new revision, may be {@code null}.
*/
- final void update(Module module, ModuleRevisionBuilder builder) {
+ final void update(Module module, ModuleRevisionBuilder builder, Object revisionInfo) {
lockWrite();
try {
ModuleRevision oldRevision = module.getCurrentRevision();
- ModuleRevision newRevision = builder.addRevision(module);
+ ModuleRevision newRevision = builder.addRevision(module, revisionInfo);
String name = newRevision.getSymbolicName();
Collection<ModuleRevision> sameName = revisionByName.get(name);
if (sameName == null) {
@@ -1072,7 +1074,8 @@ public class ModuleDatabase {
// startlevel
int startlevel = in.readInt();
- Module module = moduleDatabase.load(location, builder, id, settings, startlevel);
+ Object revisionInfo = moduleDatabase.adaptor.getRevisionInfo(location, id);
+ Module module = moduleDatabase.load(location, builder, revisionInfo, id, settings, startlevel);
// last modified
module.setlastModified(in.readLong());
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java
index 0fe3604e9..6426dec1b 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevision.java
@@ -32,14 +32,16 @@ public final class ModuleRevision implements BundleRevision {
private final List<ModuleCapability> capabilities;
private final List<ModuleRequirement> requirements;
private final ModuleRevisions revisions;
+ private final Object revisionInfo;
- ModuleRevision(String symbolicName, Version version, int types, List<GenericInfo> capabilityInfos, List<GenericInfo> requirementInfos, ModuleRevisions revisions) {
+ ModuleRevision(String symbolicName, Version version, int types, List<GenericInfo> capabilityInfos, List<GenericInfo> requirementInfos, ModuleRevisions revisions, Object revisionInfo) {
this.symbolicName = symbolicName;
this.version = version;
this.types = types;
this.capabilities = createCapabilities(capabilityInfos);
this.requirements = createRequirements(requirementInfos);
this.revisions = revisions;
+ this.revisionInfo = revisionInfo;
}
private List<ModuleCapability> createCapabilities(List<GenericInfo> capabilityInfos) {
@@ -151,6 +153,15 @@ public final class ModuleRevision implements BundleRevision {
return revisions;
}
+ /**
+ * Returns the revision info for this revision. The revision info is
+ * assigned when a revision is created to install a module or update module
+ * @return the revision info for this revision, may be {@code null}.
+ */
+ public Object getRevisionInfo() {
+ return revisionInfo;
+ }
+
boolean isCurrent() {
return !revisions.isUninstalled() && this.equals(revisions.getCurrentRevision());
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisionBuilder.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisionBuilder.java
index 587772046..0bde402b5 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisionBuilder.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleRevisionBuilder.java
@@ -16,8 +16,8 @@ import org.osgi.framework.Version;
/**
* A builder for creating module {@link ModuleRevision} objects. A builder can only be used by
* the module {@link ModuleContainer container} to build revisions when
- * {@link ModuleContainer#install(Module, String, ModuleRevisionBuilder)
- * installing} or {@link ModuleContainer#update(Module, ModuleRevisionBuilder) updating} a module.
+ * {@link ModuleContainer#install(Module, String, ModuleRevisionBuilder, Object)
+ * installing} or {@link ModuleContainer#update(Module, ModuleRevisionBuilder, Object) updating} a module.
* <p>
* The builder provides the instructions to the container for creating a {@link ModuleRevision}.
* @since 3.10
@@ -124,11 +124,12 @@ public final class ModuleRevisionBuilder {
* This builder is used to build a new {@link Module#getCurrentRevision() current}
* revision for the specified module.
* @param module the module to build a new revision for
+ * @param revisionInfo the revision info for the new revision, may be {@code null}
* @return the new new {@link Module#getCurrentRevision() current} revision.
*/
- ModuleRevision addRevision(Module module) {
+ ModuleRevision addRevision(Module module, Object revisionInfo) {
ModuleRevisions revisions = module.getRevisions();
- ModuleRevision revision = new ModuleRevision(symbolicName, version, types, capabilityInfos, requirementInfos, revisions);
+ ModuleRevision revision = new ModuleRevision(symbolicName, version, types, capabilityInfos, requirementInfos, revisions, revisionInfo);
revisions.addRevision(revision);
return revision;
}

Back to the top