package org.wildfly.swarm.examples.messaging;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.wildfly.swarm.container.Container;
import org.wildfly.swarm.container.JARArchive;
import org.wildfly.swarm.jaxrs.JAXRSArchive;
import org.wildfly.swarm.messaging.MessagingFraction;
import org.wildfly.swarm.messaging.MessagingServer;
import org.wildfly.swarm.msc.ServiceActivatorArchive;

/**
 * @author Bob McWhirter
 */
public class Main {

    public static void main(String[] args) throws Exception {
        Container container = new Container();

        container.subsystem(new MessagingFraction()
                        .server(
                                new MessagingServer()
                                        .enableInVMConnector()
                                        .topic("my-topic")
                                        .queue("my-queue")
                        )
        );

        // Start the container
        container.start();

        JAXRSArchive appDeployment = ShrinkWrap.create(JAXRSArchive.class);
        appDeployment.addResource(MyResource.class);

        // Deploy your app
        container.deploy(appDeployment);

        JARArchive deployment = ShrinkWrap.create( JARArchive.class );
        deployment.addClass(MyService.class);
        deployment.as(ServiceActivatorArchive.class).addServiceActivator(MyServiceActivator.class);

        // Deploy the services
        container.deploy(deployment);

    }
}

@@ -84,16 +84,136 @@
 nkWrap;%0A
+import org.wildfly.swarm.config.messaging_activemq.Server;%0Aimport org.wildfly.swarm.config.messaging_activemq.server.*;%0A
 import o
@@ -246,24 +246,24 @@
 .Container;%0A
-
 import org.w
@@ -503,16 +503,42 @@
 chive;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * @
@@ -705,155 +705,676 @@
     
-container.subsystem(new MessagingFraction()%0A                        .server(%0A                                new MessagingServer()%0A                
+final String serverName = %22default%22;%0A%0A        final ConnectionFactory connectionFactory = new ConnectionFactory(%22InVmConnectionFactory%22)%0A                .connectors(Arrays.asList(%22in-vm%22))%0A                .entries(Arrays.asList(%22java:/ConnectionFactory%22));%0A%0A        final PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(%22activemq-ra%22)%0A                .entries(Arrays.asList(%22java:jboss/DefaultJMSConnectionFactory%22))%0A                .connectors(Arrays.asList(%22in-vm%22))%0A                .transaction(%22xa%22);%0A%0A        final MessagingFraction fraction = MessagingFraction.createDefaultFraction()%0A                .server(new Server(serverName)%0A
     
@@ -1398,18 +1398,30 @@
    .
-enableInVM
+inVmConnector(new InVm
 Conn
@@ -1426,16 +1426,36 @@
 nnector(
+%22in-vm%22).serverId(1)
 )%0A      
@@ -1476,136 +1476,459 @@
     
-                .topic(%22my-topic%22)%0A                                        .queue(%22my-queue%22)%0A                        )%0A        
+.inVmAcceptor(new InVmAcceptor(%22in-vm%22).serverId(1))%0A                        .connectionFactory(connectionFactory)%0A                        .pooledConnectionFactory(pooledConnectionFactory)%0A                        .jmsTopic(new JmsTopic(%22my-topic%22).entries(Arrays.asList(%22java:/jms/topic/my-topic%22)))%0A                        .jmsQueue(new JmsQueue(%22my-queue%22).entries(Arrays.asList(%22java:/jms/queue/my-queue%22))));%0A%0A%0A        container.subsystem(fraction
 );%0A%0A

Update messaging example to use the new config api bits.