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


Java FastClass.create方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: SendableBeanEvent

import net.sf.cglib.reflect.FastClass; //导入方法依赖的package包/类
/**
 * Converts mapToSend to an instance of beanClass
 *
 * @param mapToSend     - the map containing data to send into the runtime
 * @param beanClass     - type of the bean to create from mapToSend
 * @param eventTypeName - the event type name for the map event
 * @param timestamp     - the timestamp for this event
 * @param scheduleSlot  - the schedule slot for the entity that created this event
 */
public SendableBeanEvent(Map<String, Object> mapToSend, Class beanClass, String eventTypeName, long timestamp, long scheduleSlot) {
    super(timestamp, scheduleSlot);

    try {
        Map<String, BeanEventPropertyWriter> writers = writersMap.get(beanClass);
        if (writers == null) {
            Set<WriteablePropertyDescriptor> props = PropertyHelper.getWritableProperties(beanClass);
            writers = new HashMap<String, BeanEventPropertyWriter>();
            writersMap.put(beanClass, writers);
            FastClass fastClass = FastClass.create(FastClassClassLoaderProviderDefault.INSTANCE.classloader(beanClass), beanClass);
            for (WriteablePropertyDescriptor prop : props) {
                FastMethod writerMethod = fastClass.getMethod(prop.getWriteMethod());
                writers.put(prop.getPropertyName(), new BeanEventPropertyWriter(beanClass, writerMethod));
            }
            // populate writers
        }

        beanToSend = beanClass.newInstance();

        for (Map.Entry<String, Object> entry : mapToSend.entrySet()) {
            BeanEventPropertyWriter writer = writers.get(entry.getKey());
            if (writer != null) {
                writer.writeValue(entry.getValue(), beanToSend);
            }
        }
    } catch (Exception e) {
        throw new EPException("Cannot populate bean instance", e);
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:39,代码来源:SendableBeanEvent.java

示例9: getFastMethod

import net.sf.cglib.reflect.FastClass; //导入方法依赖的package包/类
private static FastMethod getFastMethod(Class clazz, ExprDotMethodForgeDuck forge) {
    try {
        Method method = forge.getEngineImportService().resolveMethod(clazz, forge.getMethodName(), forge.getParameterTypes(), new boolean[forge.getParameterTypes().length], new boolean[forge.getParameterTypes().length]);
        FastClass declaringClass = FastClass.create(forge.getEngineImportService().getFastClassClassLoader(method.getDeclaringClass()), method.getDeclaringClass());
        return declaringClass.getMethod(method);
    } catch (Exception e) {
        log.debug("Not resolved for class '" + clazz.getName() + "' method '" + forge.getMethodName() + "'");
    }
    return null;
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:11,代码来源:ExprDotMethodForgeDuckEval.java

示例10: EPDataFlowEmitter1Stream1TargetBase

import net.sf.cglib.reflect.FastClass; //导入方法依赖的package包/类
public EPDataFlowEmitter1Stream1TargetBase(int operatorNum, DataFlowSignalManager signalManager, SignalHandler signalHandler, EPDataFlowEmitterExceptionHandler exceptionHandler, ObjectBindingPair target, EngineImportService engineImportService) {
    this.operatorNum = operatorNum;
    this.signalManager = signalManager;
    this.signalHandler = signalHandler;
    this.exceptionHandler = exceptionHandler;

    FastClass fastClass = FastClass.create(engineImportService.getFastClassClassLoader(target.getTarget().getClass()), target.getTarget().getClass());
    fastMethod = fastClass.getMethod(target.getBinding().getConsumingBindingDesc().getMethod());
    targetObject = target.getTarget();
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:11,代码来源:EPDataFlowEmitter1Stream1TargetBase.java

示例11: ResultDeliveryStrategyImpl

import net.sf.cglib.reflect.FastClass; //导入方法依赖的package包/类
/**
 * Ctor.
 *
 * @param subscriber        is the subscriber receiving method invocations
 * @param deliveryConvertor for converting individual rows
 * @param method            to deliver the insert stream to
 * @param startMethod       to call to indicate when delivery starts, or null if no such indication is required
 * @param endMethod         to call to indicate when delivery ends, or null if no such indication is required
 * @param rStreamMethod     to deliver the remove stream to, or null if no such indication is required
 * @param statement         statement
 * @param engineImportService engine imports
 */
public ResultDeliveryStrategyImpl(EPStatement statement, Object subscriber, DeliveryConvertor deliveryConvertor, Method method, Method startMethod, Method endMethod, Method rStreamMethod, EngineImportService engineImportService) {
    this.statement = statement;
    this.subscriber = subscriber;
    this.deliveryConvertor = deliveryConvertor;
    FastClass fastClass = FastClass.create(engineImportService.getFastClassClassLoader(subscriber.getClass()), subscriber.getClass());
    this.updateMethodFast = fastClass.getMethod(method);

    if (startMethod != null) {
        this.startMethodFast = fastClass.getMethod(startMethod);
        this.startMethodHasEPStatement = isMethodAcceptsStatement(startMethod);
    } else {
        this.startMethodFast = null;
        this.startMethodHasEPStatement = false;
    }

    if (endMethod != null) {
        this.endMethodFast = fastClass.getMethod(endMethod);
        this.endMethodHasEPStatement = isMethodAcceptsStatement(endMethod);
    } else {
        this.endMethodFast = null;
        this.endMethodHasEPStatement = false;
    }

    if (rStreamMethod != null) {
        updateRStreamMethodFast = fastClass.getMethod(rStreamMethod);
    } else {
        updateRStreamMethodFast = null;
    }
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:42,代码来源:ResultDeliveryStrategyImpl.java

示例12: invokeService

import net.sf.cglib.reflect.FastClass; //导入方法依赖的package包/类
/**
 * init local rpc service map
 */

public static RpcResponse invokeService(RpcRequest request, Object serviceBean) {
	if (serviceBean==null) {
		serviceBean = regitsryMap.get(request.getRegistryKey());
	}
	if (serviceBean == null) {
		// TODO
	}

	RpcResponse response = new RpcResponse();
	response.setRequestId(request.getRequestId());

	try {
		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);

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

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

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

示例13: resolveMethod

import net.sf.cglib.reflect.FastClass; //导入方法依赖的package包/类
/**
 * 根据参数获取函数
 */
private void resolveMethod(IExpression[] exprs)
{
    Class< ? >[] paramTypes = null;
    if (exprs != null)
    {
        //获得函数参数类型
        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 funcitonName = annotation == null ? declareClass.getSimpleName() : annotation.value();
        //运行时调用,和resolveType方法不同
        StreamingRuntimeException exception =
         new StreamingRuntimeException(ErrorCode.FUNCTION_UNSUPPORTED_PARAMETERS, funcitonName);
        LOG.error(ErrorCode.FUNCTION_UNSUPPORTED_PARAMETERS.getFullMessage(funcitonName));
        throw exception;
    }
    FastClass declaringClass =
        FastClass.create(Thread.currentThread().getContextClassLoader(), method.getDeclaringClass());
    fastMethod = declaringClass.getMethod(method);
}
 
开发者ID:HuaweiBigData,项目名称:StreamCQL,代码行数:33,代码来源:MethodExpression.java

示例14: testGetGetter

import net.sf.cglib.reflect.FastClass; //导入方法依赖的package包/类
public void testGetGetter() throws Exception {
    FastClass fastClass = FastClass.create(Thread.currentThread().getContextClassLoader(), SupportBeanPropertyNames.class);
    EventBean bean = SupportEventBeanFactory.createObject(new SupportBeanPropertyNames());
    Method method = SupportBeanPropertyNames.class.getMethod("getA", new Class[0]);
    EventPropertyGetter getter = PropertyHelper.getGetter(method, fastClass, SupportEventAdapterService.getService());
    assertEquals("", getter.get(bean));
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:8,代码来源:TestPropertyHelper.java

示例15: makeGetter

import net.sf.cglib.reflect.FastClass; //导入方法依赖的package包/类
private CGLibPropertyGetter makeGetter(Class clazz, String methodName) throws Exception {
    FastClass fastClass = FastClass.create(Thread.currentThread().getContextClassLoader(), clazz);
    Method method = clazz.getMethod(methodName, new Class[]{});
    FastMethod fastMethod = fastClass.getMethod(method);

    CGLibPropertyGetter getter = new CGLibPropertyGetter(method, fastMethod, SupportEventAdapterService.getService());

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


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