Search in sources :

Example 1 with Service

use of com.duangframework.core.annotation.mvc.Service in project duangframework by tcrct.

the class AutoBuildServiceInterface method createBatchInterface.

/**
 *  批量创建Service类接口文件到指定目录下
 * @param interFaceDirPath      存放RPC接口文件的目录
 * @param  customizeDir           自定义目录
 * @return
 * @throws Exception
 */
public static boolean createBatchInterface(String interFaceDirPath, String customizeDir) throws Exception {
    Map<Class<?>, Object> serviceMap = BeanUtils.getAllBeanMaps().get(Service.class.getSimpleName());
    if (ToolsKit.isEmpty(serviceMap)) {
        throw new EmptyNullException("serviceMap is null");
    }
    try {
        for (Iterator<Class<?>> iterator = serviceMap.keySet().iterator(); iterator.hasNext(); ) {
            Class<?> clazz = iterator.next();
            String packagePath = RpcUtils.getRpcPackagePath(customizeDir);
            createInterface(clazz, interFaceDirPath, packagePath);
        }
        return true;
    } catch (Exception e) {
        logger.warn(e.getMessage(), e);
        throw new RpcException("batch create service interface is fail: " + e.getMessage(), e);
    }
}
Also used : EmptyNullException(com.duangframework.core.exceptions.EmptyNullException) RpcException(com.duangframework.core.exceptions.RpcException) Service(com.duangframework.core.annotation.mvc.Service) CtClass(javassist.CtClass) RpcException(com.duangframework.core.exceptions.RpcException) NotFoundException(javassist.NotFoundException) EmptyNullException(com.duangframework.core.exceptions.EmptyNullException)

Aggregations

Service (com.duangframework.core.annotation.mvc.Service)1 EmptyNullException (com.duangframework.core.exceptions.EmptyNullException)1 RpcException (com.duangframework.core.exceptions.RpcException)1 CtClass (javassist.CtClass)1 NotFoundException (javassist.NotFoundException)1