/**
 * Copyright 2015 Red Hat, Inc, and individual contributors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
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;

/**
 * @author Bob McWhirter
 * @author Lance Ball
 */
public class MessagingFraction extends MessagingActiveMQ<MessagingFraction> implements Fraction {

    private MessagingFraction() {
    }

    public static MessagingFraction createDefaultFraction() {
        return new MessagingFraction().defaultServer();
    }

    public MessagingFraction defaultServer() {
        return defaultServer((s) -> {
            s.enableInVm();
        });
    }

    public MessagingFraction server(String childKey, EnhancedServerConsumer consumer) {
        return super.server( ()->{
            EnhancedServer s = new EnhancedServer(childKey);
            consumer.accept(s);
            return s;
        });
    }

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

@@ -658,45 +658,8 @@
 g;%0A%0A
-import java.util.function.Consumer;%0A%0A
 impo
@@ -709,75 +709,8 @@
 MQ;%0A
-import org.wildfly.swarm.config.messaging_activemq.ServerConsumer;%0A
 impo
@@ -1126,23 +1126,25 @@
         
-return 
+if (this.
 defaultS
@@ -1152,15 +1152,17 @@
 rver
-((s) -%3E
+ == null)
  %7B%0A 
@@ -1172,18 +1172,71 @@
         
-s.
+this.defaultServer = server(%22default%22, EnhancedServer::
 enableIn
@@ -1237,17 +1237,16 @@
 ableInVm
-(
 );%0A     
@@ -1241,33 +1241,67 @@
 InVm);%0A        %7D
-)
+%0A%0A        return this.defaultServer
 ;%0A    %7D%0A%0A    pub
@@ -1547,37 +1547,38 @@
 %7D);%0A    %7D%0A%0A    p
-ublic
+rivate
  MessagingFracti
@@ -1597,90 +1597,15 @@
 rver
-(EnhancedServerConsumer config) %7B%0A        return server( %22default%22, config );%0A    %7D
+ = null;
 %0A%7D%0A

Make defaultServer idempotent.