001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.rest.server.ops; 018 019import org.apache.juneau.marshall.html.*; 020import org.apache.juneau.rest.server.*; 021import org.apache.juneau.rest.server.servlet.*; 022import org.apache.juneau.rest.server.stats.*; 023 024/** 025 * Mixin providing the residual {@code [GET /stats]} timing-statistics endpoint. 026 * 027 * <p> 028 * Single-responsibility op-mixin carved out of the former {@code BasicRestOperations} interface. Carries 029 * the per-method {@link HtmlDocConfig @HtmlDocConfig} that customizes the {@code /stats} HTML page. 030 * The per-method config travels with the op, while the host-wide navlinks/JSON-schema config 031 * lives at the class level on {@link BasicRestServlet}. 032 * 033 * @since 10.0.0 034 */ 035@Rest 036public class StatsMixin extends RestMixin { 037 038 /** 039 * [GET /stats] - Timing statistics. 040 * 041 * <p> 042 * Timing statistics for method invocations on this resource. 043 * 044 * @param req The HTTP request. 045 * @return A collection of timing statistics for each annotated method on this resource. 046 */ 047 @RestGet( 048 path="/stats", 049 summary="Timing statistics", 050 description="Timing statistics for method invocations on this resource." 051 ) 052 @HtmlDocConfig( 053 // Should override config annotations defined on class. 054 rank=10, 055 // Override the nav links for the swagger page. 056 navlinks = { "back: servlet:/", "json: servlet:/stats?Accept=text/json&plainText=true" }, 057 // Never show aside contents of page inherited from class. 058 aside="NONE" 059 ) 060 public RestContextStats getStats(RestRequest req) { 061 return req.getContext().getStats(); 062 } 063}