Mixing the configurations
Now, what about mixing configurations? Are you allowed to do this? Yup. Let's look at the following code:
package org.packt.swarm.petstore.catalog; import org.jboss.shrinkwrap.api.Archive; import org.wildfly.swarm.Swarm; import org.wildfly.swarm.datasources.DatasourcesFraction; import org.wildfly.swarm.undertow.UndertowFraction; public class Main { public static void main(String[] args) throws Exception { Swarm swarm = new Swarm(); //1 ClassLoader cl = Main.class.getClassLoader(); URL xmlConfig = cl.getResource("standalone.xml"); swarm.withXMLFile(xmlFile); //2 UndertowFraction undertowFraction = new UndertowFraction(); undertowFraction.applyDefaults(); undertowFraction.httpPort(12345); swarm.fraction(undertowFraction); //3 Archive<?> deployment = swarm.createDefaultDeployment(); deployment.addModule("com.h2database.h2"); //4 swarm.start().deploy(); } }
It is another variation of our database example, and you already know what is happening...