use of com.predic8.membrane.core.interceptor.flow.RequestInterceptor in project service-proxy by membrane.
the class AdminPageBuilder method createServiceProxyVisualization.
public void createServiceProxyVisualization(AbstractServiceProxy proxy, String relativeRootPath) {
List<Interceptor> leftStack = new ArrayList<Interceptor>(), rightStack = new ArrayList<Interceptor>();
List<Interceptor> list = new ArrayList<Interceptor>(proxy.getInterceptors());
list.add(new // fake interceptor so that both stacks end with the same size
AbstractInterceptor() {
@Override
public EnumSet<Flow> getFlow() {
return Flow.Set.REQUEST_RESPONSE;
}
});
// build left and right stacks
for (Interceptor i : list) {
EnumSet<Flow> f = i.getFlow();
if (i instanceof ResponseInterceptor) {
for (Interceptor i2 : ((ResponseInterceptor) i).getInterceptors()) rightStack.add(i2);
} else if (i instanceof RequestInterceptor) {
for (Interceptor i3 : ((RequestInterceptor) i).getInterceptors()) leftStack.add(i3);
} else if (f.contains(Flow.REQUEST)) {
if (f.contains(Flow.RESPONSE)) {
// fill left and right to same height
while (leftStack.size() < rightStack.size()) leftStack.add(null);
while (rightStack.size() < leftStack.size()) rightStack.add(null);
// put i into both
leftStack.add(i);
rightStack.add(i);
} else {
leftStack.add(i);
}
} else {
if (f.contains(Flow.RESPONSE)) {
rightStack.add(i);
}
}
}
boolean noTarget = proxy.getTargetURL() == null && proxy.getTargetHost() == null;
table().cellspacing("0px").cellpadding("0px").classAttr("spv").style("width:662px");
createListenerRow(proxy);
if (leftStack.size() > 1 || !noTarget) {
createBeginArrowsRow();
for (int i = 0; i < leftStack.size() - 1 - (noTarget ? 1 : 0); i++) {
tr().style("background:url(\"" + relativeRootPath + "/admin/images/spv-middle.png\");background-repeat:repeat-y;display:inline-table");
createInterceptorRow(leftStack, rightStack, i, false);
end();
}
createEndArrowsRow();
if (noTarget) {
tr();
createInterceptorRow(leftStack, rightStack, leftStack.size() - 2, true);
end();
} else {
createTargetRow(proxy);
}
}
end();
}
Aggregations