• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FastClass类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.cglib.reflect.FastClass的典型用法代码示例。如果您正苦于以下问题:Java FastClass类的具体用法?Java FastClass怎么用?Java FastClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FastClass类属于org.springframework.cglib.reflect包,在下文中一共展示了FastClass类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: invokeService

import org.springframework.cglib.reflect.FastClass; //导入依赖的package包/类
public static RpcResponse invokeService(RpcRequest request, Object serviceBean) {
	if (serviceBean==null) {
		serviceBean = serviceMap.get(request.getClassName());
	}
	if (serviceBean == null) {
		// TODO
	}

	RpcResponse response = new RpcResponse();

	if (System.currentTimeMillis() - request.getCreateMillisTime() > 180000) {
		response.setResult(new ReturnT<String>(ReturnT.FAIL_CODE, "The timestamp difference between admin and executor exceeds the limit."));
		return response;
	}
	if (accessToken!=null && accessToken.trim().length()>0 && !accessToken.trim().equals(request.getAccessToken())) {
		response.setResult(new ReturnT<String>(ReturnT.FAIL_CODE, "The access token[" + request.getAccessToken() + "] is wrong."));
		return response;
	}

	try {
		Class<?> serviceClass = serviceBean.getClass();
		String methodName = request.getMethodName();
		Class<?>[] parameterTypes = request.getParameterTypes();
		Object[] parameters = request.getParameters();

		FastClass serviceFastClass = FastClass.create(serviceClass);
		FastMethod serviceFastMethod = serviceFastClass.getMethod(methodName, parameterTypes);

		Object result = serviceFastMethod.invoke(serviceBean, parameters);

		response.setResult(result);
	} catch (Throwable t) {
		t.printStackTrace();
		response.setError(t.getMessage());
	}

	return response;
}
 
开发者ID:mmwhd,项目名称:stage-job,代码行数:39,代码来源:NetComServerFactory.java


示例2: invokeService

import org.springframework.cglib.reflect.FastClass; //导入依赖的package包/类
/**
 *@description 远程RPC调用
 *@time 创建时间:2017年7月28日下午5:03:27
 *@param request
 *@param serviceBean
 *@return
 *@author dzn
 */
public static RpcResponse invokeService(RpcRequest request) {
    RpcResponse response = new RpcResponse();
    //动态调用某个对象的指定方法
    try {
        //获取请求调用的接口实例
        String serviceInterfaceName = request.getClassName();
        Object serviceInstance = serviceMap.get(serviceInterfaceName);
        
        //获取接口实例的FastClass对象
        Class<?> serviceInstanceClass = serviceInstance.getClass();
        FastClass serviceFastClass = FastClass.create(serviceInstanceClass);
        
        //获取远程调用的方法
        String methodName = request.getMethodName();
        Class<?>[] parameterTypes = request.getParameterTypes();
        FastMethod serviceFastMethod = serviceFastClass.getMethod(methodName, parameterTypes);
        
        //调用指定的方法
        Object[] parameters = request.getParameters();
        Object result = serviceFastMethod.invoke(serviceInstance, parameters);

        response.setResult(result);
    } catch (Throwable t) {
        t.printStackTrace();
        response.setError(t.getMessage());
    }
    return response;
}
 
开发者ID:SnailFastGo,项目名称:netty_op,代码行数:37,代码来源:JettyServerHandler.java


示例3: invokeService

import org.springframework.cglib.reflect.FastClass; //导入依赖的package包/类
public static RpcResponse invokeService(RpcRequest request, Object serviceBean) {
	if (serviceBean==null) {
		serviceBean = serviceMap.get(request.getClassName());
	}
	if (serviceBean == null) {
		// TODO
	}

	RpcResponse response = new RpcResponse();

	if (System.currentTimeMillis() - request.getCreateMillisTime() > 180000) {
		response.setResult(new ReturnT<String>(ReturnT.FAIL_CODE, "the timestamp difference between admin and executor exceeds the limit."));
		return response;
	}

	try {
		Class<?> serviceClass = serviceBean.getClass();
		String methodName = request.getMethodName();
		Class<?>[] parameterTypes = request.getParameterTypes();
		Object[] parameters = request.getParameters();

		FastClass serviceFastClass = FastClass.create(serviceClass);
		FastMethod serviceFastMethod = serviceFastClass.getMethod(methodName, parameterTypes);

		Object result = serviceFastMethod.invoke(serviceBean, parameters);

		response.setResult(result);
	} catch (Throwable t) {
		t.printStackTrace();
		response.setError(t.getMessage());
	}

	return response;
}
 
开发者ID:kevinKaiF,项目名称:xxl-job,代码行数:35,代码来源:NetComServerFactory.java


示例4: BeanAbstractFieldValidator

import org.springframework.cglib.reflect.FastClass; //导入依赖的package包/类
public BeanAbstractFieldValidator(Class<?> clazz, ValidateField... validateFields) {
    super(validateFields);
    this.clazz = clazz;
    this.fastClass = FastClass.create(clazz);
    try {
        init();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:wxz1211,项目名称:dooo,代码行数:11,代码来源:BeanAbstractFieldValidator.java


示例5: parse

import org.springframework.cglib.reflect.FastClass; //导入依赖的package包/类
private void parse(Action action) {
    Class clazz = action.getClass();
    FastClass fastClass = FastClass.create(clazz);
    for (Method method : clazz.getDeclaredMethods()) {
        InterfaceTarget interfaceTarget = method.getAnnotation(InterfaceTarget.class);
        if (interfaceTarget == null) {
            continue;
        }
        String interfaceKey = interfaceTarget.path() + "_" + interfaceTarget.version();
        InterfaceHandler interfaceHandler = new InterfaceHandler(interfaceKey, action, method, fastClass.getMethod(method));

        // 返回表示按照声明顺序对此 Method对象所表示方法的形参进行注释的那个数组的数组。
        String[] parameterNames = parameterNameDiscoverer.getParameterNames(method);
        Class<?>[] parameterTypes = method.getParameterTypes();
        Annotation[][] parameterAnnotations = method.getParameterAnnotations();
        Preconditions.checkArgument(parameterNames.length == parameterTypes.length);
        Preconditions.checkArgument(parameterNames.length == parameterAnnotations.length);
        int parameterCount = parameterTypes.length;
        for (int i = 0; i < parameterCount; i++) {
            Annotation[] annotations = parameterAnnotations[i];
            Class<?> parameterClazz = parameterTypes[i];
            String parameterName = parameterNames[i];
            resolveParameter(parameterName, parameterClazz, annotations, interfaceHandler);
        }

        LOGGER.info("path {} ,handle {}", interfaceKey, interfaceHandler);
        interfaceHandlerHashMap.put(interfaceKey, interfaceHandler);
    }
}
 
开发者ID:wxz1211,项目名称:dooo,代码行数:30,代码来源:SpringContainer.java


示例6: invoke

import org.springframework.cglib.reflect.FastClass; //导入依赖的package包/类
public static void invoke(Object targetObject, Method method, Object[] objects) {
    final Class<?> clazz = targetObject.getClass();
    final FastClass fastClass = FastClass.create(clazz);
    try {
        fastClass.getMethod(method).invoke(targetObject, objects);
    } catch (InvocationTargetException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:KoperGroup,项目名称:koper,代码行数:10,代码来源:ReflectUtil.java


示例7: helper

import org.springframework.cglib.reflect.FastClass; //导入依赖的package包/类
private static FastClass helper(CreateInfo ci, Class type) {
    FastClass.Generator g = new FastClass.Generator();
    g.setType(type);
    g.setClassLoader(ci.c2.getClassLoader());
    g.setNamingPolicy(ci.namingPolicy);
    g.setStrategy(ci.strategy);
    g.setAttemptLoad(ci.attemptLoad);
    return g.create();
}
 
开发者ID:yngui,项目名称:jephyr,代码行数:10,代码来源:MethodProxy.java


示例8: RequestMapping

import org.springframework.cglib.reflect.FastClass; //导入依赖的package包/类
public RequestMapping(String uriPattern,
                      Object target,
                      Class<?> handlerClass,
                      Method handlerMethod,
                      String httpMethod,
                      String redirectTo) {
  this.uriPattern = uriPattern;
  this.target = target;
  this.handlerMethod = FastClass.create(handlerClass).getMethod(handlerMethod);
  this.httpMethod = httpMethod;
  this.redirectTo = redirectTo;
  init(handlerMethod);
}
 
开发者ID:orctom,项目名称:laputa,代码行数:14,代码来源:RequestMapping.java


示例9: getFastClass

import org.springframework.cglib.reflect.FastClass; //导入依赖的package包/类
FastClass getFastClass() {
  init();
  return fastClassInfo.f1;
}
 
开发者ID:yngui,项目名称:jephyr,代码行数:5,代码来源:MethodProxy.java


示例10: getSuperFastClass

import org.springframework.cglib.reflect.FastClass; //导入依赖的package包/类
FastClass getSuperFastClass() {
  init();
  return fastClassInfo.f2;
}
 
开发者ID:yngui,项目名称:jephyr,代码行数:5,代码来源:MethodProxy.java



注:本文中的org.springframework.cglib.reflect.FastClass类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StaticSentence类代码示例发布时间:2022-05-23
下一篇:
Java Node类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap