/*******************************************************************************
 * Copyright (c) 2012-2015 Codenvy, S.A.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Codenvy, S.A. - initial API and implementation
 *******************************************************************************/
package org.eclipse.che.plugin.docker.machine.ext;

import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.name.Names;

import org.eclipse.che.plugin.docker.machine.ServerConf;

/**
 * Guice module for extension servers feature in docker machines
 *
 * @author Alexander Garagatyi
 */
// Not a DynaModule, install manually
public class DockerExtServerModule extends AbstractModule {
    @Override
    protected void configure() {
        bind(DockerMachineExtServerLauncher.class).asEagerSingleton();

        Multibinder<ServerConf> machineServers = Multibinder.newSetBinder(binder(), ServerConf.class);
        machineServers.addBinding().toInstance(new ServerConf("extensions", "4401", "http"));

        bindConstant().annotatedWith(Names.named(DockerMachineExtServerLauncher.START_EXT_SERVER_COMMAND))
                      .to("mkdir -p ~/che && unzip /mnt/che/ext-server.zip -d ~/che/ext-server && ~/che/ext-server/bin/catalina.sh start");

        // :ro removed because of bug in a docker 1.6:L
        //TODO add :ro when bug is fixed or rework ext server binding mechanism to provide copy of the ext server zip to each machine
        Multibinder<String> volumesMultibinder =
                Multibinder.newSetBinder(binder(), String.class, Names.named("machine.docker.system_volumes"));
        volumesMultibinder.addBinding().toProvider(DockerExtServerBindingProvider.class);
    }
}

@@ -1282,256 +1282,8 @@
 );%0A%0A
-        bindConstant().annotatedWith(Names.named(DockerMachineExtServerLauncher.START_EXT_SERVER_COMMAND))%0A                      .to(%22mkdir -p ~/che && unzip /mnt/che/ext-server.zip -d ~/che/ext-server && ~/che/ext-server/bin/catalina.sh start%22);%0A%0A
     

make it possible to configure different start commands for che ext server in properties