// Path: druid-spring-boot-actuator/druid-spring-boot-actuator-autoconfigure/src/main/java/com/github/trang/druid/actuate/DruidDataSourceEndpoint.java
// @ConfigurationProperties(prefix = "endpoints.druid")
// public class DruidDataSourceEndpoint extends AbstractEndpoint<List<Map<String, Object>>> {
// 
//     public DruidDataSourceEndpoint() {
//         super("druid");
//     }
// 
//     private static final DruidStatManagerFacade STAT_MANAGER = DruidStatManagerFacade.getInstance();
// 
//     @Override
//     public List<Map<String, Object>> invoke() {
//         return STAT_MANAGER.getDataSourceStatDataList();
//     }
// 
// }
// 
// Path: druid-spring-boot-actuator/druid-spring-boot-actuator-autoconfigure/src/main/java/com/github/trang/druid/actuate/DruidDataSourceMvcEndpoint.java
// @ConfigurationProperties(prefix = "endpoints.druid")
// public class DruidDataSourceMvcEndpoint extends EndpointMvcAdapter {
// 
//     private static final DruidStatService statService = DruidStatService.getInstance();
// 
//     private final long timeout;
//     private final Lock lock = new ReentrantLock();
// 
//     public DruidDataSourceMvcEndpoint(DruidDataSourceEndpoint delegate) {
//         super(delegate);
//         this.timeout = TimeUnit.SECONDS.toMillis(10);
//     }
// 
//     public DruidDataSourceMvcEndpoint(DruidDataSourceEndpoint delegate, long timeout) {
//         super(delegate);
//         this.timeout = timeout;
//     }
// 
//     @GetMapping(value = "/{name:.*}", produces = {ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
//             MediaType.APPLICATION_JSON_VALUE})
//     @ResponseBody
//     @HypermediaDisabled
//     public String handle(@PathVariable String name) {
//         String temp = name;
//         if (name.contains(".")) {
//             temp = name.substring(0, name.indexOf("."));
//         }
//         name = "/" + temp + ".json";
//         return statService.service(name);
//     }
// 
// }


import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.github.trang.druid.actuate.DruidDataSourceEndpoint;
import com.github.trang.druid.actuate.DruidDataSourceMvcEndpoint;
package com.github.trang.druid.actuate.autoconfigure;



/**
 * Druid Endpoint & Druid MvcEndpoint 自动配置，默认开启
 *
 * @author trang
 */
@Configuration
@ConditionalOnProperty(prefix = "endpoints.druid", name = "enabled", havingValue = "true", matchIfMissing = true)
public class DruidDataSourceEndpointConfiguration {

    @Bean
    @ConditionalOnMissingBean
// Path: druid-spring-boot-actuator/druid-spring-boot-actuator-autoconfigure/src/main/java/com/github/trang/druid/actuate/DruidDataSourceEndpoint.java
// @ConfigurationProperties(prefix = "endpoints.druid")
// public class DruidDataSourceEndpoint extends AbstractEndpoint<List<Map<String, Object>>> {
// 
//     public DruidDataSourceEndpoint() {
//         super("druid");
//     }
// 
//     private static final DruidStatManagerFacade STAT_MANAGER = DruidStatManagerFacade.getInstance();
// 
//     @Override
//     public List<Map<String, Object>> invoke() {
//         return STAT_MANAGER.getDataSourceStatDataList();
//     }
// 
// }
// 
// Path: druid-spring-boot-actuator/druid-spring-boot-actuator-autoconfigure/src/main/java/com/github/trang/druid/actuate/DruidDataSourceMvcEndpoint.java
// @ConfigurationProperties(prefix = "endpoints.druid")
// public class DruidDataSourceMvcEndpoint extends EndpointMvcAdapter {
// 
//     private static final DruidStatService statService = DruidStatService.getInstance();
// 
//     private final long timeout;
//     private final Lock lock = new ReentrantLock();
// 
//     public DruidDataSourceMvcEndpoint(DruidDataSourceEndpoint delegate) {
//         super(delegate);
//         this.timeout = TimeUnit.SECONDS.toMillis(10);
//     }
// 
//     public DruidDataSourceMvcEndpoint(DruidDataSourceEndpoint delegate, long timeout) {
//         super(delegate);
//         this.timeout = timeout;
//     }
// 
//     @GetMapping(value = "/{name:.*}", produces = {ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE,
//             MediaType.APPLICATION_JSON_VALUE})
//     @ResponseBody
//     @HypermediaDisabled
//     public String handle(@PathVariable String name) {
//         String temp = name;
//         if (name.contains(".")) {
//             temp = name.substring(0, name.indexOf("."));
//         }
//         name = "/" + temp + ".json";
//         return statService.service(name);
//     }
// 
// }


// Path: druid-spring-boot-actuator/druid-spring-boot-actuator-autoconfigure/src/main/java/com/github/trang/druid/actuate/autoconfigure/DruidDataSourceEndpointConfiguration.java
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.github.trang.druid.actuate.DruidDataSourceEndpoint;
import com.github.trang.druid.actuate.DruidDataSourceMvcEndpoint;

package com.github.trang.druid.actuate.autoconfigure;



/**
 * Druid Endpoint & Druid MvcEndpoint 自动配置，默认开启
 *
 * @author trang
 */
@Configuration
@ConditionalOnProperty(prefix = "endpoints.druid", name = "enabled", havingValue = "true", matchIfMissing = true)
public class DruidDataSourceEndpointConfiguration {

    @Bean
    @ConditionalOnMissingBean
    public DruidDataSourceEndpoint druidDataSourceEndpoint() {