killbill-memoizeit

Details

diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithFakeKPMPlugin.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithFakeKPMPlugin.java
index 4d9c7d8..4a351ac 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithFakeKPMPlugin.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithFakeKPMPlugin.java
@@ -121,7 +121,7 @@ public class TestWithFakeKPMPlugin extends TestIntegrationBase {
                     final PluginNodeCommandMetadata nodeCommandMetadata = (PluginNodeCommandMetadata) nodeInfoMapper.deserializeNodeCommand(broadcastMetadata.getEventJson(), broadcastMetadata.getCommandType());
                     ((FakePluginFinder) pluginFinder).addPlugin(createPluginConfig(nodeCommandMetadata));
 
-                    pluginsInfoApi.notifyOfStateChanged(PluginStateChange.NEW_VERSION, nodeCommandMetadata.getPluginName(), nodeCommandMetadata.getPluginVersion(), PluginLanguage.JAVA);
+                    pluginsInfoApi.notifyOfStateChanged(PluginStateChange.NEW_VERSION, nodeCommandMetadata.getPluginKey(), nodeCommandMetadata.getPluginName(), nodeCommandMetadata.getPluginVersion(), PluginLanguage.JAVA);
 
                 } catch (IOException e) {
                     throw new RuntimeException(e);
@@ -138,6 +138,11 @@ public class TestWithFakeKPMPlugin extends TestIntegrationBase {
             }
 
             @Override
+            public String getPluginKey() {
+                return nodeCommandMetadata.getPluginKey();
+            }
+
+            @Override
             public String getPluginName() {
                 return nodeCommandMetadata.getPluginName();
             }
@@ -234,6 +239,11 @@ public class TestWithFakeKPMPlugin extends TestIntegrationBase {
                 }
 
                 @Override
+                public String getPluginKey() {
+                    return null;
+                }
+
+                @Override
                 public String getPluginName() {
                     return pluginName;
                 }
@@ -344,7 +354,7 @@ public class TestWithFakeKPMPlugin extends TestIntegrationBase {
 
             @Override
             public NodeCommandMetadata getNodeCommandMetadata() {
-                return new PluginNodeCommandMetadata(NEW_PLUGIN_NAME, NEW_PLUGIN_VERSION, ImmutableList.<NodeCommandProperty>of());
+                return new PluginNodeCommandMetadata(NEW_PLUGIN_NAME, NEW_PLUGIN_NAME, NEW_PLUGIN_VERSION, ImmutableList.<NodeCommandProperty>of());
             }
         };
         busHandler.pushExpectedEvent(NextEvent.BROADCAST_SERVICE);
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PluginInfoJson.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PluginInfoJson.java
index e1bdd1e..13e4bbc 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PluginInfoJson.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/json/PluginInfoJson.java
@@ -32,6 +32,8 @@ public class PluginInfoJson {
 
     private final String bundleSymbolicName;
 
+    private final String pluginKey;
+
     private final String pluginName;
 
     private final String version;
@@ -44,12 +46,14 @@ public class PluginInfoJson {
 
     @JsonCreator
     public PluginInfoJson(@JsonProperty("bundleSymbolicName") final String bundleSymbolicName,
+                          @JsonProperty("pluginKey") final String pluginKey,
                           @JsonProperty("pluginName") final String pluginName,
                           @JsonProperty("version") final String version,
                           @JsonProperty("state") final String state,
                           @JsonProperty("isSelectedForStart") final Boolean isSelectedForStart,
                           @JsonProperty("services") final Set<PluginServiceInfoJson> services) {
         this.bundleSymbolicName = bundleSymbolicName;
+        this.pluginKey = pluginKey;
         this.pluginName = pluginName;
         this.version = version;
         this.state = state;
@@ -59,6 +63,7 @@ public class PluginInfoJson {
 
     public PluginInfoJson(final PluginInfo input) {
         this(input.getBundleSymbolicName(),
+             input.getPluginKey(),
              input.getPluginName(),
              input.getVersion(),
              input.getPluginState().name(),
@@ -79,6 +84,10 @@ public class PluginInfoJson {
         return pluginName;
     }
 
+    public String getPluginKey() {
+        return pluginKey;
+    }
+
     public String getVersion() {
         return version;
     }
diff --git a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/NodesInfoResource.java b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/NodesInfoResource.java
index 5d92b8d..a699485 100644
--- a/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/NodesInfoResource.java
+++ b/jaxrs/src/main/java/org/killbill/billing/jaxrs/resources/NodesInfoResource.java
@@ -117,6 +117,7 @@ public class NodesInfoResource extends JaxRsResourceBase {
                             }
                         }));
                         return new PluginInfoJson(input.getBundleSymbolicName(),
+                                                  input.getPluginKey(),
                                                   input.getPluginName(),
                                                   input.getVersion(),
                                                   input.getPluginState().name(),
@@ -187,6 +188,7 @@ public class NodesInfoResource extends JaxRsResourceBase {
             };
         }
 
+        String pluginKey = null;
         String pluginName = null;
         String pluginVersion = null;
         final Iterator<NodeCommandPropertyJson> it = input.getNodeCommandProperties().iterator();
@@ -196,16 +198,17 @@ public class NodesInfoResource extends JaxRsResourceBase {
                 pluginName = (String) cur.getValue();
             } else if (PluginNodeCommandMetadata.PLUGIN_VERSION.equals(cur.getKey())) {
                 pluginVersion = (String) cur.getValue();
+            } else if (PluginNodeCommandMetadata.PLUGIN_KEY.equals(cur.getKey())) {
+                pluginKey = (String) cur.getValue();
             }
-            if (pluginName != null && pluginVersion != null) {
+            if (pluginName != null && pluginVersion != null && pluginKey != null) {
                 break;
             }
         }
 
-        if (pluginName != null) {
-            input.getNodeCommandProperties().remove(PluginNodeCommandMetadata.PLUGIN_NAME);
-            input.getNodeCommandProperties().remove(PluginNodeCommandMetadata.PLUGIN_VERSION);
-            return new PluginNodeCommandMetadata(pluginName, pluginVersion, toNodeCommandProperties(input.getNodeCommandProperties()));
+        if (pluginName != null || pluginKey != null) {
+            removeFirstClassProperties(input.getNodeCommandProperties(), PluginNodeCommandMetadata.PLUGIN_NAME, PluginNodeCommandMetadata.PLUGIN_VERSION, PluginNodeCommandMetadata.PLUGIN_KEY);
+            return new PluginNodeCommandMetadata(pluginKey, pluginName, pluginVersion, toNodeCommandProperties(input.getNodeCommandProperties()));
         } else {
             return new NodeCommandMetadata() {
                 @Override
@@ -216,6 +219,18 @@ public class NodesInfoResource extends JaxRsResourceBase {
         }
     }
 
+    private void removeFirstClassProperties(final List<NodeCommandPropertyJson> properties, final String... toBeRemoved) {
+        final Iterator<NodeCommandPropertyJson> it = properties.iterator();
+        while (it.hasNext()) {
+            final NodeCommandPropertyJson cur = it.next();
+            for (String p : toBeRemoved) {
+                if (cur.getKey().equals(p)) {
+                    it.remove();
+                    break;
+                }
+            }
+        }
+    }
     private List<NodeCommandProperty> toNodeCommandProperties(final List<NodeCommandPropertyJson> input) {
         return ImmutableList.copyOf(Iterables.transform(input, new Function<NodeCommandPropertyJson, NodeCommandProperty>() {
             @Override

pom.xml 2(+1 -1)

diff --git a/pom.xml b/pom.xml
index 71ef422..f211d9a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
     <parent>
         <artifactId>killbill-oss-parent</artifactId>
         <groupId>org.kill-bill.billing</groupId>
-        <version>0.74</version>
+        <version>0.76</version>
     </parent>
     <artifactId>killbill</artifactId>
     <version>0.15.11-SNAPSHOT</version>
diff --git a/util/src/main/java/org/killbill/billing/util/nodes/DefaultNodeInfo.java b/util/src/main/java/org/killbill/billing/util/nodes/DefaultNodeInfo.java
index 941a9b6..84232bd 100644
--- a/util/src/main/java/org/killbill/billing/util/nodes/DefaultNodeInfo.java
+++ b/util/src/main/java/org/killbill/billing/util/nodes/DefaultNodeInfo.java
@@ -94,7 +94,7 @@ public class DefaultNodeInfo implements NodeInfo {
         return Iterables.transform(plugins, new Function<PluginInfoModelJson, PluginInfo>() {
             @Override
             public PluginInfo apply(final PluginInfoModelJson input) {
-                return new DefaultPluginInfo(input.getBundleSymbolicName(), input.getPluginName(), input.getVersion(), input.getState(), input.isSelectedForStart(), toPluginServiceInfo(input.getServices()));
+                return new DefaultPluginInfo(input.getPluginKey(), input.getBundleSymbolicName(), input.getPluginName(), input.getVersion(), input.getState(), input.isSelectedForStart(), toPluginServiceInfo(input.getServices()));
             }
         });
     }
diff --git a/util/src/main/java/org/killbill/billing/util/nodes/json/PluginInfoModelJson.java b/util/src/main/java/org/killbill/billing/util/nodes/json/PluginInfoModelJson.java
index 487c83e..49e7372 100644
--- a/util/src/main/java/org/killbill/billing/util/nodes/json/PluginInfoModelJson.java
+++ b/util/src/main/java/org/killbill/billing/util/nodes/json/PluginInfoModelJson.java
@@ -33,6 +33,8 @@ public class PluginInfoModelJson {
 
     private final String bundleSymbolicName;
 
+    private final String pluginKey;
+
     private final String pluginName;
 
     private final String version;
@@ -45,12 +47,14 @@ public class PluginInfoModelJson {
 
     @JsonCreator
     public PluginInfoModelJson(@JsonProperty("bundleSymbolicName") final String bundleSymbolicName,
+                               @JsonProperty("pluginKey") final String pluginKey,
                                @JsonProperty("pluginName") final String pluginName,
                                @JsonProperty("version") final String version,
                                @JsonProperty("state") final PluginState state,
                                @JsonProperty("isSelectedForStart") final Boolean isSelectedForStart,
                                @JsonProperty("services") final Set<PluginServiceInfoModelJson> services) {
         this.bundleSymbolicName = bundleSymbolicName;
+        this.pluginKey = pluginKey;
         this.pluginName = pluginName;
         this.version = version;
         this.state = state;
@@ -60,6 +64,7 @@ public class PluginInfoModelJson {
 
     public PluginInfoModelJson(final PluginInfo input) {
         this(input.getBundleSymbolicName(),
+             input.getPluginKey(),
              input.getPluginName(),
              input.getVersion(),
              input.getPluginState(),
@@ -88,6 +93,10 @@ public class PluginInfoModelJson {
         return state;
     }
 
+    public String getPluginKey() {
+        return pluginKey;
+    }
+
     @JsonProperty("isSelectedForStart")
     public boolean isSelectedForStart() {
         return isSelectedForStart;
@@ -117,6 +126,9 @@ public class PluginInfoModelJson {
         if (isSelectedForStart != that.isSelectedForStart) {
             return false;
         }
+        if (pluginKey != null ? !pluginKey.equals(that.pluginKey) : that.pluginKey != null) {
+            return false;
+        }
         if (pluginName != null ? !pluginName.equals(that.pluginName) : that.pluginName != null) {
             return false;
         }
@@ -130,6 +142,7 @@ public class PluginInfoModelJson {
     @Override
     public int hashCode() {
         int result = bundleSymbolicName != null ? bundleSymbolicName.hashCode() : 0;
+        result = 31 * result + (pluginKey != null ? pluginKey.hashCode() : 0);
         result = 31 * result + (pluginName != null ? pluginName.hashCode() : 0);
         result = 31 * result + (version != null ? version.hashCode() : 0);
         result = 31 * result + (state != null ? state.hashCode() : 0);
diff --git a/util/src/test/java/org/killbill/billing/util/nodes/TestNodeInfoMapper.java b/util/src/test/java/org/killbill/billing/util/nodes/TestNodeInfoMapper.java
index 8d4ab12..91bdfbf 100644
--- a/util/src/test/java/org/killbill/billing/util/nodes/TestNodeInfoMapper.java
+++ b/util/src/test/java/org/killbill/billing/util/nodes/TestNodeInfoMapper.java
@@ -48,7 +48,7 @@ public class TestNodeInfoMapper extends UtilTestSuiteNoDB {
         services1.add(svc);
 
         final List<PluginInfoModelJson> pluginInfos = new ArrayList<PluginInfoModelJson>();
-        final PluginInfoModelJson info1 = new PluginInfoModelJson("sym1", "name1", "vers1", PluginState.STOPPED, true, services1);
+        final PluginInfoModelJson info1 = new PluginInfoModelJson("sym1", "key1", "name1", "vers1", PluginState.STOPPED, true, services1);
         pluginInfos.add(info1);
         final NodeInfoModelJson input = new NodeInfoModelJson("nodeName", clock.getUTCNow(), clock.getUTCNow(), "1.0", "1.0", "1.0", "1.0", "1.0", pluginInfos);
 
@@ -63,7 +63,7 @@ public class TestNodeInfoMapper extends UtilTestSuiteNoDB {
     public void testNodeSystemCommandSerialization() throws Exception {
 
         final NodeCommandProperty prop = new NodeCommandProperty("something", "nothing");
-        final PluginNodeCommandMetadata nodeCommandMetadata = new PluginNodeCommandMetadata("foo", "1.2.3", ImmutableList.<NodeCommandProperty>of(prop));
+        final PluginNodeCommandMetadata nodeCommandMetadata = new PluginNodeCommandMetadata("foo", "key1", "1.2.3", ImmutableList.<NodeCommandProperty>of(prop));
 
         final String nodeCmdStr = nodeInfoMapper.serializeNodeCommand(nodeCommandMetadata);