use of com.predic8.membrane.core.interceptor.Interceptor in project service-proxy by membrane.
the class SpringReferencesTest method doit.
@Test
public void doit() {
ServiceProxy p = (ServiceProxy) r.getRules().iterator().next();
List<Interceptor> is = p.getInterceptors();
Assert.assertEquals(LogInterceptor.class, is.get(0).getClass());
Assert.assertEquals(LogInterceptor.class, is.get(1).getClass());
Assert.assertEquals(LogInterceptor.class, is.get(2).getClass());
Assert.assertEquals(SpringInterceptor.class, is.get(3).getClass());
Assert.assertEquals(LogInterceptor.class, is.get(4).getClass());
SpringInterceptor si = (SpringInterceptor) is.get(3);
Assert.assertSame(is.get(1), is.get(2));
Assert.assertSame(is.get(1), si.getInner());
}
use of com.predic8.membrane.core.interceptor.Interceptor in project service-proxy by membrane.
the class ConditionalInterceptor method getShortDescription.
@Override
public String getShortDescription() {
String ret = "if (" + test + ") {";
for (Interceptor i : getInterceptors()) {
ret += "<br/> " + i.getDisplayName();
}
ret += "<br/>}";
return ret;
}
use of com.predic8.membrane.core.interceptor.Interceptor in project service-proxy by membrane.
the class RequestInterceptor method handleRequest.
@Override
public Outcome handleRequest(Exchange exc) throws Exception {
boolean logDebug = log.isDebugEnabled();
for (Interceptor i : getInterceptors()) {
EnumSet<Flow> f = i.getFlow();
if (!f.contains(Flow.REQUEST))
continue;
if (logDebug)
log.debug("Invoking request handler: " + i.getDisplayName() + " on exchange: " + exc);
Outcome o = i.handleRequest(exc);
if (o != Outcome.CONTINUE)
return o;
}
return Outcome.CONTINUE;
}
use of com.predic8.membrane.core.interceptor.Interceptor in project service-proxy by membrane.
the class AbstractProxy method init.
/**
* Called after parsing is complete and this has been added to the object tree (whose root is Router).
*/
public final void init(Router router) throws Exception {
this.router = router;
try {
init();
for (Interceptor i : interceptors) i.init(router);
active = true;
} catch (Exception e) {
if (!router.isRetryInit())
throw e;
log.error("", e);
active = false;
error = e.getMessage();
}
}
use of com.predic8.membrane.core.interceptor.Interceptor in project service-proxy by membrane.
the class SwaggerProxy method init.
@Override
public void init() throws Exception {
super.init();
// download swaggerUrl
HttpClient hc = new HttpClient(router.getHttpClientConfig());
Exchange ex = hc.call(new Request.Builder().get(swaggerUrl).buildExchange());
if (ex.getResponse().getStatusCode() != 200) {
log.error("Couldn't fetch Swagger URL!");
throw new Exception("Couldn't fetch Swagger URL!");
}
// parse swaggerUrl
swagger = new SwaggerParser().parse(ex.getResponse().getBodyAsStringDecoded());
// pass swagger specification to Swagger Key
((SwaggerProxyKey) key).setSwagger(swagger);
((SwaggerProxyKey) key).setAllowUI(allowUI);
// add interceptor to position 0.
SwaggerRewriterInterceptor sri = new SwaggerRewriterInterceptor(swagger, swaggerUrl);
interceptors.add(0, sri);
}
Aggregations