// Path: naive-core/src/main/java/com/goribun/naive/core/constants/Const.java
// public class Const {
// 
//     //扫描rpc服务的包路径配置key
//     public static final String SCAN_PACKAGE_KEY_ = "scanPackage";
// 
//     public static final String IS_TRACE_STACK = "isTraceStack";
// 
//     //日期格式
//     public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss SSS";
// 
// 
// }
// 
// Path: naive-core/src/main/java/com/goribun/naive/core/utils/PropertyUtil.java
// public class PropertyUtil {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(PropertyUtil.class);
// 
//     private static Properties props;
// 
//     static {
//         loadProps();
//     }
// 
//     synchronized static private void loadProps() {
// 
//         props = new Properties();
//         InputStream in = null;
//         try {
//             in = PropertyUtil.class.getClassLoader().getResourceAsStream("naive-rpc.properties");
//             props.load(in);
//         } catch (FileNotFoundException e) {
//             LOGGER.warn("naive-rpc.properties not found");
//         } catch (IOException e) {
//             LOGGER.error("loadProps error", e);
//         } finally {
//             try {
//                 if (null != in) {
//                     in.close();
//                 }
//             } catch (IOException e) {
//                 LOGGER.error("naive-rpc.properties close error", e);
//             }
//         }
//     }
// 
//     public static String getProperty(String key) {
//         if (null == props) {
//             loadProps();
//         }
//         return props.getProperty(key);
//     }
// 
//     public static String getProperty(String key, String defaultValue) {
//         if (null == props) {
//             loadProps();
//         }
//         return props.getProperty(key, defaultValue);
//     }
// 
//     public static boolean getBooleanProperty(String key, boolean defaultValue) {
//         if (null == props) {
//             loadProps();
//         }
// 
//         try {
//             return Boolean.valueOf(props.getProperty(key));
//         } catch (Exception e) {
//             return defaultValue;
//         }
//     }
// }


import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.goribun.naive.core.annotation.RpcService;
import com.goribun.naive.core.constants.Const;
import com.goribun.naive.core.utils.PropertyUtil;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.SystemPropertyUtils;
package com.goribun.naive.server.utils;



/**
 * 类扫描工具
 * <p>
 * 可以指定包路径和注解
 *
 * @author wangxuesong
 * @version 1.0
 */
public class RPCServiceScanner {

    private RPCServiceScanner() {
    }

    //默认包扫描路径
    private static final String DEFAULT_SCAN_PACKAGE = "cn.wangxs.crm.service.*";

    public static List<Class<?>> scan() {

        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        MetadataReaderFactory readerFactory = new SimpleMetadataReaderFactory();

        //优先取得自定义配置
// Path: naive-core/src/main/java/com/goribun/naive/core/constants/Const.java
// public class Const {
// 
//     //扫描rpc服务的包路径配置key
//     public static final String SCAN_PACKAGE_KEY_ = "scanPackage";
// 
//     public static final String IS_TRACE_STACK = "isTraceStack";
// 
//     //日期格式
//     public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss SSS";
// 
// 
// }
// 
// Path: naive-core/src/main/java/com/goribun/naive/core/utils/PropertyUtil.java
// public class PropertyUtil {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(PropertyUtil.class);
// 
//     private static Properties props;
// 
//     static {
//         loadProps();
//     }
// 
//     synchronized static private void loadProps() {
// 
//         props = new Properties();
//         InputStream in = null;
//         try {
//             in = PropertyUtil.class.getClassLoader().getResourceAsStream("naive-rpc.properties");
//             props.load(in);
//         } catch (FileNotFoundException e) {
//             LOGGER.warn("naive-rpc.properties not found");
//         } catch (IOException e) {
//             LOGGER.error("loadProps error", e);
//         } finally {
//             try {
//                 if (null != in) {
//                     in.close();
//                 }
//             } catch (IOException e) {
//                 LOGGER.error("naive-rpc.properties close error", e);
//             }
//         }
//     }
// 
//     public static String getProperty(String key) {
//         if (null == props) {
//             loadProps();
//         }
//         return props.getProperty(key);
//     }
// 
//     public static String getProperty(String key, String defaultValue) {
//         if (null == props) {
//             loadProps();
//         }
//         return props.getProperty(key, defaultValue);
//     }
// 
//     public static boolean getBooleanProperty(String key, boolean defaultValue) {
//         if (null == props) {
//             loadProps();
//         }
// 
//         try {
//             return Boolean.valueOf(props.getProperty(key));
//         } catch (Exception e) {
//             return defaultValue;
//         }
//     }
// }


// Path: naive-server/src/main/java/com/goribun/naive/server/utils/RPCServiceScanner.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import com.goribun.naive.core.annotation.RpcService;
import com.goribun.naive.core.constants.Const;
import com.goribun.naive.core.utils.PropertyUtil;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.core.type.classreading.MetadataReaderFactory;
import org.springframework.core.type.classreading.SimpleMetadataReaderFactory;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.SystemPropertyUtils;

package com.goribun.naive.server.utils;



/**
 * 类扫描工具
 * <p>
 * 可以指定包路径和注解
 *
 * @author wangxuesong
 * @version 1.0
 */
public class RPCServiceScanner {

    private RPCServiceScanner() {
    }

    //默认包扫描路径
    private static final String DEFAULT_SCAN_PACKAGE = "cn.wangxs.crm.service.*";

    public static List<Class<?>> scan() {

        PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
        MetadataReaderFactory readerFactory = new SimpleMetadataReaderFactory();

        //优先取得自定义配置
        String pkgString = PropertyUtil.getProperty(Const.SCAN_PACKAGE_KEY_, DEFAULT_SCAN_PACKAGE);