@Override protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { handle(httpPostHandler, req, resp); }
@Override protected void configure() { bind (JolokiaServlet.class); }
@Inject public JolokiaServlet(final BackendManager backendManager, final HttpRequestHandler requestHandler) { this.backendManager = backendManager; this.requestHandler = requestHandler; this.httpGetHandler = new HttpGetHandler(); this.httpPostHandler = new HttpPostHandler(); }
@Override public HttpServlet get() { if (config.isJolokiaEnabled()) { return injector.createChildInjector(new RealJolokiaModule()).getInstance(JolokiaServlet.class); } return new NoJolokiaServlet(); } }
@Override public void configureServlets() { bind (JolokiaConfig.class).toProvider(ConfigProvider.of(JolokiaConfig.class)); bind (HttpServlet.class).annotatedWith(JOLOKIA_SERVLET).toProvider(JolokiaServletProvider.class).in(Scopes.SINGLETON); serve("/jolokia/*").with(Key.get(HttpServlet.class, JOLOKIA_SERVLET)); configureRestrictor(); }
@Override protected void configure() { install (new InstrumentationModule()); install (new JolokiaModule()); install (new DatabaseMetricsModule()); install (new ArgumentFactoryModule()); install (new JerseyServletModule()); install (new NessJerseyServletModule(config, paths)); install (new NessJerseyExceptionMapperModule()); NessJerseyBinder.bindResourceFilterFactory(binder()).to(BodySizeLimitResourceFilterFactory.class); bind (NessJacksonJsonProvider.class); install (new SelftestModule()); install (new ServerInfoModule()); } }
private void handle(final ServletRequestHandler reqHandler, final HttpServletRequest req, final HttpServletResponse resp) throws IOException { JSONAware json = null; try { // Check access policy requestHandler.checkClientIPAccess(req.getRemoteHost(), req.getRemoteAddr()); // Dispatch for the proper HTTP request method json = reqHandler.handleRequest(req, resp); if (backendManager.isDebug()) { backendManager.debug("Response: " + json); } } catch (RuntimeMBeanException rme) { json = requestHandler.handleThrowable(rme.getTargetException()); } catch (Throwable exp) { json = requestHandler.handleThrowable(exp); } finally { final String callback = req.getParameter(ConfigKey.CALLBACK.getKeyValue()); if (callback != null) { // Send a JSONP response sendResponse(resp, "text/javascript", callback + "(" + json.toJSONString() + ");"); } else { sendResponse(resp, "application/json", json.toJSONString()); } } }
/** * Override this method to implement access restrictions. */ protected void configureRestrictor() { bind(Restrictor.class).to(AllowAllRestrictor.class).in(Scopes.SINGLETON); }
@Override protected void configure() { binder().requireExplicitBindings(); binder().disableCircularProxies(); install(new JolokiaModule()); install(new JerseyServletModule()); install(new NessJerseyServletModule(config, paths)); install(new JmxStarterModule(config)); install(new InstrumentationModule()); install(new DatabaseMetricsModule()); install(new ArgumentFactoryModule()); install (new NessJerseyExceptionMapperModule()); install(new SelftestModule()); NessJerseyBinder.bindResourceFilterFactory(binder()).to(BodySizeLimitResourceFilterFactory.class); bind (NessJacksonJsonProvider.class); } }
@Override protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { handle(httpGetHandler, req, resp); }