aboutsummaryrefslogtreecommitdiffstats
path: root/jdisc_core/src/main
diff options
context:
space:
mode:
authorArnstein Ressem <aressem@gmail.com>2023-01-09 08:25:27 +0100
committerGitHub <noreply@github.com>2023-01-09 08:25:27 +0100
commit170af02d92a5f5e5442c45d6041cd367e46be3ad (patch)
tree62b7e1e947697ddc92e410a0ed1b951e67302f3d /jdisc_core/src/main
parente704b1b4ae95eabfa30f7fc4ea0f44ac4e7ee177 (diff)
Revert "More user friendly class resolution"
Diffstat (limited to 'jdisc_core/src/main')
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/application/BsnVersion.java21
-rw-r--r--jdisc_core/src/main/java/com/yahoo/jdisc/core/BundleCollisionHook.java31
2 files changed, 30 insertions, 22 deletions
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/application/BsnVersion.java b/jdisc_core/src/main/java/com/yahoo/jdisc/application/BsnVersion.java
deleted file mode 100644
index 40573eee3b2..00000000000
--- a/jdisc_core/src/main/java/com/yahoo/jdisc/application/BsnVersion.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.yahoo.jdisc.application;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.Version;
-
-/**
- * A bundle's symbolic name and version.
- *
- * @author gjoranv
- */
-public record BsnVersion(String symbolicName, Version version) {
-
- public BsnVersion(Bundle bundle) {
- this(bundle.getSymbolicName(), bundle.getVersion());
- }
-
- public String toReadableString() {
- return symbolicName + " version:" + version;
- }
-
-}
diff --git a/jdisc_core/src/main/java/com/yahoo/jdisc/core/BundleCollisionHook.java b/jdisc_core/src/main/java/com/yahoo/jdisc/core/BundleCollisionHook.java
index 203c2e975e4..3212bb4e6de 100644
--- a/jdisc_core/src/main/java/com/yahoo/jdisc/core/BundleCollisionHook.java
+++ b/jdisc_core/src/main/java/com/yahoo/jdisc/core/BundleCollisionHook.java
@@ -1,11 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.core;
-import com.yahoo.jdisc.application.BsnVersion;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleEvent;
import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.Version;
import org.osgi.framework.hooks.bundle.CollisionHook;
import org.osgi.framework.hooks.bundle.EventHook;
import org.osgi.framework.hooks.bundle.FindHook;
@@ -15,8 +15,10 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.logging.Logger;
+import java.util.stream.Collectors;
/**
* A bundle {@link CollisionHook} that contains a set of bundles that are allowed to collide with bundles
@@ -127,4 +129,31 @@ public class BundleCollisionHook implements CollisionHook, EventHook, FindHook {
}
}
+
+ static class BsnVersion {
+
+ private final String symbolicName;
+ private final Version version;
+
+ BsnVersion(Bundle bundle) {
+ this.symbolicName = bundle.getSymbolicName();
+ this.version = bundle.getVersion();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ BsnVersion that = (BsnVersion) o;
+ return Objects.equals(symbolicName, that.symbolicName) &&
+ version.equals(that.version);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(symbolicName, version);
+ }
+
+ }
+
}