Java 类org.springframework.boot.actuate.endpoint.mvc.MvcEndpoint 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ManagementWebSecurityAutoConfiguration.java   
public String[] getPaths(EndpointHandlerMapping endpointHandlerMapping) {
    if (endpointHandlerMapping == null) {
        return NO_PATHS;
    }
    Set<? extends MvcEndpoint> endpoints = endpointHandlerMapping.getEndpoints();
    Set<String> paths = new LinkedHashSet<String>(endpoints.size());
    for (MvcEndpoint endpoint : endpoints) {
        if (isIncluded(endpoint)) {
            String path = endpointHandlerMapping.getPath(endpoint.getPath());
            paths.add(path);
            if (!path.equals("")) {
                if (endpoint.isSensitive()) {
                    // Ensure that nested paths are secured
                    paths.add(path + "/**");
                    // Add Spring MVC-generated additional paths
                    paths.add(path + ".*");
                }
            }
            paths.add(path + "/");
        }
    }
    return paths.toArray(new String[paths.size()]);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcManagementContextConfiguration.java   
@Bean
@ConditionalOnMissingBean
public EndpointHandlerMapping endpointHandlerMapping() {
    Set<? extends MvcEndpoint> endpoints = mvcEndpoints().getEndpoints();
    CorsConfiguration corsConfiguration = getCorsConfiguration(this.corsProperties);
    EndpointHandlerMapping mapping = new EndpointHandlerMapping(endpoints,
            corsConfiguration);
    boolean disabled = this.managementServerProperties.getPort() != null
            && this.managementServerProperties.getPort() == -1;
    mapping.setDisabled(disabled);
    if (!disabled) {
        mapping.setPrefix(this.managementServerProperties.getContextPath());
    }
    if (this.mappingCustomizers != null) {
        for (EndpointHandlerMappingCustomizer customizer : this.mappingCustomizers) {
            customizer.customize(mapping);
        }
    }
    return mapping;
}
项目:spring-boot-concourse    文件:ManagementWebSecurityAutoConfiguration.java   
public String[] getPaths(EndpointHandlerMapping endpointHandlerMapping) {
    if (endpointHandlerMapping == null) {
        return NO_PATHS;
    }
    Set<? extends MvcEndpoint> endpoints = endpointHandlerMapping.getEndpoints();
    Set<String> paths = new LinkedHashSet<String>(endpoints.size());
    for (MvcEndpoint endpoint : endpoints) {
        if (isIncluded(endpoint)) {
            String path = endpointHandlerMapping.getPath(endpoint.getPath());
            paths.add(path);
            if (!path.equals("")) {
                if (endpoint.isSensitive()) {
                    // Ensure that nested paths are secured
                    paths.add(path + "/**");
                    // Add Spring MVC-generated additional paths
                    paths.add(path + ".*");
                }
            }
            paths.add(path + "/");
        }
    }
    return paths.toArray(new String[paths.size()]);
}
项目:spring-boot-concourse    文件:EndpointWebMvcManagementContextConfiguration.java   
@Bean
@ConditionalOnMissingBean
public EndpointHandlerMapping endpointHandlerMapping() {
    Set<? extends MvcEndpoint> endpoints = mvcEndpoints().getEndpoints();
    CorsConfiguration corsConfiguration = getCorsConfiguration(this.corsProperties);
    EndpointHandlerMapping mapping = new EndpointHandlerMapping(endpoints,
            corsConfiguration);
    boolean disabled = this.managementServerProperties.getPort() != null
            && this.managementServerProperties.getPort() == -1;
    mapping.setDisabled(disabled);
    if (!disabled) {
        mapping.setPrefix(this.managementServerProperties.getContextPath());
    }
    if (this.mappingCustomizers != null) {
        for (EndpointHandlerMappingCustomizer customizer : this.mappingCustomizers) {
            customizer.customize(mapping);
        }
    }
    return mapping;
}
项目:contestparser    文件:ManagementWebSecurityAutoConfiguration.java   
protected final EndpointHandlerMapping getRequiredEndpointHandlerMapping() {
    if (this.endpointHandlerMapping == null) {
        ApplicationContext context = (this.contextResolver == null ? null
                : this.contextResolver.getApplicationContext());
        if (context != null && context
                .getBeanNamesForType(EndpointHandlerMapping.class).length > 0) {
            this.endpointHandlerMapping = context
                    .getBean(EndpointHandlerMapping.class);
        }
        if (this.endpointHandlerMapping == null) {
            this.endpointHandlerMapping = new EndpointHandlerMapping(
                    Collections.<MvcEndpoint>emptySet());
        }
    }
    return this.endpointHandlerMapping;
}
项目:contestparser    文件:ManagementWebSecurityAutoConfiguration.java   
public String[] getPaths(EndpointHandlerMapping endpointHandlerMapping) {
    if (endpointHandlerMapping == null) {
        return NO_PATHS;
    }
    Set<? extends MvcEndpoint> endpoints = endpointHandlerMapping.getEndpoints();
    Set<String> paths = new LinkedHashSet<String>(endpoints.size());
    for (MvcEndpoint endpoint : endpoints) {
        if (isIncluded(endpoint)) {
            String path = endpointHandlerMapping.getPath(endpoint.getPath());
            paths.add(path);
            if (!path.equals("")) {
                if (endpoint.isSensitive()) {
                    // Ensure that nested paths are secured
                    paths.add(path + "/**");
                    // Add Spring MVC-generated additional paths
                    paths.add(path + ".*");
                }
            }
            paths.add(path + "/");
        }
    }
    return paths.toArray(new String[paths.size()]);
}
项目:contestparser    文件:EndpointWebMvcManagementContextConfiguration.java   
@Bean
@ConditionalOnMissingBean
public EndpointHandlerMapping endpointHandlerMapping() {
    Set<? extends MvcEndpoint> endpoints = mvcEndpoints().getEndpoints();
    CorsConfiguration corsConfiguration = getCorsConfiguration(this.corsProperties);
    EndpointHandlerMapping mapping = new EndpointHandlerMapping(endpoints,
            corsConfiguration);
    boolean disabled = this.managementServerProperties.getPort() != null
            && this.managementServerProperties.getPort() == -1;
    mapping.setDisabled(disabled);
    if (!disabled) {
        mapping.setPrefix(this.managementServerProperties.getContextPath());
    }
    if (this.mappingCustomizers != null) {
        for (EndpointHandlerMappingCustomizer customizer : this.mappingCustomizers) {
            customizer.customize(mapping);
        }
    }
    return mapping;
}
项目:cas-5.1.0    文件:CasReportsConfiguration.java   
@Profile("standalone")
@ConditionalOnBean(name = "configurationPropertiesEnvironmentManager")
@Bean
@RefreshScope
public MvcEndpoint internalConfigController() {
    return new ConfigurationStateController(casProperties);
}
项目:cas-5.1.0    文件:CasReportsConfiguration.java   
@Autowired
@Bean
@RefreshScope
public MvcEndpoint statisticsController(@Qualifier("auditTrailManager") final DelegatingAuditTrailManager auditTrailManager) {
    return new StatisticsController(auditTrailManager, centralAuthenticationService,
            metricsRegistry, healthCheckRegistry, casProperties);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:LinksEnhancer.java   
public void addEndpointLinks(ResourceSupport resource, String self) {
    if (!resource.hasLink("self")) {
        resource.add(linkTo(LinksEnhancer.class).slash(this.rootPath + self)
                .withSelfRel());
    }
    Set<String> added = new HashSet<String>();
    for (MvcEndpoint endpoint : this.endpoints.getEndpoints()) {
        if (!endpoint.getPath().equals(self) && !added.contains(endpoint.getPath())) {
            addEndpointLink(resource, endpoint);
        }
        added.add(endpoint.getPath());
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:LinksEnhancer.java   
private void addEndpointLink(ResourceSupport resource, MvcEndpoint endpoint) {
    Class<?> type = endpoint.getEndpointType();
    type = (type == null ? Object.class : type);
    String path = endpoint.getPath();
    String rel = (path.startsWith("/") ? path.substring(1) : path);
    if (StringUtils.hasText(rel)) {
        String fullPath = this.rootPath + endpoint.getPath();
        resource.add(linkTo(type).slash(fullPath).withRel(rel));
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void endpointsDefaultConfiguration() throws Exception {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    // /health, /metrics, /env, /actuator, /heapdump (/shutdown is disabled by default)
    assertThat(this.applicationContext.getBeansOfType(MvcEndpoint.class)).hasSize(5);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void endpointsAllDisabled() throws Exception {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "ENDPOINTS_ENABLED:false");
    this.applicationContext.refresh();
    assertThat(this.applicationContext.getBeansOfType(MvcEndpoint.class)).isEmpty();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcAutoConfigurationTests.java   
private void endpointDisabled(String name, Class<? extends MvcEndpoint> type) {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            String.format("endpoints.%s.enabled:false", name));
    this.applicationContext.refresh();
    assertThat(this.applicationContext.getBeansOfType(type)).isEmpty();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcAutoConfigurationTests.java   
private void endpointEnabledOverride(String name, Class<? extends MvcEndpoint> type)
        throws Exception {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "endpoints.enabled:false",
            String.format("endpoints_%s_enabled:true", name));
    this.applicationContext.refresh();
    assertThat(this.applicationContext.getBeansOfType(type)).hasSize(1);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:MvcEndpointPathConfigurationTests.java   
private String getConfiguredPath() {
    if (MvcEndpoint.class.isAssignableFrom(this.endpointClass)) {
        return ((MvcEndpoint) this.context.getBean(this.endpointClass)).getPath();
    }
    for (MvcEndpoint endpoint : this.context.getBean(MvcEndpoints.class)
            .getEndpoints()) {
        if (endpoint instanceof EndpointMvcAdapter && this.endpointClass
                .isInstance(((EndpointMvcAdapter) endpoint).getDelegate())) {
            return ((EndpointMvcAdapter) endpoint).getPath();
        }
    }
    throw new IllegalStateException(
            "Could not get configured path for " + this.endpointClass);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointDocumentation.java   
private Collection<? extends MvcEndpoint> getEndpoints() {
    List<? extends MvcEndpoint> endpoints = new ArrayList<MvcEndpoint>(
            this.mvcEndpoints.getEndpoints());
    Collections.sort(endpoints, new Comparator<MvcEndpoint>() {
        @Override
        public int compare(MvcEndpoint o1, MvcEndpoint o2) {
            return o1.getPath().compareTo(o2.getPath());
        }
    });
    return endpoints;
}
项目:spring-boot-concourse    文件:LinksEnhancer.java   
public void addEndpointLinks(ResourceSupport resource, String self) {
    if (!resource.hasLink("self")) {
        resource.add(linkTo(LinksEnhancer.class).slash(this.rootPath + self)
                .withSelfRel());
    }
    Set<String> added = new HashSet<String>();
    for (MvcEndpoint endpoint : this.endpoints.getEndpoints()) {
        if (!endpoint.getPath().equals(self) && !added.contains(endpoint.getPath())) {
            addEndpointLink(resource, endpoint);
        }
        added.add(endpoint.getPath());
    }
}
项目:spring-boot-concourse    文件:LinksEnhancer.java   
private void addEndpointLink(ResourceSupport resource, MvcEndpoint endpoint) {
    Class<?> type = endpoint.getEndpointType();
    type = (type == null ? Object.class : type);
    String path = endpoint.getPath();
    String rel = (path.startsWith("/") ? path.substring(1) : path);
    if (StringUtils.hasText(rel)) {
        String fullPath = this.rootPath + endpoint.getPath();
        resource.add(linkTo(type).slash(fullPath).withRel(rel));
    }
}
项目:spring-boot-concourse    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void endpointsDefaultConfiguration() throws Exception {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    // /health, /metrics, /env, /actuator (/shutdown is disabled by default)
    assertThat(this.applicationContext.getBeansOfType(MvcEndpoint.class)).hasSize(4);
}
项目:spring-boot-concourse    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void endpointsAllDisabled() throws Exception {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "ENDPOINTS_ENABLED:false");
    this.applicationContext.refresh();
    assertThat(this.applicationContext.getBeansOfType(MvcEndpoint.class)).isEmpty();
}
项目:spring-boot-concourse    文件:EndpointWebMvcAutoConfigurationTests.java   
private void endpointDisabled(String name, Class<? extends MvcEndpoint> type) {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            String.format("endpoints.%s.enabled:false", name));
    this.applicationContext.refresh();
    assertThat(this.applicationContext.getBeansOfType(type)).isEmpty();
}
项目:spring-boot-concourse    文件:EndpointWebMvcAutoConfigurationTests.java   
private void endpointEnabledOverride(String name, Class<? extends MvcEndpoint> type)
        throws Exception {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "endpoints.enabled:false",
            String.format("endpoints_%s_enabled:true", name));
    this.applicationContext.refresh();
    assertThat(this.applicationContext.getBeansOfType(type)).hasSize(1);
}
项目:spring-boot-concourse    文件:MvcEndpointPathConfigurationTests.java   
private String getConfiguredPath() {
    if (MvcEndpoint.class.isAssignableFrom(this.endpointClass)) {
        return ((MvcEndpoint) this.context.getBean(this.endpointClass)).getPath();
    }
    for (MvcEndpoint endpoint : this.context.getBean(MvcEndpoints.class)
            .getEndpoints()) {
        if (endpoint instanceof EndpointMvcAdapter && this.endpointClass
                .isInstance(((EndpointMvcAdapter) endpoint).getDelegate())) {
            return ((EndpointMvcAdapter) endpoint).getPath();
        }
    }
    throw new IllegalStateException(
            "Could not get configured path for " + this.endpointClass);
}
项目:spring-boot-concourse    文件:EndpointDocumentation.java   
private Collection<? extends MvcEndpoint> getEndpoints() {
    List<? extends MvcEndpoint> endpoints = new ArrayList<MvcEndpoint>(
            this.mvcEndpoints.getEndpoints());
    Collections.sort(endpoints, new Comparator<MvcEndpoint>() {
        @Override
        public int compare(MvcEndpoint o1, MvcEndpoint o2) {
            return o1.getPath().compareTo(o2.getPath());
        }
    });
    return endpoints;
}
项目:contestparser    文件:LinksEnhancer.java   
public void addEndpointLinks(ResourceSupport resource, String self) {
    if (!resource.hasLink("self")) {
        resource.add(linkTo(LinksEnhancer.class).slash(this.rootPath + self)
                .withSelfRel());
    }
    Set<String> added = new HashSet<String>();
    for (MvcEndpoint endpoint : this.endpoints.getEndpoints()) {
        if (!endpoint.getPath().equals(self) && !added.contains(endpoint.getPath())) {
            addEndpointLink(resource, endpoint);
        }
        added.add(endpoint.getPath());
    }
}
项目:contestparser    文件:LinksEnhancer.java   
private void addEndpointLink(ResourceSupport resource, MvcEndpoint endpoint) {
    Class<?> type = endpoint.getEndpointType();
    type = (type == null ? Object.class : type);
    String path = endpoint.getPath();
    String rel = (path.startsWith("/") ? path.substring(1) : path);
    if (StringUtils.hasText(rel)) {
        String fullPath = this.rootPath + endpoint.getPath();
        resource.add(linkTo(type).slash(fullPath).withRel(rel));
    }
}
项目:contestparser    文件:ManagementContextPathHypermediaIntegrationTests.java   
@Test
public void endpointsAllListed() throws Exception {
    for (MvcEndpoint endpoint : this.mvcEndpoints.getEndpoints()) {
        String path = endpoint.getPath();
        if ("/actuator".equals(path)) {
            continue;
        }
        path = path.startsWith("/") ? path.substring(1) : path;
        path = path.length() > 0 ? path : "self";
        this.mockMvc.perform(get("/admin").accept(MediaType.APPLICATION_JSON))
                .andExpect(status().isOk())
                .andExpect(jsonPath("$._links.%s.href", path)
                        .value("http://localhost/admin" + endpoint.getPath()));
    }
}
项目:contestparser    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void endpointsDefaultConfiguration() throws Exception {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    this.applicationContext.refresh();
    // /health, /metrics, /env, /actuator (/shutdown is disabled by default)
    assertThat(this.applicationContext.getBeansOfType(MvcEndpoint.class).size(),
            is(equalTo(4)));
}
项目:contestparser    文件:EndpointWebMvcAutoConfigurationTests.java   
@Test
public void endpointsAllDisabled() throws Exception {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "ENDPOINTS_ENABLED:false");
    this.applicationContext.refresh();
    assertThat(this.applicationContext.getBeansOfType(MvcEndpoint.class).size(),
            is(equalTo(0)));
}
项目:contestparser    文件:EndpointWebMvcAutoConfigurationTests.java   
private void endpointDisabled(String name, Class<? extends MvcEndpoint> type) {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            String.format("endpoints.%s.enabled:false", name));
    this.applicationContext.refresh();
    assertThat(this.applicationContext.getBeansOfType(type).size(), is(equalTo(0)));
}
项目:contestparser    文件:EndpointWebMvcAutoConfigurationTests.java   
private void endpointEnabledOverride(String name, Class<? extends MvcEndpoint> type)
        throws Exception {
    this.applicationContext.register(RootConfig.class, BaseConfiguration.class,
            ServerPortConfig.class, EndpointWebMvcAutoConfiguration.class);
    EnvironmentTestUtils.addEnvironment(this.applicationContext,
            "endpoints.enabled:false",
            String.format("endpoints_%s_enabled:true", name));
    this.applicationContext.refresh();
    assertThat(this.applicationContext.getBeansOfType(type).size(), is(equalTo(1)));
}
项目:contestparser    文件:VanillaHypermediaIntegrationTests.java   
@Test
public void endpointsAllListed() throws Exception {
    for (MvcEndpoint endpoint : this.mvcEndpoints.getEndpoints()) {
        String path = endpoint.getPath();
        if ("/actuator".equals(path)) {
            continue;
        }
        path = path.startsWith("/") ? path.substring(1) : path;
        this.mockMvc.perform(get("/actuator").accept(MediaType.APPLICATION_JSON))
                .andExpect(status().isOk())
                .andExpect(jsonPath("$._links.%s.href", path).exists());
    }
}
项目:contestparser    文件:VanillaHypermediaIntegrationTests.java   
@Test
public void endpointsEachHaveSelf() throws Exception {
    for (MvcEndpoint endpoint : this.mvcEndpoints.getEndpoints()) {
        String path = endpoint.getPath();
        path = path.length() > 0 ? path : "/";
        this.mockMvc.perform(get(path).accept(MediaType.APPLICATION_JSON))
                .andExpect(status().isOk()).andExpect(jsonPath("$._links.self.href")
                        .value("http://localhost" + endpoint.getPath()));
    }
}
项目:contestparser    文件:EndpointDocumentation.java   
private Collection<? extends MvcEndpoint> getEndpoints() {
    List<? extends MvcEndpoint> endpoints = new ArrayList<MvcEndpoint>(
            this.mvcEndpoints.getEndpoints());
    Collections.sort(endpoints, new Comparator<MvcEndpoint>() {
        @Override
        public int compare(MvcEndpoint o1, MvcEndpoint o2) {
            return o1.getPath().compareTo(o2.getPath());
        }
    });
    return endpoints;
}
项目:cas-5.1.0    文件:CasReportsConfiguration.java   
@Bean
@RefreshScope
public MvcEndpoint dashboardController() {
    return new DashboardController(casProperties);
}
项目:cas-5.1.0    文件:CasReportsConfiguration.java   
@Bean
@RefreshScope
public MvcEndpoint personDirectoryAttributeResolutionController() {
    return new PersonDirectoryAttributeResolutionController(casProperties);
}
项目:cas-5.1.0    文件:CasReportsConfiguration.java   
@Bean
@RefreshScope
public MvcEndpoint healthCheckController() {
    return new HealthCheckController(healthCheckMonitor, casProperties);
}
项目:cas-5.1.0    文件:CasReportsConfiguration.java   
@Bean
@RefreshScope
public MvcEndpoint singleSignOnSessionsReportController() {
    return new SingleSignOnSessionsReportController(centralAuthenticationService, casProperties);
}
项目:cas-5.1.0    文件:CasReportsConfiguration.java   
@Bean
@RefreshScope
@Autowired
public MvcEndpoint loggingConfigController(@Qualifier("auditTrailManager") final DelegatingAuditTrailManager auditTrailManager) {
    return new LoggingConfigController(auditTrailManager, casProperties);
}