use of com.predic8.membrane.core.rules.Rule in project service-proxy by membrane.
the class SwaggerRewriterInterceptor method init.
@Override
public void init() throws Exception {
// inherit wsdl="..." from SoapProxy
if (this.swagger == null) {
Rule parent = router.getParentProxy(this);
if (parent instanceof SwaggerProxy) {
setSwagger(((SwaggerProxy) parent).getSwagger());
}
}
// use default if no SwaggerProxy is found
if (this.swagger == null) {
String swaggerSource = IOUtils.toString(this.getRouter().getResolverMap().resolve(this.swaggerJson));
this.swagger = new SwaggerParser().parse(swaggerSource);
this.swaggerUrl = this.swaggerJson;
}
}
use of com.predic8.membrane.core.rules.Rule in project service-proxy by membrane.
the class LargeBodyTest method setup.
public void setup() throws Exception {
// streaming only works for maxRetries = 1
hcc = new HttpClientConfiguration();
hcc.setMaxRetries(1);
Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 3040), "thomas-bayer.com", 80);
rule.getInterceptors().add(new AbstractInterceptor() {
@Override
public Outcome handleRequest(Exchange exc) throws Exception {
exc.setResponse(Response.ok().body("").build());
return Outcome.RETURN;
}
});
router = new HttpRouter();
((HTTPClientInterceptor) router.getTransport().getInterceptors().get(3)).setHttpClientConfig(hcc);
router.getRuleManager().addProxyAndOpenPortIfNew(rule);
router.init();
Rule rule1 = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 3041), "localhost", 3040);
router2 = new HttpRouter();
((HTTPClientInterceptor) router2.getTransport().getInterceptors().get(3)).setHttpClientConfig(hcc);
router2.getRuleManager().addProxyAndOpenPortIfNew(rule1);
router2.init();
}
use of com.predic8.membrane.core.rules.Rule in project service-proxy by membrane.
the class Http10Test method setUp.
@Before
public void setUp() throws Exception {
Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 3000), "thomas-bayer.com", 80);
router = new HttpRouter();
router.getRuleManager().addProxyAndOpenPortIfNew(rule);
router.init();
}
use of com.predic8.membrane.core.rules.Rule in project service-proxy by membrane.
the class RuleManager method addProxyAndOpenPortIfNew.
public synchronized void addProxyAndOpenPortIfNew(Rule rule, RuleDefinitionSource source) throws IOException {
if (exists(rule.getKey()))
return;
router.getTransport().openPort(rule.getKey().getIp(), rule.getKey().getPort(), rule.getSslInboundContext());
rules.add(rule);
ruleSources.add(source);
for (IRuleChangeListener listener : listeners) {
listener.ruleAdded(rule);
}
}
use of com.predic8.membrane.core.rules.Rule in project service-proxy by membrane.
the class RuleManager method removeRule.
public synchronized void removeRule(Rule rule) {
getExchangeStore().removeAllExchanges(rule);
int i = rules.indexOf(rule);
rules.remove(i);
ruleSources.remove(i);
for (IRuleChangeListener listener : listeners) {
listener.ruleRemoved(rule, rules.size());
}
}
Aggregations