Search in sources :

Example 16 with Rule

use of com.predic8.membrane.core.rules.Rule in project service-proxy by membrane.

the class Http11Test method setUp.

@Before
public void setUp() throws Exception {
    Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 4000), "thomas-bayer.com", 80);
    router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(rule);
    router.init();
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) Rule(com.predic8.membrane.core.rules.Rule) HttpRouter(com.predic8.membrane.core.HttpRouter) Before(org.junit.Before)

Example 17 with Rule

use of com.predic8.membrane.core.rules.Rule in project service-proxy by membrane.

the class ServiceInvocationTest method createServiceRule.

private ServiceProxy createServiceRule() {
    ServiceProxy rule = new ServiceProxy(new ServiceProxyKey("localhost", "*", "*", 3012), "thomas-bayer.com", 80);
    rule.setName("log");
    rule.getInterceptors().add(new MockInterceptor("log"));
    return rule;
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) MockInterceptor(com.predic8.membrane.core.interceptor.MockInterceptor)

Example 18 with Rule

use of com.predic8.membrane.core.rules.Rule in project service-proxy by membrane.

the class ConnectionTest method setUp.

@Before
public void setUp() throws Exception {
    Rule rule2000 = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 2000), "predic8.com", 80);
    router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(rule2000);
    conLocalhost = Connection.open("localhost", 2000, null, null, 30000);
    con127_0_0_1 = Connection.open("127.0.0.1", 2000, null, null, 30000);
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) Rule(com.predic8.membrane.core.rules.Rule) HttpRouter(com.predic8.membrane.core.HttpRouter) Before(org.junit.Before)

Example 19 with Rule

use of com.predic8.membrane.core.rules.Rule in project service-proxy by membrane.

the class Router method tryReinitialization.

public void tryReinitialization() {
    boolean stillFailing = false;
    ArrayList<Rule> inactive = getInactiveRules();
    if (inactive.size() > 0) {
        log.info("Trying to activate all inactive rules.");
        for (Rule rule : inactive) {
            try {
                Rule newRule = rule.clone();
                if (!newRule.isActive()) {
                    log.info("New rule is still not active.");
                    stillFailing = true;
                }
                getRuleManager().replaceRule(rule, newRule);
            } catch (CloneNotSupportedException e) {
                log.error("", e);
            }
        }
    }
    if (stillFailing)
        log.info("There are still inactive rules.");
    else {
        stopAutoReinitializator();
        log.info("All rules have been initialized.");
    }
}
Also used : Rule(com.predic8.membrane.core.rules.Rule)

Example 20 with Rule

use of com.predic8.membrane.core.rules.Rule in project service-proxy by membrane.

the class RuleManager method ruleDown.

public synchronized void ruleDown(Rule rule) {
    int index = rules.indexOf(rule);
    if (index < 0 || index == (rules.size() - 1))
        return;
    Collections.swap(rules, index, index + 1);
    Collections.swap(ruleSources, index, index + 1);
    for (IRuleChangeListener listener : listeners) {
        listener.rulePositionsChanged();
    }
}
Also used : IRuleChangeListener(com.predic8.membrane.core.model.IRuleChangeListener)

Aggregations

Rule (com.predic8.membrane.core.rules.Rule)29 ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)15 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)13 HttpRouter (com.predic8.membrane.core.HttpRouter)11 Before (org.junit.Before)8 IRuleChangeListener (com.predic8.membrane.core.model.IRuleChangeListener)6 ProxyRule (com.predic8.membrane.core.rules.ProxyRule)6 AbstractServiceProxy (com.predic8.membrane.core.rules.AbstractServiceProxy)5 Exchange (com.predic8.membrane.core.exchange.Exchange)3 IOException (java.io.IOException)3 Test (org.junit.Test)3 AbstractExchange (com.predic8.membrane.core.exchange.AbstractExchange)2 HeaderField (com.predic8.membrane.core.http.HeaderField)2 MockInterceptor (com.predic8.membrane.core.interceptor.MockInterceptor)2 Mapping (com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping)2 IExchangesStoreListener (com.predic8.membrane.core.model.IExchangesStoreListener)2 NullRule (com.predic8.membrane.core.rules.NullRule)2 SOAPProxy (com.predic8.membrane.core.rules.SOAPProxy)2 StringWriter (java.io.StringWriter)2 CacheBuilder (com.google.common.cache.CacheBuilder)1