Search in sources :

Example 6 with Interceptor

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

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

the class EtcdRegistryApiConfig method findAdminConsole.

private EtcdNodeInformation findAdminConsole() {
    Object routerObj = context.getBean(Router.class);
    if (routerObj == null)
        throw new RuntimeException("Router not found, cannot publish admin console");
    Router router = (Router) routerObj;
    for (Rule r : router.getRuleManager().getRules()) {
        if (!(r instanceof AbstractServiceProxy))
            continue;
        for (Interceptor i : r.getInterceptors()) {
            if (i instanceof AdminConsoleInterceptor) {
                String name = r.getName();
                String host = ((ServiceProxy) r).getExternalHostname();
                if (host == null)
                    host = getLocalHostname();
                String port = Integer.toString(((AbstractServiceProxy) r).getPort());
                EtcdNodeInformation node = new EtcdNodeInformation(null, null, host, port, name);
                return node;
            }
        }
    }
    throw new RuntimeException("Admin console not found but is needed. Add a service proxy with an admin console.");
}
Also used : AbstractServiceProxy(com.predic8.membrane.core.rules.AbstractServiceProxy) AdminConsoleInterceptor(com.predic8.membrane.core.interceptor.administration.AdminConsoleInterceptor) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) AbstractServiceProxy(com.predic8.membrane.core.rules.AbstractServiceProxy) EtcdNodeInformation(com.predic8.membrane.core.cloud.etcd.EtcdNodeInformation) Router(com.predic8.membrane.core.Router) Rule(com.predic8.membrane.core.rules.Rule) Interceptor(com.predic8.membrane.core.interceptor.Interceptor) AdminConsoleInterceptor(com.predic8.membrane.core.interceptor.administration.AdminConsoleInterceptor)

Example 8 with Interceptor

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

the class AdminPageBuilder method createHelpIcon.

private void createHelpIcon(Interceptor i, String id) {
    String helpId = i.getHelpId();
    if (helpId != null) {
        div().style("float:right;");
        a().href("http://membrane-soa.org/service-proxy-doc/" + getVersion() + "/configuration/reference/" + helpId + ".htm");
        span().classAttr("ui-icon ui-icon-help").title("help").end();
        end();
        end();
    }
}
Also used : URLParamUtil.createQueryString(com.predic8.membrane.core.util.URLParamUtil.createQueryString)

Example 9 with Interceptor

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

the class AdminPageBuilder method createInterceptorTable.

protected void createInterceptorTable(List<Interceptor> interceptors) {
    table().id("interceptortable").attr("cellpadding", "0", "cellspacing", "0", "border", "0", "class", "display", "id", "interceptor-table");
    thead();
    tr();
    createThs("Order", "Name");
    end();
    end();
    tbody();
    int j = 0;
    for (Interceptor i : interceptors) {
        tr();
        createTds("" + ++j, i.getDisplayName());
        end();
    }
    end();
    end();
}
Also used : 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)

Example 10 with Interceptor

use of com.predic8.membrane.core.interceptor.Interceptor 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)

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