本文整理汇总了Java中net.sf.cglib.reflect.FastClass.getMethod方法的典型用法代码示例。如果您正苦于以下问题:Java FastClass.getMethod方法的具体用法?Java FastClass.getMethod怎么用?Java FastClass.getMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.sf.cglib.reflect.FastClass
的用法示例。
在下文中一共展示了FastClass.getMethod方法的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;
}
示例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);
}
示例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());
}
示例4: 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());
}
示例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);
}
示例6: 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));
}
示例7: 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);
}
}
示例8: 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);
}
示例9: 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);
}
}
示例10: 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;
}
示例11: 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();
}
示例12: 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;
}
}
示例13: setUp
import net.sf.cglib.reflect.FastClass; //导入方法依赖的package包/类
public void setUp() throws Exception {
bean = SupportBeanComplexProps.makeDefaultBean();
theEvent = SupportEventBeanFactory.createObject(bean);
FastClass fastClass = FastClass.create(Thread.currentThread().getContextClassLoader(), SupportBeanComplexProps.class);
FastMethod method = fastClass.getMethod("getIndexed", new Class[]{int.class});
getter = new KeyedFastPropertyGetter(method, 1, SupportEventAdapterService.getService());
}
示例14: 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;
}
示例15: testGetterSpecial
import net.sf.cglib.reflect.FastClass; //导入方法依赖的package包/类
public void testGetterSpecial() throws Exception {
Class clazz = SupportBeanComplexProps.class;
FastClass fastClass = FastClass.create(Thread.currentThread().getContextClassLoader(), clazz);
// set up bean
SupportBeanComplexProps bean = SupportBeanComplexProps.makeDefaultBean();
// try mapped property
Method method = clazz.getMethod("getMapped", new Class[]{String.class});
FastMethod fastMethod = fastClass.getMethod(method);
Object result = fastMethod.invoke(bean, new Object[]{"keyOne"});
assertEquals("valueOne", result);
result = fastMethod.invoke(bean, new Object[]{"keyTwo"});
assertEquals("valueTwo", result);
// try index property
method = clazz.getMethod("getIndexed", new Class[]{int.class});
fastMethod = fastClass.getMethod(method);
result = fastMethod.invoke(bean, new Object[]{0});
assertEquals(1, result);
result = fastMethod.invoke(bean, new Object[]{1});
assertEquals(2, result);
// try nested property
method = clazz.getMethod("getNested", new Class[]{});
fastMethod = fastClass.getMethod(method);
SupportBeanComplexProps.SupportBeanSpecialGetterNested nested = (SupportBeanComplexProps.SupportBeanSpecialGetterNested) fastMethod.invoke(bean, new Object[]{});
Class nestedClazz = SupportBeanComplexProps.SupportBeanSpecialGetterNested.class;
Method methodNested = nestedClazz.getMethod("getNestedValue", new Class[]{});
FastClass fastClassNested = FastClass.create(Thread.currentThread().getContextClassLoader(), nestedClazz);
fastClassNested.getMethod(methodNested);
}