2016-07-23 86 views
0

我想監控球衣服務器,從計數輸入請求的數量開始。球衣服務器的監控

我從這裏以下,官方指導:https://jersey.java.net/documentation/latest/monitoring_tracing.html

我瞭解應用事件監聽器和請求事件監聽器的概念。但是,我不明白註冊應用程序事件偵聽器的概念。我的問題是在哪裏把下面的代碼(在MyApplicationEventListener或在一個單獨的類):

ResourceConfig resourceConfig = 
     new ResourceConfig(TestResource.class, MyApplicationEventListener.class) 
     .setApplicationName("my-monitored-application"); 

這一段代碼同樣的問題:

target.path("resource").request() 
    .post(Entity.entity("post", MediaType.TEXT_PLAIN_TYPE)); 
target.path("resource").request().get(); 

如果你能表現出完整的Java項目,這對我和其他人尋找這個問題的答案來說是完美的。

非常感謝你:)

回答

0

我認爲它可以像這樣使用。

@Configuration 
public class EndpointsConfig extends ResourceConfig { 
    /** 
    * Configures all necessary features, endpoints and properties. 
    */ 
    public EndpointsConfig() throws UnknownHostException { 
    // register features 
     register(MyApplicationEventListener.class); 
    } 
} 
+0

我試過你的代碼,但它沒有做任何事情:) –