Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

Commit

Permalink
Make defaultServer idempotent.
Browse files Browse the repository at this point in the history
Otherwise, trying to use the messaging fraction results in duplicate
service exceptions, since defaultServer gets called twice, by
default. Default? Default!

This also gets rid of a configurable default, since that kinda defeats
the value of a default.
  • Loading branch information
tobias committed Nov 9, 2015
1 parent 891c420 commit 61f05e3
Showing 1 changed file with 6 additions and 9 deletions.
Expand Up @@ -15,10 +15,7 @@
*/
package org.wildfly.swarm.messaging;

import java.util.function.Consumer;

import org.wildfly.swarm.config.MessagingActiveMQ;
import org.wildfly.swarm.config.messaging_activemq.ServerConsumer;
import org.wildfly.swarm.container.Fraction;

/**
Expand All @@ -35,9 +32,11 @@ public static MessagingFraction createDefaultFraction() {
}

public MessagingFraction defaultServer() {
return defaultServer((s) -> {
s.enableInVm();
});
if (this.defaultServer == null) {
this.defaultServer = server("default", EnhancedServer::enableInVm);
}

return this.defaultServer;
}

public MessagingFraction server(String childKey, EnhancedServerConsumer consumer) {
Expand All @@ -48,7 +47,5 @@ public MessagingFraction server(String childKey, EnhancedServerConsumer consumer
});
}

public MessagingFraction defaultServer(EnhancedServerConsumer config) {
return server( "default", config );
}
private MessagingFraction defaultServer = null;
}

0 comments on commit 61f05e3

Please sign in to comment.