use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class DynamicAdminPageInterceptor method handleServiceProxyStartRequest.
@Mapping("/admin/service-proxy/start/?(\\?.*)?")
public Response handleServiceProxyStartRequest(Map<String, String> params, String relativeRootPath) throws Exception {
if (readOnly)
return createReadOnlyErrorResponse();
Rule rule = RuleUtil.findRuleByIdentifier(router, params.get("name"));
Rule newRule = rule.clone();
router.getRuleManager().replaceRule(rule, newRule);
return respond(getServiceProxyPage(params, relativeRootPath));
}
use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class DynamicAdminPageInterceptor method handlePruleShowRequest.
@Mapping("/admin/proxy/show/?(\\?.*)?")
public Response handlePruleShowRequest(final Map<String, String> params, String relativeRootPath) throws Exception {
StringWriter writer = new StringWriter();
final ProxyRule rule = (ProxyRule) RuleUtil.findRuleByIdentifier(router, params.get("name"));
return respond(new AdminPageBuilder(writer, router, relativeRootPath, params, readOnly) {
@Override
protected int getSelectedTab() {
return TAB_ID_PROXIES;
}
@Override
protected String getTitle() {
return super.getTitle() + " " + rule.toString() + " Proxy";
}
@Override
protected void createTabContent() throws Exception {
h1().text(rule.toString() + " Proxy").end();
if (rule.getKey().getPort() != -1) {
table();
createTr("Listen Port", "" + rule.getKey().getPort());
end();
}
h2().text("Status Codes").end();
createStatusCodesTable(rule.getStatisticsByStatusCodes());
h2().text("Interceptors").end();
createInterceptorTable(rule.getInterceptors());
}
}.createPage());
}
use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class ConditionalInterceptor method init.
@Override
public void init(Router router) throws Exception {
super.init(router);
LanguageSupport ls = new GroovyLanguageSupport();
condition = ls.compileExpression(router, test);
}
use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class CoreActivator method start.
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
if (new File("configuration/log4j.properties").exists())
PropertyConfigurator.configure("configuration/log4j.properties");
Platform.addLogListener(logListener);
final MembraneCommandLine cl = new MembraneCommandLine();
cl.parse(fixArguments(Platform.getCommandLineArgs()));
if (cl.hasConfiguration()) {
log.info("loading monitor beans from command line argument: " + getConfigurationFileName(cl));
router = Router.init(getConfigurationFileName(cl), this.getClass().getClassLoader());
} else {
try {
if (ClassloaderUtil.fileExists(getConfigurationFileName())) {
log.info("Eclipse framework found config file: " + getConfigurationFileName());
readBeanConfigWhenStartedAsProduct();
} else {
readBeanConfigWhenStartedInEclipse();
}
} catch (Exception e1) {
log.error("Unable to read bean configuration file: " + e1.getMessage());
log.error("Unable to read bean configuration file: " + e1.getStackTrace());
e1.printStackTrace();
}
}
sr = context.registerService(router.getClass().getName(), router, null);
}
use of com.predic8.membrane.core.Router in project service-proxy by membrane.
the class RouterUtil method initializeRoutersFromSpringWebContext.
public static Router initializeRoutersFromSpringWebContext(XmlWebApplicationContext appCtx, final ServletContext ctx, String configLocation) {
appCtx.setServletContext(ctx);
appCtx.setConfigLocation(configLocation);
appCtx.refresh();
Collection<Router> routers = appCtx.getBeansOfType(Router.class).values();
Router theOne = null;
for (Router r : routers) {
r.getResolverMap().addSchemaResolver(new FileSchemaWebAppResolver(ctx));
if (r.getTransport() instanceof ServletTransport) {
if (theOne != null)
throw new RuntimeException("Only one <router> may have a <servletTransport> defined.");
theOne = r;
}
}
appCtx.start();
return theOne;
}
Aggregations