Search in sources :

Example 1 with ExchangeStoreInterceptor

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

the class Transport method init.

public void init(Router router) throws Exception {
    this.router = router;
    if (interceptors.isEmpty()) {
        interceptors.add(new RuleMatchingInterceptor());
        interceptors.add(new ExchangeStoreInterceptor(router.getExchangeStore()));
        interceptors.add(new DispatchingInterceptor());
        interceptors.add(new ReverseProxyingInterceptor());
        interceptors.add(new UserFeatureInterceptor());
        interceptors.add(new HTTPClientInterceptor());
    }
    for (Interceptor interceptor : interceptors) {
        interceptor.init(router);
    }
}
Also used : HTTPClientInterceptor(com.predic8.membrane.core.interceptor.HTTPClientInterceptor) ReverseProxyingInterceptor(com.predic8.membrane.core.interceptor.rewrite.ReverseProxyingInterceptor) ExchangeStoreInterceptor(com.predic8.membrane.core.interceptor.ExchangeStoreInterceptor) HTTPClientInterceptor(com.predic8.membrane.core.interceptor.HTTPClientInterceptor) DispatchingInterceptor(com.predic8.membrane.core.interceptor.DispatchingInterceptor) RuleMatchingInterceptor(com.predic8.membrane.core.interceptor.RuleMatchingInterceptor) Interceptor(com.predic8.membrane.core.interceptor.Interceptor) UserFeatureInterceptor(com.predic8.membrane.core.interceptor.UserFeatureInterceptor) ReverseProxyingInterceptor(com.predic8.membrane.core.interceptor.rewrite.ReverseProxyingInterceptor) ExchangeStoreInterceptor(com.predic8.membrane.core.interceptor.ExchangeStoreInterceptor) UserFeatureInterceptor(com.predic8.membrane.core.interceptor.UserFeatureInterceptor) RuleMatchingInterceptor(com.predic8.membrane.core.interceptor.RuleMatchingInterceptor) DispatchingInterceptor(com.predic8.membrane.core.interceptor.DispatchingInterceptor)

Example 2 with ExchangeStoreInterceptor

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

the class AbortExchangeTest method setup.

@Before
public void setup() throws Exception {
    router = new HttpRouter();
    LimitedMemoryExchangeStore es = new LimitedMemoryExchangeStore();
    router.setExchangeStore(es);
    router.getTransport().getInterceptors().add(2, new ExchangeStoreInterceptor(es));
    ServiceProxy sp2 = new ServiceProxy(new ServiceProxyKey("*", "*", ".*", 3031), "", -1);
    sp2.getInterceptors().add(new AbstractInterceptor() {

        @Override
        public Outcome handleRequest(Exchange exc) throws Exception {
            exc.getRequest().readBody();
            exc.setResponse(Response.ok("").body(new InputStream() {

                int l = 0;

                @Override
                public int read() throws IOException {
                    if (l >= 2000000)
                        return -1;
                    return 0;
                }
            }, true).build());
            return Outcome.RETURN;
        }
    });
    router.getRuleManager().addProxyAndOpenPortIfNew(sp2);
    router.init();
}
Also used : AbstractExchange(com.predic8.membrane.core.exchange.AbstractExchange) Exchange(com.predic8.membrane.core.exchange.Exchange) ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) Outcome(com.predic8.membrane.core.interceptor.Outcome) InputStream(java.io.InputStream) AbstractInterceptor(com.predic8.membrane.core.interceptor.AbstractInterceptor) ExchangeStoreInterceptor(com.predic8.membrane.core.interceptor.ExchangeStoreInterceptor) HttpRouter(com.predic8.membrane.core.HttpRouter) IOException(java.io.IOException) Before(org.junit.Before)

Aggregations

ExchangeStoreInterceptor (com.predic8.membrane.core.interceptor.ExchangeStoreInterceptor)2 HttpRouter (com.predic8.membrane.core.HttpRouter)1 AbstractExchange (com.predic8.membrane.core.exchange.AbstractExchange)1 Exchange (com.predic8.membrane.core.exchange.Exchange)1 AbstractInterceptor (com.predic8.membrane.core.interceptor.AbstractInterceptor)1 DispatchingInterceptor (com.predic8.membrane.core.interceptor.DispatchingInterceptor)1 HTTPClientInterceptor (com.predic8.membrane.core.interceptor.HTTPClientInterceptor)1 Interceptor (com.predic8.membrane.core.interceptor.Interceptor)1 Outcome (com.predic8.membrane.core.interceptor.Outcome)1 RuleMatchingInterceptor (com.predic8.membrane.core.interceptor.RuleMatchingInterceptor)1 UserFeatureInterceptor (com.predic8.membrane.core.interceptor.UserFeatureInterceptor)1 ReverseProxyingInterceptor (com.predic8.membrane.core.interceptor.rewrite.ReverseProxyingInterceptor)1 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)1 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Before (org.junit.Before)1