Search in sources :

Example 1 with DispatchingInterceptor

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

the class HttpRouter method createTransport.

/**
 * Same as the default config from monitor-beans.xml
 */
private Transport createTransport(ProxyConfiguration proxyConfiguration) {
    Transport transport = new HttpTransport();
    List<Interceptor> interceptors = new ArrayList<Interceptor>();
    interceptors.add(new RuleMatchingInterceptor());
    interceptors.add(new DispatchingInterceptor());
    interceptors.add(new UserFeatureInterceptor());
    HTTPClientInterceptor httpClientInterceptor = new HTTPClientInterceptor();
    interceptors.add(httpClientInterceptor);
    transport.setInterceptors(interceptors);
    return transport;
}
Also used : HttpTransport(com.predic8.membrane.core.transport.http.HttpTransport) HTTPClientInterceptor(com.predic8.membrane.core.interceptor.HTTPClientInterceptor) ArrayList(java.util.ArrayList) HttpTransport(com.predic8.membrane.core.transport.http.HttpTransport) Transport(com.predic8.membrane.core.transport.Transport) HTTPClientInterceptor(com.predic8.membrane.core.interceptor.HTTPClientInterceptor) RuleMatchingInterceptor(com.predic8.membrane.core.interceptor.RuleMatchingInterceptor) Interceptor(com.predic8.membrane.core.interceptor.Interceptor) UserFeatureInterceptor(com.predic8.membrane.core.interceptor.UserFeatureInterceptor) DispatchingInterceptor(com.predic8.membrane.core.interceptor.DispatchingInterceptor) UserFeatureInterceptor(com.predic8.membrane.core.interceptor.UserFeatureInterceptor) RuleMatchingInterceptor(com.predic8.membrane.core.interceptor.RuleMatchingInterceptor) DispatchingInterceptor(com.predic8.membrane.core.interceptor.DispatchingInterceptor)

Example 2 with DispatchingInterceptor

use of com.predic8.membrane.core.interceptor.DispatchingInterceptor 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 3 with DispatchingInterceptor

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

the class RewriteInterceptorTest method setUp.

@Before
public void setUp() throws Exception {
    HttpRouter router = new HttpRouter();
    di = new DispatchingInterceptor();
    di.init(router);
    sp = new ServiceProxy(new ServiceProxyKey(80, null), "www.predic8.de", 80);
    sp.init(router);
    exc = new Exchange(null);
    exc.setRequest(MessageUtil.getGetRequest("/buy/banana/3"));
    rewriter = new RewriteInterceptor();
    List<Mapping> mappings = new ArrayList<Mapping>();
    mappings.add(new Mapping("/buy/(.*)/(.*)", "/buy?item=$1&amount=$2", null));
    rewriter.setMappings(mappings);
    rewriter.init(router);
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) ArrayList(java.util.ArrayList) Mapping(com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping) HttpRouter(com.predic8.membrane.core.HttpRouter) DispatchingInterceptor(com.predic8.membrane.core.interceptor.DispatchingInterceptor) Before(org.junit.Before)

Example 4 with DispatchingInterceptor

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

the class DispatchingInterceptorTest method setUp.

@Before
public void setUp() throws Exception {
    dispatcher = new DispatchingInterceptor();
    exc = new Exchange(null);
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) Before(org.junit.Before)

Aggregations

DispatchingInterceptor (com.predic8.membrane.core.interceptor.DispatchingInterceptor)3 Exchange (com.predic8.membrane.core.exchange.Exchange)2 HTTPClientInterceptor (com.predic8.membrane.core.interceptor.HTTPClientInterceptor)2 Interceptor (com.predic8.membrane.core.interceptor.Interceptor)2 RuleMatchingInterceptor (com.predic8.membrane.core.interceptor.RuleMatchingInterceptor)2 UserFeatureInterceptor (com.predic8.membrane.core.interceptor.UserFeatureInterceptor)2 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 HttpRouter (com.predic8.membrane.core.HttpRouter)1 ExchangeStoreInterceptor (com.predic8.membrane.core.interceptor.ExchangeStoreInterceptor)1 ReverseProxyingInterceptor (com.predic8.membrane.core.interceptor.rewrite.ReverseProxyingInterceptor)1 Mapping (com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping)1 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)1 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)1 Transport (com.predic8.membrane.core.transport.Transport)1 HttpTransport (com.predic8.membrane.core.transport.http.HttpTransport)1