本文整理汇总了Java中net.sf.cglib.reflect.FastMethod类的典型用法代码示例。如果您正苦于以下问题:Java FastMethod类的具体用法?Java FastMethod怎么用?Java FastMethod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FastMethod类属于net.sf.cglib.reflect包,在下文中一共展示了FastMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ExprDotNodeForgeStaticMethod
import net.sf.cglib.reflect.FastMethod; //导入依赖的package包/类
public ExprDotNodeForgeStaticMethod(ExprNode parent, boolean isReturnsConstantResult, String statementName, String classOrPropertyName, FastMethod staticMethod, ExprForge[] childForges, boolean isConstantParameters, ExprDotForge[] chainForges, ExprDotStaticMethodWrap resultWrapLambda, boolean rethrowExceptions, Object targetObject) {
this.parent = parent;
this.isReturnsConstantResult = isReturnsConstantResult;
this.statementName = statementName;
this.classOrPropertyName = classOrPropertyName;
this.staticMethod = staticMethod;
this.childForges = childForges;
if (chainForges.length > 0) {
this.isConstantParameters = false;
} else {
this.isConstantParameters = isConstantParameters;
}
this.chainForges = chainForges;
this.resultWrapLambda = resultWrapLambda;
this.rethrowExceptions = rethrowExceptions;
this.targetObject = targetObject;
}
示例2: evaluate
import net.sf.cglib.reflect.FastMethod; //导入依赖的package包/类
public Object evaluate(Object target, EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext) {
if (target == null) {
return null;
}
FastMethod method = dotMethodDuckGetMethod(target.getClass(), cache, forge);
if (method == null) {
return null;
}
Object[] args = new Object[parameters.length];
for (int i = 0; i < args.length; i++) {
args[i] = parameters[i].evaluate(eventsPerStream, isNewData, exprEvaluatorContext);
}
return dotMethodDuckInvokeMethod(method, target, args, forge);
}
示例3: codegen
import net.sf.cglib.reflect.FastMethod; //导入依赖的package包/类
public static CodegenExpression codegen(ExprDotMethodForgeDuck forge, CodegenExpression inner, Class innerType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) {
CodegenMember mCache = codegenClassScope.makeAddMember(Map.class, new HashMap());
CodegenMember mForge = codegenClassScope.makeAddMember(ExprDotMethodForgeDuck.class, forge);
CodegenMethodNode methodNode = codegenMethodScope.makeChild(Object.class, ExprDotMethodForgeDuckEval.class, codegenClassScope).addParam(innerType, "target");
CodegenBlock block = methodNode.getBlock()
.ifRefNullReturnNull("target")
.declareVar(FastMethod.class, "method", staticMethod(ExprDotMethodForgeDuckEval.class, "dotMethodDuckGetMethod", exprDotMethod(ref("target"), "getClass"), member(mCache.getMemberId()), member(mForge.getMemberId())))
.ifRefNullReturnNull("method")
.declareVar(Object[].class, "args", newArrayByLength(Object.class, constant(forge.getParameters().length)));
for (int i = 0; i < forge.getParameters().length; i++) {
block.assignArrayElement("args", constant(i), forge.getParameters()[i].evaluateCodegen(Object.class, methodNode, exprSymbol, codegenClassScope));
}
block.methodReturn(staticMethod(ExprDotMethodForgeDuckEval.class, "dotMethodDuckInvokeMethod", ref("method"), ref("target"), ref("args"), member(mForge.getMemberId())));
return localMethod(methodNode, inner);
}
示例4: initializeWriters
import net.sf.cglib.reflect.FastMethod; //导入依赖的package包/类
private void initializeWriters() {
Set<WriteablePropertyDescriptor> writables = PropertyHelper.getWritableProperties(fastClass.getJavaClass());
EventPropertyDescriptor[] desc = new EventPropertyDescriptor[writables.size()];
Map<String, Pair<EventPropertyDescriptor, BeanEventPropertyWriter>> writers = new HashMap<String, Pair<EventPropertyDescriptor, BeanEventPropertyWriter>>();
int count = 0;
for (final WriteablePropertyDescriptor writable : writables) {
EventPropertyDescriptor propertyDesc = new EventPropertyDescriptor(writable.getPropertyName(), writable.getType(), null, false, false, false, false, false);
desc[count++] = propertyDesc;
final FastMethod fastMethod = fastClass.getMethod(writable.getWriteMethod());
writers.put(writable.getPropertyName(), new Pair<EventPropertyDescriptor, BeanEventPropertyWriter>(propertyDesc, new BeanEventPropertyWriter(clazz, fastMethod)));
}
writerMap = writers;
writeablePropertyDescriptors = desc;
}
示例5: getGetter
import net.sf.cglib.reflect.FastMethod; //导入依赖的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;
}
示例6: handle
import net.sf.cglib.reflect.FastMethod; //导入依赖的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);
}
示例7: resolveType
import net.sf.cglib.reflect.FastMethod; //导入依赖的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());
}
示例8: registerResultSetMethod
import net.sf.cglib.reflect.FastMethod; //导入依赖的package包/类
/**
* ע��ResultSet setter,getter����
*/
private static void registerResultSetMethod()
{
Class<ResultSet> clazz = ResultSet.class;
Method[] mts = clazz.getDeclaredMethods();
for (Method mt : mts)
{
String name = mt.getName();
if (name.startsWith("get"))
{
FastMethod fastMethod = fastClass.getMethod(mt);
Class<?>[] types = fastMethod.getParameterTypes();
if (types.length == 1)
{
if (types[0].equals(String.class))
fastResultStringMethodMap.put(name, fastMethod);
if (types[0].equals(int.class))
fastResultIndexMethodMap.put(name, fastMethod);
}
}
}
}
示例9: invoke
import net.sf.cglib.reflect.FastMethod; //导入依赖的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;
}
}
示例10: buildGettersMap
import net.sf.cglib.reflect.FastMethod; //导入依赖的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;
}
示例11: buildSettersMap
import net.sf.cglib.reflect.FastMethod; //导入依赖的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;
}
示例12: test
import net.sf.cglib.reflect.FastMethod; //导入依赖的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());
}
示例13: doconfirmorcancel
import net.sf.cglib.reflect.FastMethod; //导入依赖的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);
}
示例14: add
import net.sf.cglib.reflect.FastMethod; //导入依赖的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);
}
}
示例15: handleRequest
import net.sf.cglib.reflect.FastMethod; //导入依赖的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);
}