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.microservice.management; 018 019import org.apache.juneau.marshall.collections.*; 020import org.apache.juneau.rest.server.*; 021import org.apache.juneau.rest.server.servlet.*; 022 023/** 024 * Mixin flavor of the {@code /info} endpoint: renders the running application's manifest 025 * (build/version/git metadata) resolved from the host bean store. 026 * 027 * <p> 028 * Composes into a host resource via {@link Rest#mixins() @Rest(mixins=InfoMixin.class)} and delegates to a 029 * shared {@link InfoManager} worker so the mixin and {@link InfoResource resource} flavors cannot drift. 030 * When no {@link org.apache.juneau.commons.runtime.ManifestFile ManifestFile} bean is present the endpoint 031 * degrades cleanly to an empty map. 032 * 033 * <h5 class='section'>See Also:</h5><ul> 034 * <li class='jc'>{@link InfoResource} 035 * <li class='jc'>{@link InfoManager} 036 * </ul> 037 * 038 * @since 10.0.0 039 */ 040@Rest 041public class InfoMixin extends RestMixin { 042 043 private final InfoManager manager = new InfoManager(); 044 045 /** 046 * [GET /info] - Application build/version/git metadata from the manifest. 047 * 048 * @param req The HTTP request. 049 * @return The manifest main attributes as a sorted map (empty when no manifest is registered). 050 */ 051 @RestGet( 052 path="/info", 053 summary="Application info", 054 description="Renders the running application's manifest main attributes (build/version/git metadata)." 055 ) 056 public JsonMap getInfo(RestRequest req) { 057 return manager.getInfo(manager.resolveManifest(req.getContext())); 058 } 059}