模块 org.redkale

类 Sncp


  • public abstract class Sncp
    extends Object
    Service Node Communicate Protocol 生成Service的本地模式或远程模式Service-Class的工具类

    详情见: https://redkale.org

    作者:
    zhangjx
    • 方法详细资料

      • resourceid

        public static String resourceid​(String resourceName,
                                        Class resourceType)
        格式:资源类型:资源名
        参数:
        resourceName - 资源名
        resourceType - 资源类型
        返回:
        resourceid
      • serviceid

        public static Uint128 serviceid​(String serviceResourceName,
                                        Class serviceResourceType)
      • isRemote

        public static boolean isRemote​(Service service)
      • isSncpDyn

        public static boolean isSncpDyn​(Service service)
      • isSncpDyn

        public static boolean isSncpDyn​(Class serviceType)
      • isComponent

        public static boolean isComponent​(Service service)
      • isComponent

        public static boolean isComponent​(Class serviceType)
      • getVersion

        public static int getVersion​(Service service)
      • getResourceName

        public static String getResourceName​(Service service)
      • getResourceType

        public static Class getResourceType​(Service service)
      • getResourceType

        public static <T extends ServiceClass getResourceType​(Class<T> serviceImplClass)
      • getServiceType

        public static Class getServiceType​(Service service)
      • getServiceType

        public static <T extends ServiceClass getServiceType​(Class<T> serviceImplClass)
      • generateSncpReqTopic

        public static String generateSncpReqTopic​(Service service,
                                                  String nodeid)
      • generateSncpReqTopic

        public static String generateSncpReqTopic​(String resourceName,
                                                  Class resourceType,
                                                  String nodeid)
      • getSncpReqTopicPrefix

        public static String getSncpReqTopicPrefix()
      • getSncpRespTopicPrefix

        public static String getSncpRespTopicPrefix()
      • getResourceConf

        public static AnyValue getResourceConf​(Service service)
      • getResourceMQ

        public static String getResourceMQ​(Service service)
      • toSimpleString

        public static String toSimpleString​(Service service,
                                            int maxNameLength,
                                            int maxTypeLength)
      • loadNotImplMethods

        public static List<Method> loadNotImplMethods​(Class clazz)
      • createLocalServiceClass

        protected static <T extends ServiceClass<? extends T> createLocalServiceClass​(RedkaleClassLoader.DynBytesClassLoader dynLoader,
                                                                                        String name,
                                                                                        Class<T> serviceImplClass,
                                                                                        org.redkale.asm.AsmMethodBoost methodBoost)
         public class TestService implements Service {
        
              public String findSomeThing(){
                  return "hello";
              }
        
              @RpcMultiRun(selfrun = false)
              public void createSomeThing(TestBean bean){
                  //do something
              }
        
              @RpcMultiRun
              public String updateSomeThing(String id){
                  return "hello" + id;
              }
         }
         
         @Resource(name = "")
         @SncpDyn(remote = false)
         @ResourceType(TestService.class)
         public final class _DynLocalTestService extends TestService {
        
              private AnyValue _redkale_conf;
        
         }
         
        创建Service的本地模式Class
        类型参数:
        T - Service子类
        参数:
        dynLoader - DynBytesClassLoader
        name - 资源名
        serviceImplClass - Service类
        methodBoost - 方法扩展
        返回:
        Service实例
      • createSimpleLocalService

        public static <T extends Service> T createSimpleLocalService​(Class<T> serviceImplClass,
                                                                     ResourceFactory resourceFactory)
      • createLocalService

        public static <T extends Service> T createLocalService​(RedkaleClassLoader classLoader,
                                                               String name,
                                                               Class<T> serviceImplClass,
                                                               org.redkale.asm.AsmMethodBoost methodBoost,
                                                               ResourceFactory resourceFactory,
                                                               SncpRpcGroups sncpRpcGroups,
                                                               SncpClient client,
                                                               MessageAgent agent,
                                                               String remoteGroup,
                                                               AnyValue conf)
        创建本地模式Service实例
        类型参数:
        T - Service泛型
        参数:
        classLoader - ClassLoader
        name - 资源名
        serviceImplClass - Service类
        methodBoost - 方法扩展
        resourceFactory - ResourceFactory
        sncpRpcGroups - SncpRpcGroups
        client - SncpClient
        agent - MessageAgent
        remoteGroup - 所有的组节点
        conf - 启动配置项
        返回:
        Service的本地模式实例
      • createRemoteService

        public static <T extends Service> T createRemoteService​(ClassLoader classLoader,
                                                                String name,
                                                                Class<T> serviceTypeOrImplClass,
                                                                org.redkale.asm.AsmMethodBoost methodBoost,
                                                                ResourceFactory resourceFactory,
                                                                SncpRpcGroups sncpRpcGroups,
                                                                SncpClient client,
                                                                MessageAgent agent,
                                                                String remoteGroup,
                                                                AnyValue conf)
         @Resource(name = "")
         @SncpDyn(remote = true)
         @ResourceType(TestService.class)
         public final class _DynRemoteTestService extends TestService {
        
              private AnyValue _redkale_conf;
        
              private SncpClient _redkale_client;
        
              private SncpRemoteInfo _redkale_sncp;
        
              @Override
              public void createSomeThing(TestBean bean){
                  _redkale_client.remote(_redkale_sncp, 0, bean);
              }
        
              @Override
              public String findSomeThing(){
                  return (String)_redkale_client.remote(_redkale_sncp, 1);
              }
        
              @Override
              public String updateSomeThing(String id){
                  return (String)_redkale_client.remote(_redkale_sncp, 2, id);
              }
         }
         
        创建远程模式的Service实例
        类型参数:
        T - Service泛型
        参数:
        classLoader - ClassLoader
        name - 资源名
        serviceTypeOrImplClass - Service类
        methodBoost - 方法扩展
        resourceFactory - ResourceFactory
        sncpRpcGroups - SncpRpcGroups
        client - SncpClient
        agent - MessageAgent
        remoteGroup - 所有的组节点
        conf - 启动配置项
        返回:
        Service的远程模式实例