Search in sources :

Example 51 with Exchange

use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.

the class WsaEndpointRewriterInterceptorTest method setUp.

@Before
public void setUp() {
    rewriter = new WsaEndpointRewriterInterceptor();
    exc = new Exchange(null);
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) WsaEndpointRewriterInterceptor(com.predic8.membrane.core.interceptor.ws_addressing.WsaEndpointRewriterInterceptor) Before(org.junit.Before)

Example 52 with Exchange

use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.

the class MyInterceptor method handleRequest.

@Override
public Outcome handleRequest(Exchange exc) throws Exception {
    System.out.println("MyInterceptor invoked.");
    System.out.println("Request headers:");
    for (HeaderField headerField : exc.getRequest().getHeader().getAllHeaderFields()) System.out.print(headerField.getHeaderName() + ": " + headerField.getValue());
    return Outcome.CONTINUE;
}
Also used : HeaderField(com.predic8.membrane.core.http.HeaderField)

Example 53 with Exchange

use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.

the class LBNotificationClient method notifiyClusterManager.

private Response notifiyClusterManager() throws Exception {
    HttpClient client = new HttpClient();
    Exchange exc = new Exchange(null);
    Request r = MessageUtil.getPostRequest(getRequestURL());
    r.setBodyContent(new byte[0]);
    exc.setRequest(r);
    exc.getDestinations().add(getRequestURL());
    Response res = client.call(exc).getResponse();
    return res;
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) Response(com.predic8.membrane.core.http.Response) HttpClient(com.predic8.membrane.core.transport.http.HttpClient) Request(com.predic8.membrane.core.http.Request)

Example 54 with Exchange

use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.

the class Exchange method block.

public void block(Message msg) throws TerminateException {
    try {
        log.debug("Message thread waits");
        msg.wait();
        log.debug("Message thread received notify");
        if (isForcedToStop())
            throw new TerminateException("Force the exchange to stop.");
    } catch (InterruptedException e1) {
        Thread.currentThread().interrupt();
    }
}
Also used : TerminateException(com.predic8.membrane.core.TerminateException)

Example 55 with Exchange

use of com.predic8.membrane.core.exchange.Exchange in project service-proxy by membrane.

the class DynamicAdminPageInterceptor method handleRequest.

@Override
public Outcome handleRequest(Exchange exc) throws Exception {
    log.debug("request: " + exc.getOriginalRequestUri());
    exc.setTimeReqSent(System.currentTimeMillis());
    Outcome o = dispatchRequest(exc);
    exc.setReceived();
    exc.setTimeResReceived(System.currentTimeMillis());
    return o;
}
Also used : Outcome(com.predic8.membrane.core.interceptor.Outcome)

Aggregations

Exchange (com.predic8.membrane.core.exchange.Exchange)107 Test (org.junit.Test)39 IOException (java.io.IOException)32 Request (com.predic8.membrane.core.http.Request)25 Outcome (com.predic8.membrane.core.interceptor.Outcome)24 Response (com.predic8.membrane.core.http.Response)16 AbstractInterceptor (com.predic8.membrane.core.interceptor.AbstractInterceptor)16 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)16 HttpRouter (com.predic8.membrane.core.HttpRouter)14 Before (org.junit.Before)13 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)12 AbstractExchange (com.predic8.membrane.core.exchange.AbstractExchange)11 Header (com.predic8.membrane.core.http.Header)10 HttpClient (com.predic8.membrane.core.transport.http.HttpClient)10 CacheBuilder (com.google.common.cache.CacheBuilder)9 Rule (com.predic8.membrane.core.rules.Rule)6 URISyntaxException (java.net.URISyntaxException)6 UnknownHostException (java.net.UnknownHostException)6 ArrayList (java.util.ArrayList)6 Session (com.predic8.membrane.core.interceptor.authentication.session.SessionManager.Session)5