org.webpieces.httpproxy.impl.HttpProxyFactoryImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of embeddablehttpproxy Show documentation
Show all versions of embeddablehttpproxy Show documentation
Someone forgot to fill this in. See http://stackoverflow.com/questions/38272550/how-to-fail-the-gradle-build-if-subproject-is-missing-a-property
The newest version!
package org.webpieces.httpproxy.impl;
import org.webpieces.httpproxy.api.HttpProxy;
import org.webpieces.httpproxy.api.HttpProxyFactory;
import org.webpieces.httpproxy.api.ProxyConfig;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.util.Modules;
public class HttpProxyFactoryImpl extends HttpProxyFactory {
@Override
protected HttpProxy createHttpProxyImpl(String id, Module overrideModule, ProxyConfig config) {
Module testModule = overrideModule;
Module allModules = getModules(config);
if(testModule != null)
allModules = Modules.override(allModules).with(testModule);
Injector injector = Guice.createInjector(allModules);
return injector.getInstance(HttpProxy.class);
}
private Module getModules(ProxyConfig config) {
return Modules.combine(
new HttpProxyModule(config)
);
}
}