- java.lang.Object
-
- org.redkale.net.sncp.Sncp
-
public abstract class Sncp extends Object
Service Node Communicate Protocol 生成Service的本地模式或远程模式Service-Class的工具类详情见: https://redkale.org
- 作者:
- zhangjx
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 static interface
Sncp.SncpDyn
修饰由SNCP协议动态生成的class、和method 本地模式:动态生成的_DynLocalXXXXService类会打上@SncpDyn(remote = false) 的注解 远程模式:动态生成的_DynRemoteXXXService类会打上@SncpDyn(remote = true) 的注解
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static Uint128
actionid(Method method)
static Uint128
actionid(RpcAction action)
static <T extends Service>
TcreateLocalService(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实例protected static <T extends Service>
Class<? extends T>createLocalServiceClass(RedkaleClassLoader.DynBytesClassLoader dynLoader, String name, Class<T> serviceImplClass, org.redkale.asm.AsmMethodBoost methodBoost)
static <T extends Service>
TcreateRemoteService(ClassLoader classLoader, String name, Class<T> serviceTypeOrImplClass, org.redkale.asm.AsmMethodBoost methodBoost, ResourceFactory resourceFactory, SncpRpcGroups sncpRpcGroups, SncpClient client, MessageAgent agent, String remoteGroup, AnyValue conf)
static <T extends Service>
TcreateSimpleLocalService(Class<T> serviceImplClass, ResourceFactory resourceFactory)
static <T extends Service>
TcreateSimpleRemoteService(Class<T> serviceImplClass, ResourceFactory resourceFactory, SncpRpcGroups sncpRpcGroups, SncpClient client, String group)
static <T extends Service>
SncpRemoteInfocreateSncpRemoteInfo(String resourceName, Class<T> resourceServiceType, Class<T> serviceImplClass, ProtobufConvert convert, SncpRpcGroups sncpRpcGroups, SncpClient sncpClient, MessageAgent messageAgent, String remoteGroup)
static String
generateSncpReqTopic(String resourceName, Class resourceType, String nodeid)
static String
generateSncpReqTopic(Service service, String nodeid)
static AnyValue
getResourceConf(Service service)
static String
getResourceMQ(Service service)
static String
getResourceName(Service service)
static <T extends Service>
ClassgetResourceType(Class<T> serviceImplClass)
static Class
getResourceType(Service service)
static <T extends Service>
ClassgetServiceType(Class<T> serviceImplClass)
static Class
getServiceType(Service service)
static String
getSncpReqTopicPrefix()
static String
getSncpRespTopicPrefix()
static int
getVersion(Service service)
static boolean
isComponent(Class serviceType)
static boolean
isComponent(Service service)
static boolean
isRemote(Service service)
static boolean
isSncpDyn(Class serviceType)
static boolean
isSncpDyn(Service service)
static List<Method>
loadNotImplMethods(Class clazz)
static LinkedHashMap<Uint128,Method>
loadRemoteMethodActions(Class serviceTypeOrImplClass)
static String
resourceid(String resourceName, Class resourceType)
格式:资源类型:资源名static Uint128
serviceid(String serviceResourceName, Class serviceResourceType)
static String
toSimpleString(Service service, int maxNameLength, int maxTypeLength)
-
-
-
方法详细资料
-
loadRemoteMethodActions
public static LinkedHashMap<Uint128,Method> loadRemoteMethodActions(Class serviceTypeOrImplClass)
-
createSncpRemoteInfo
public static <T extends Service> SncpRemoteInfo createSncpRemoteInfo(String resourceName, Class<T> resourceServiceType, Class<T> serviceImplClass, ProtobufConvert convert, SncpRpcGroups sncpRpcGroups, SncpClient sncpClient, MessageAgent messageAgent, String remoteGroup)
-
resourceid
public static String resourceid(String resourceName, Class resourceType)
格式:资源类型:资源名- 参数:
resourceName
- 资源名resourceType
- 资源类型- 返回:
- resourceid
-
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)
-
generateSncpReqTopic
public static String generateSncpReqTopic(String resourceName, Class resourceType, String nodeid)
-
getSncpReqTopicPrefix
public static String getSncpReqTopicPrefix()
-
getSncpRespTopicPrefix
public static String getSncpRespTopicPrefix()
-
toSimpleString
public static String toSimpleString(Service service, int maxNameLength, int maxTypeLength)
-
createLocalServiceClass
protected static <T extends Service> Class<? 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; }
- 类型参数:
T
- Service子类- 参数:
dynLoader
- DynBytesClassLoadername
- 资源名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
- ClassLoadername
- 资源名serviceImplClass
- Service类methodBoost
- 方法扩展resourceFactory
- ResourceFactorysncpRpcGroups
- SncpRpcGroupsclient
- SncpClientagent
- MessageAgentremoteGroup
- 所有的组节点conf
- 启动配置项- 返回:
- Service的本地模式实例
-
createSimpleRemoteService
public static <T extends Service> T createSimpleRemoteService(Class<T> serviceImplClass, ResourceFactory resourceFactory, SncpRpcGroups sncpRpcGroups, SncpClient client, String group)
-
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); } }
- 类型参数:
T
- Service泛型- 参数:
classLoader
- ClassLoadername
- 资源名serviceTypeOrImplClass
- Service类methodBoost
- 方法扩展resourceFactory
- ResourceFactorysncpRpcGroups
- SncpRpcGroupsclient
- SncpClientagent
- MessageAgentremoteGroup
- 所有的组节点conf
- 启动配置项- 返回:
- Service的远程模式实例
-
-