package org.wildfly.swarm.examples.config.projectStage;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.wildfly.swarm.config.datasources.DataSource;
import org.wildfly.swarm.container.Container;
import org.wildfly.swarm.datasources.DatasourcesFraction;
import org.wildfly.swarm.jaxrs.JAXRSArchive;

import java.net.URL;

/**
 * @author Heiko Braun
 * @since 10/11/15
 */
public class ProjectStagesMain {

    public static void main(String[] args) throws Exception {

        ClassLoader cl = ProjectStagesMain.class.getClassLoader();
        URL stageConfig = cl.getResource("project-stages.yml");

        assert stageConfig!=null : "Failed to load stage configuration";

        Container container = new Container(false)
                .withStageConfig(stageConfig);

        container.fraction(
                new DatasourcesFraction()
                        .jdbcDriver("h2", (d) -> {
                            d.driverClassName("org.h2.Driver");
                            d.xaDatasourceClass("org.h2.jdbcx.JdbcDataSource");
                            d.driverModuleName("com.h2database.h2");
                        })
                        .dataSource("ExampleDS", (ds) -> {

                            ds.driverName("h2");

                            ds.connectionUrl(
                                    container
                                            .stageConfig()
                                            .resolve("database.connection.url")
                                            .getValue()
                            );
                            ds.userName("sa");
                            ds.password("sa");
                        })
        );

        // Start the container
        container.start();

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

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


    }
}

@@ -46,24 +46,46 @@
 jectStage;%0A%0A
+import java.net.URL;%0A%0A
 import org.j
@@ -145,37 +145,13 @@
 arm.
-config.datasources.DataSource
+Swarm
 ;%0Aim
@@ -298,38 +298,16 @@
 chive;%0A%0A
-import java.net.URL;%0A%0A
 /**%0A * @
@@ -458,300 +458,171 @@
    C
-lassLoader cl = ProjectStagesMain.class.getClassLoader();%0A        URL stageConfig = cl.getResource(%22project-stages.yml%22);%0A%0A        assert stageConfig!=null : %22Failed to load 
+ontainer container = new Container(args);%0A%0A        System.err.println( %22Connection URL: %22 + container.
 stage
- c
+C
 onfig
-uration%22;%0A%0A        Container container = new Container(false)%0A                .withStageConfig(stageConfig
+().resolve(%22database.connection.url%22 ).getValue() 
 );%0A%0A

Simplify the project-stages example to use the CLI capabilities.