当前位置: 首页>>代码示例>>Java>>正文


Java FastClass类代码示例

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


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

示例1: getGetter

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
/**
 * Return getter for the given method and CGLIB FastClass.
 *
 * @param method              to return getter for
 * @param fastClass           is the CGLIB fast classs to make FastMethod for
 * @param eventAdapterService factory for event beans and event types
 * @return property getter
 */
public static EventPropertyGetterSPI getGetter(Method method, FastClass fastClass, EventAdapterService eventAdapterService) {
    // Get CGLib fast method handle
    FastMethod fastMethod = null;
    try {
        if (fastClass != null) {
            fastMethod = fastClass.getMethod(method);
        }
    } catch (Throwable ex) {
        log.warn(".getAccessAccessorsForges Unable to obtain CGLib fast method implementation, msg=" + ex.getMessage());
    }

    // Construct the appropriate property getter CGLib or reflect
    EventPropertyGetterSPI getter;
    if (fastMethod != null) {
        getter = new CGLibPropertyGetter(method, fastMethod, eventAdapterService);
    } else {
        getter = new ReflectionPropMethodGetter(method, eventAdapterService);
    }

    return getter;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:30,代码来源:PropertyHelper.java

示例2: handle

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
private Object handle(RpcRequest request) throws Throwable {
	String className = request.getClassName();
	Object serviceBean = handlerMap.get(className);

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

	/*
	 * Method method = serviceClass.getMethod(methodName, parameterTypes);
	 * method.setAccessible(true); return method.invoke(serviceBean,
	 * parameters);
	 */

	FastClass serviceFastClass = FastClass.create(serviceClass);
	FastMethod serviceFastMethod = serviceFastClass.getMethod(methodName, parameterTypes);
	return serviceFastMethod.invoke(serviceBean, parameters);
}
 
开发者ID:zoopaper,项目名称:rpc4j,代码行数:20,代码来源:RpcHandler.java

示例3: resolveType

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
private Class< ? > resolveType(IExpression[] exprs)
{
    //获得函数参数类型
    Class< ? >[] paramTypes = new Class[exprs.length];
    for (int i = 0; i < paramTypes.length; i++)
    {
        paramTypes[i] = exprs[i].getType();
    }
    
    //获得相应方法
    Method method = MethodResolver.resolveMethod(declareClass, methodName, paramTypes);
    if (null == method)
    {
        UDFAnnotation annotation = declareClass.getAnnotation(UDFAnnotation.class);
        String functionName = annotation == null ? declareClass.getSimpleName() : annotation.value();
        StreamingRuntimeException exception =
         new StreamingRuntimeException(ErrorCode.FUNCTION_UNSUPPORTED_PARAMETERS, functionName);
        LOG.error(ErrorCode.FUNCTION_UNSUPPORTED_PARAMETERS.getFullMessage(functionName));
        throw exception;
    }
    FastClass declaringClass =
        FastClass.create(Thread.currentThread().getContextClassLoader(), method.getDeclaringClass());
    FastMethod md = declaringClass.getMethod(method);
    return warpDataType(md.getReturnType());
}
 
开发者ID:HuaweiBigData,项目名称:StreamCQL,代码行数:26,代码来源:MethodExpression.java

示例4: invoke

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
/**
 * �������AOP�෽��
 * 
 * @param methodName ��������
 * @param className ��ȫ��
 * @param dao BaseDAO
 * @param aspectData AOP xml�����ļ�����
 * @param queryWrapper ��ѯ����
 * @param queryEnumType ��ѯ����
 * @return �Ƿ����ִ��
 */
private boolean invoke(String methodName, String className, SqlSession dao, AspectData aspectData,
    QueryAspectWrapper queryWrapper, QueryEnumType queryEnumType)
{
    if (getJavaClass(className) == null || aepectObj == null)
        return false;
    Class<?>[] params = {SqlSession.class, AspectData.class, QueryAspectWrapper.class, QueryEnumType.class};
    try
    {
        FastClass fastClass = ReflectHelper.getFastClass(aspectClass);
        FastMethod mt = ReflectHelper.getFastMethod(fastClass, methodName, params);
        if (mt == null)
            return false;
        Boolean ret = (Boolean)mt.invoke(aepectObj, new Object[] {dao, aspectData, queryWrapper, queryEnumType});
        return ret;
    }
    catch (Exception e)
    {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:liulhdarks,项目名称:darks-orm,代码行数:33,代码来源:JavaClassQueryAspect.java

示例5: init

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
@Setup
public void init() {
	try {
		simpleMethod = clazz.getMethod("getAStatic", null);

		Method method = clazz.getMethod("getBStatic", null);
		method.setAccessible(true);
		methodAccessible = method;
	
		fastMethod = FastClass.create(clazz).getMethod("getCStatic", null);
		
		methodHandle = MethodHandles.lookup().findStatic(clazz, "getDStatic", MethodType.methodType(Integer.class));
	} catch (Exception e) {
		// do nothing
	}
}
 
开发者ID:SerCeMan,项目名称:reflection-access-tests,代码行数:17,代码来源:ReflectionMethodStaticAccess.java

示例6: init

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
@Setup
public void init() {
	try {
		testedObject = new TestedClass();
		
		simpleMethod = clazz.getMethod("getA", null);

		Method method = clazz.getMethod("getB", null);
		method.setAccessible(true);
		methodAccessible = method;
		
		fastMethod = FastClass.create(clazz).getMethod("getC", null);
		
		methodHandle = MethodHandles.lookup().findVirtual(clazz, "getD", MethodType.methodType(Integer.class));
	} catch (Exception e) {
		// do nothing
	}
}
 
开发者ID:SerCeMan,项目名称:reflection-access-tests,代码行数:19,代码来源:ReflectionMethodAccess.java

示例7: buildGettersMap

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
private static Map<String, FastMethod> buildGettersMap(Class<?> clazz) {
    Map<String, FastMethod> result = new HashMap<>();

    FastClass fastClass = getFastClass(clazz);
    Method[] methods = clazz.getMethods();

    for (Method method : methods) {
        if (!Modifier.isStatic(method.getModifiers())) {
            String property = getGetterProperty(method);
            if (property != null) {
                result.put(property, fastClass.getMethod(method));
            }
        }
    }

    return result;
}
 
开发者ID:Codeforces,项目名称:codeforces-commons,代码行数:18,代码来源:ReflectionUtil.java

示例8: buildSettersMap

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
private static Map<String, FastMethod> buildSettersMap(Class<?> clazz) {
    Map<String, FastMethod> result = new HashMap<>();

    FastClass fastClass = getFastClass(clazz);
    Method[] methods = clazz.getMethods();

    for (Method method : methods) {
        if (!Modifier.isStatic(method.getModifiers())) {
            String property = getSetterProperty(method);
            if (property != null) {
                result.put(property, fastClass.getMethod(method));
            }
        }
    }

    return result;
}
 
开发者ID:Codeforces,项目名称:codeforces-commons,代码行数:18,代码来源:ReflectionUtil.java

示例9: test

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
private void test() throws InvocationTargetException {
    FastClass fastClass = FastClass.create(Source.class);

    Source sourceClass = (Source) fastClass.newInstance();

    fastClass.invoke("setIntValue", new Class[] { int.class }, sourceClass, new Object[] { 200 });
    Object getIntValue = fastClass.invoke("getIntValue", new Class[] {}, sourceClass, new Object[] {});
    System.out.println("intValue : " + getIntValue.toString());

    FastMethod setIntValueMethod = fastClass.getMethod("setIntValue", new Class[] { int.class });
    System.out.println("method name :" + setIntValueMethod.getJavaMethod().getName() + " index:"
                       + setIntValueMethod.getIndex());

    FastMethod getIntValueMethod = fastClass.getMethod("getIntValue", new Class[] {});
    System.out.println("method name :" + getIntValueMethod.getJavaMethod().getName() + " index:"
                       + getIntValueMethod.getIndex());
}
 
开发者ID:inter12,项目名称:swiftly,代码行数:18,代码来源:FastClassTest.java

示例10: doconfirmorcancel

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
private void doconfirmorcancel(Class<?> clazz, String lookup, String method, //
                Class<?>[] mParamsTypes, Object[] args) throws Exception {
    Class<?> confirmclass = GuiceDI.getInstance(ServiceInfosHolder.class).getImplClass(clazz, lookup);
    FastClass confrimfast = FastClass.create(confirmclass);
    // fast class反射调用  
    Object confirmtarget = confrimfast.newInstance();

    FastMethod confirmmethod = confrimfast.getMethod(method, mParamsTypes);
    confirmmethod.invoke(confirmtarget, args);
}
 
开发者ID:lemonJun,项目名称:TakinRPC,代码行数:11,代码来源:CGlibInvoker.java

示例11: build

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
private static FastMethodInvoker build(final Class<?> clz, Method method) {
	FastClass fastClz = MapUtil.createIfAbsent(fastClassMap, clz, new ValueCreator<FastClass>() {
		@Override
		public FastClass get() {
			return FastClass.create(clz);
		}
	});

	return new FastMethodInvoker(fastClz.getMethod(method));
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:11,代码来源:FastMethodInvoker.java

示例12: add

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
public void add(String prefix, String serviceName, Object serviceBean) {
	Class<?> serviceClass = serviceBean.getClass();
	FastClass serviceFastClass = FastClass.create(serviceClass);

	Method[] methods = serviceClass.getDeclaredMethods();

	for (Method method : methods) {
		method.setAccessible(true);
		FastMethod fastMethod = serviceFastClass.getMethod(method);
		MethodInvoker methodInvoker = new MethodInvoker(serviceBean, fastMethod);

		methodInvokerMap.put(prefix + "/" + serviceName + "/" + method.getName().toLowerCase(), methodInvoker);
	}
}
 
开发者ID:springside,项目名称:springtime,代码行数:15,代码来源:ServiceBeanFactory.java

示例13: handleRequest

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
protected Object handleRequest(RpcRequest request) throws Exception {
    Class<?> serviceClass = serviceBean.getClass();
    String methodName = request.getMethodName();
    Class<?>[] parameterTypes = request.getParameterTypes();
    Object[] parameters = request.getParameters();
    // use cglib go to invoke
    FastClass serviceFastClass = FastClass.create(serviceClass);
    FastMethod serviceFastMethod = serviceFastClass.getMethod(methodName, parameterTypes);
    return serviceFastMethod.invoke(serviceBean, parameters);
}
 
开发者ID:netboynb,项目名称:coco,代码行数:11,代码来源:RpcRequestTask.java

示例14: initialize

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
/**
 * Initializes the dispatcher table. This maps every type
 * to precisely the method which handles it. At lookup time we
 * will incrementally populate the table with additional entries
 * for super-types.
 */
private void initialize(Class<? extends Annotation> marker, Class<?> provider) {
  Class<?> providerSuper = provider.getSuperclass();
  if (providerSuper != null && providerSuper != Object.class) {
    // First get methods from super class. They can be overridden later.
    initialize(marker, providerSuper);
  }
  // Now get methods from this provider.
  FastClass fastProvider = FastClass.create(provider);
  for (Method method : provider.getDeclaredMethods()) {
    Annotation dispatched = method.getAnnotation(marker);
    if (dispatched == null) {
      continue;
    }

    Preconditions.checkState((method.getModifiers() & Modifier.STATIC) == 0,
        "%s must not be static", method);
    Preconditions.checkState(method.getParameterTypes().length == 1,
        "%s must have exactly one parameter", method);
    @SuppressWarnings("unchecked") // checked at runtime
    Class<? extends BaseType> dispatchedOn =
        (Class<? extends BaseType>) method.getParameterTypes()[0];
    Preconditions.checkState(baseType.isAssignableFrom(dispatchedOn),
        "%s parameter must be assignable to %s", method, baseType);

    Optional<FastMethod> oldMethod = dispatchTable.getIfPresent(dispatchedOn);
    if (oldMethod != null && oldMethod.get().getDeclaringClass() == provider) {
      throw new IllegalStateException(String.format(
          "%s clashes with already configured %s from same class %s",
          method, oldMethod.get().getJavaMethod(), provider));
    }
    dispatchTable.put(dispatchedOn, Optional.of(fastProvider.getMethod(method)));
  }
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:40,代码来源:Dispatcher.java

示例15: createPropertyConstructors

import net.sf.cglib.reflect.FastClass; //导入依赖的package包/类
private Map<String, FastConstructor> createPropertyConstructors(Map<String, Object> propertyTypes) {
    Map<String, FastConstructor> constructors = new HashMap<String, FastConstructor>();

    Class[] parameterTypes = new Class[]{String.class};
    for (String property : propertyTypes.keySet()) {
        log.debug(".createPropertyConstructors property==" + property + ", type==" + propertyTypes.get(property));
        Class clazz = JavaClassHelper.getBoxedType((Class) propertyTypes.get(property));
        FastClass fastClass = FastClass.create(FastClassClassLoaderProviderDefault.INSTANCE.classloader(clazz), clazz);
        FastConstructor constructor = fastClass.getConstructor(parameterTypes);
        constructors.put(property, constructor);
    }
    return constructors;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:14,代码来源:AbstractTypeCoercer.java


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