use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class ServiceInvocationTest method createRouter.
private HttpRouter createRouter() throws Exception {
HttpRouter router = new HttpRouter();
router.getRuleManager().addProxyAndOpenPortIfNew(createFirstRule());
router.getRuleManager().addProxyAndOpenPortIfNew(createServiceRule());
router.getTransport().getInterceptors().add(router.getTransport().getInterceptors().size() - 1, new MockInterceptor("transport-log"));
router.init();
return router;
}
use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class RewriteInterceptorIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
interceptor = new RewriteInterceptor();
interceptor.getMappings().add(new Mapping("/blz-service\\?wsdl", "/axis2/services/BLZService?wsdl", null));
Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", 3006), "thomas-bayer.com", 80);
rule.getInterceptors().add(interceptor);
router = new HttpRouter();
router.getRuleManager().addProxyAndOpenPortIfNew(rule);
}
use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class REST2SOAPInterceptorIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 3004), "www.thomas-bayer.com", 80);
router = new HttpRouter();
router.getRuleManager().addProxyAndOpenPortIfNew(rule);
REST2SOAPInterceptor rest2SoapInt = new REST2SOAPInterceptor();
rest2SoapInt.setMappings(getMappings());
rule.getInterceptors().add(rest2SoapInt);
router.init();
}
use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class MyApplication method main.
public static void main(String[] args) throws Exception {
System.out.println("Starting up");
// create a new service proxy that listens on port 8080 and has a target to localhost:2001
ServiceProxy sp = createServiceProxy();
// create an enclosing WebSocket interceptor to add our own Logging interceptor to it
WebSocketInterceptor ws = new WebSocketInterceptor();
ws.getInterceptors().add(new MyWebSocketLogInterceptor());
// attach the WebSocket interceptor to the service proxy
sp.getInterceptors().add(ws);
// add the service proxy to a new router instance and start it
HttpRouter router = new HttpRouter();
router.add(sp);
router.init();
System.out.println("Starting finished - Waiting for WebSocket communication");
}
use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class TestServiceInterceptor method init.
@Override
public void init(final Router router) throws Exception {
super.init(router);
wi.init(router);
Rule r = router.getParentProxy(this);
if (r instanceof AbstractServiceProxy) {
final Path path = ((AbstractServiceProxy) r).getPath();
if (path != null) {
if (path.isRegExp())
throw new Exception("<testService> may not be used together with <path isRegExp=\"true\">.");
final String keyPath = path.getValue();
final String name = URLUtil.getName(router.getUriFactory(), keyPath);
wi.setPathRewriter(new PathRewriter() {
@Override
public String rewrite(String path2) {
try {
if (path2.contains("://")) {
path2 = new URL(new URL(path2), keyPath).toString();
} else {
Matcher m = RELATIVE_PATH_PATTERN.matcher(path2);
path2 = m.replaceAll("./" + name + "?");
}
} catch (MalformedURLException e) {
}
return path2;
}
});
}
}
}
Aggregations