Dropwizard:新管理员资源 [英] Dropwizard : New admin resource

查看:47
本文介绍了Dropwizard:新管理员资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Drowpizard 0.7.1,但也许我很快就会升级到0.8.4.

I'm using Drowpizard 0.7.1, but perhaps I will upgrade to 0.8.4 very soon.

是否有人知道如何向dropwizard添加管理资源,如下面的示例所示,显示在操作菜单"中?

Does anyone know how to add a admin resource to dropwizard, that is shown in Operational Menu like the example below?

Operational Menu

    Metrics
    Ping
    Threads
    Healthcheck
    CustomAdminXy

推荐答案

我认为您不容易做到这一点.

I don't think you can do this easily.

DefaultServerFactory 并覆盖

The AdminServlet is created when the ServerFactory is built. It may be possible to extend DefaultServerFactory and override createAdminServlet to create a custom Admin servlet with your links etc... (You would then have to set your server factory via configuration.)

似乎这将涉及一些代码重复并且可能非常脆弱.

It seems like this would involve some duplication of code and could be quite fragile.

仅注册自己的管理servlet(除了常规的servlet)可能会更容易,例如:

It might be easier to just register your own admin servlet (in addition to the regular one), e.g.:

environment.admin().addServlet("custom-admin", new CustomAdminServlet())
    .addMapping("/custom-admin");

可能也不理想.

这篇关于Dropwizard:新管理员资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆