Search in sources :

Example 16 with Interceptor

use of com.predic8.membrane.core.interceptor.Interceptor in project service-proxy by membrane.

the class RewriteInterceptorIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    interceptor = new RewriteInterceptor();
    interceptor.getMappings().add(new Mapping("/blz-service\\?wsdl", "/axis2/services/BLZService?wsdl", null));
    Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 3006), "thomas-bayer.com", 80);
    rule.getInterceptors().add(interceptor);
    router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(rule);
}
Also used : Mapping(com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping) Rule(com.predic8.membrane.core.rules.Rule) HttpRouter(com.predic8.membrane.core.HttpRouter)

Example 17 with Interceptor

use of com.predic8.membrane.core.interceptor.Interceptor in project service-proxy by membrane.

the class SOAPMessageValidatorInterceptorTest method createValidatorInterceptor.

private ValidatorInterceptor createValidatorInterceptor(String wsdl) throws Exception {
    ValidatorInterceptor interceptor = new ValidatorInterceptor();
    interceptor.setWsdl(wsdl);
    interceptor.setResourceResolver(new ResolverMap());
    interceptor.init();
    return interceptor;
}
Also used : ResolverMap(com.predic8.membrane.core.resolver.ResolverMap)

Example 18 with Interceptor

use of com.predic8.membrane.core.interceptor.Interceptor in project service-proxy by membrane.

the class ValidatorInterceptorTest method createValidatorInterceptor.

private ValidatorInterceptor createValidatorInterceptor(String wsdl) throws Exception {
    ValidatorInterceptor interceptor = new ValidatorInterceptor();
    interceptor.setResourceResolver(new ResolverMap());
    interceptor.setWsdl(wsdl);
    interceptor.init();
    return interceptor;
}
Also used : ResolverMap(com.predic8.membrane.core.resolver.ResolverMap)

Example 19 with Interceptor

use of com.predic8.membrane.core.interceptor.Interceptor in project service-proxy by membrane.

the class MyApplication method main.

public static void main(String[] args) throws Exception {
    System.out.println("Starting up");
    // create a new service proxy that listens on port 8080 and has a target to localhost:2001
    ServiceProxy sp = createServiceProxy();
    // create an enclosing WebSocket interceptor to add our own Logging interceptor to it
    WebSocketInterceptor ws = new WebSocketInterceptor();
    ws.getInterceptors().add(new MyWebSocketLogInterceptor());
    // attach the WebSocket interceptor to the service proxy
    sp.getInterceptors().add(ws);
    // add the service proxy to a new router instance and start it
    HttpRouter router = new HttpRouter();
    router.add(sp);
    router.init();
    System.out.println("Starting finished - Waiting for WebSocket communication");
}
Also used : ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) WebSocketInterceptor(com.predic8.membrane.core.interceptor.tunnel.WebSocketInterceptor) MyWebSocketLogInterceptor(com.predic8.membrane.core.interceptor.websocket.custom.MyWebSocketLogInterceptor) HttpRouter(com.predic8.membrane.core.HttpRouter)

Example 20 with Interceptor

use of com.predic8.membrane.core.interceptor.Interceptor 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();
}
Also used : RequestInterceptor(com.predic8.membrane.core.interceptor.flow.RequestInterceptor) LoadBalancingInterceptor(com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor) Interceptor(com.predic8.membrane.core.interceptor.Interceptor) ResponseInterceptor(com.predic8.membrane.core.interceptor.flow.ResponseInterceptor) RequestInterceptor(com.predic8.membrane.core.interceptor.flow.RequestInterceptor) AbstractInterceptor(com.predic8.membrane.core.interceptor.AbstractInterceptor) Flow(com.predic8.membrane.core.interceptor.Interceptor.Flow) ResponseInterceptor(com.predic8.membrane.core.interceptor.flow.ResponseInterceptor)

Aggregations

Interceptor (com.predic8.membrane.core.interceptor.Interceptor)11 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)6 Test (org.junit.Test)6 HttpRouter (com.predic8.membrane.core.HttpRouter)5 Rule (com.predic8.membrane.core.rules.Rule)5 Before (org.junit.Before)5 Exchange (com.predic8.membrane.core.exchange.Exchange)4 ArrayList (java.util.ArrayList)4 LoadBalancingInterceptor (com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor)3 ResolverMap (com.predic8.membrane.core.resolver.ResolverMap)3 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)3 Response (com.predic8.membrane.core.http.Response)2 AbstractInterceptor (com.predic8.membrane.core.interceptor.AbstractInterceptor)2 DispatchingInterceptor (com.predic8.membrane.core.interceptor.DispatchingInterceptor)2 HTTPClientInterceptor (com.predic8.membrane.core.interceptor.HTTPClientInterceptor)2 RuleMatchingInterceptor (com.predic8.membrane.core.interceptor.RuleMatchingInterceptor)2 UserFeatureInterceptor (com.predic8.membrane.core.interceptor.UserFeatureInterceptor)2 AccessControlInterceptor (com.predic8.membrane.core.interceptor.acl.AccessControlInterceptor)2 User (com.predic8.membrane.core.interceptor.authentication.session.StaticUserDataProvider.User)2 RequestInterceptor (com.predic8.membrane.core.interceptor.flow.RequestInterceptor)2