package org.wildfly.swarm.ribbon.webapp.runtime;

import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
import org.wildfly.swarm.container.runtime.AbstractServerConfiguration;
import org.wildfly.swarm.netflix.ribbon.RibbonArchive;
import org.wildfly.swarm.ribbon.webapp.RibbonWebAppFraction;
import org.wildfly.swarm.undertow.WARArchive;

import java.util.ArrayList;
import java.util.List;


/**
 * @author Lance Ball
 */
public class RibbonWebAppConfiguration extends AbstractServerConfiguration<RibbonWebAppFraction> {

    public RibbonWebAppConfiguration() {
        super(RibbonWebAppFraction.class);
    }

    @Override
    public RibbonWebAppFraction defaultFraction() {
        return new RibbonWebAppFraction();
    }

    @Override
    public List<Archive> getImplicitDeployments(RibbonWebAppFraction fraction) throws Exception {
        List<Archive> list = new ArrayList<>();
        WARArchive war = ShrinkWrap.create( WARArchive.class );
        war.addClass( RibbonToTheCurbSSEServlet.class );
        war.addModule("org.wildfly.swarm.netflix.ribbon");
        war.addAsWebResource(new ClassLoaderAsset("ribbon.js", this.getClass().getClassLoader()), "ribbon.js");
        war.setContextRoot("/ribbon");
        war.as(RibbonArchive.class);
        list.add(war);
        return list;
    }

}

@@ -602,16 +602,78 @@
 ion%3E %7B%0A%0A
+    private static final String DEFAULT_CONTEXT = %22/ribbon%22;%0A%0A
     publ
@@ -697,32 +697,32 @@
 nfiguration() %7B%0A
-
         super(Ri
@@ -983,16 +983,157 @@
 ption %7B%0A
+        String context = System.getProperty( %22wildfly.swarm.ribbon.context.path%22 );%0A        if (context == null) context = DEFAULT_CONTEXT;%0A%0A
         
@@ -1491,25 +1491,23 @@
 extRoot(
-%22/ribbon%22
+context
 );%0A     

Make ribbon-webapp's context path configurable.