Polish contribution
`InfoProvider` is now `InfoContributor` and contributes to the `Info` instance via a builder. The `Info` instance is immutable. Each contributor can be disabled via the `management.info.<name>.enabled` key or all can be disabled using `management.info.defaults.enabled` (this is similar to what the health endpoint does). By default, all keys from the environment starting with `info.` are exposed. If a `git.properties` file is present in the classpath, the content of `GitInfo` is exposed using the `git` key. A `SimpleInfoContributor` and `AbstractEnvironmentInfoContributor` are available for convenience. `InfoContributor` instances can be ordered the usual way, with a default order provided by `InfoProviderAutoConfiguration#DEFAULT_ORDER`. Closes gh-3492
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package sample.actuator;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.boot.actuate.info.Info;
|
||||
import org.springframework.boot.actuate.info.InfoContributor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ExampleInfoContributor implements InfoContributor {
|
||||
|
||||
@Override
|
||||
public void contribute(Info.Builder builder) {
|
||||
builder.withDetail("example",
|
||||
Collections.singletonMap("someKey", "someValue"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package sample.actuator;
|
||||
|
||||
import org.springframework.boot.actuate.info.Info;
|
||||
import org.springframework.boot.actuate.info.InfoProvider;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ExampleInfoProvider implements InfoProvider {
|
||||
|
||||
@Override
|
||||
public Info provide() {
|
||||
Info result = new Info();
|
||||
result.put("somekey", "somevalue");
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "example";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user