Package net.sf.cglib.reflect

Examples of net.sf.cglib.reflect.FastMethod


            if (methodTarget != null) {
                try
                {
                    // find descriptor again, allow for duck typing
                    ExprNodeUtilMethodDesc desc = getValidateMethodDescriptor(methodTarget, chainElement.getName(), chainElement.getParameters(), validationContext);
                    FastMethod fastMethod = desc.getFastMethod();
                    paramEvals = desc.getChildEvals();

                    ExprDotEval eval;
                    if (currentInputType.isSingleValueNonNull()) {
                        // if followed by an enumeration method, convert array to collection
                        if (fastMethod.getReturnType().isArray() && !chainSpecStack.isEmpty() && EnumMethodEnum.isEnumerationMethod(chainSpecStack.getFirst().getName())) {
                            eval = new ExprDotMethodEvalNoDuckWrapArray(validationContext.getStatementName(), fastMethod, paramEvals);
                        }
                        else {
                            eval = new ExprDotMethodEvalNoDuck(validationContext.getStatementName(), fastMethod, paramEvals);
                        }
View Full Code Here


    public Object evaluate(Object target, EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext) {
        if (target == null) {
            return null;
        }

        FastMethod method;
        if (cache.containsKey(target.getClass())) {
            method = cache.get(target.getClass());
        }
        else {
            method = getFastMethod(target.getClass());
            cache.put(target.getClass(), method);
        }

        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);
    }

    try
    {
            return method.invoke(target, args);
    }
    catch (InvocationTargetException e)
    {
            String message = JavaClassHelper.getMessageInvocationTarget(statementName, method.getJavaMethod(), target.getClass().getName(), args, e);
            log.error(message, e.getTargetException());
    }
        return null;
    }
View Full Code Here

        if (propertyDesc != null)
        {
            if (fastClass != null)
            {
                Method method = propertyDesc.getReadMethod();
                FastMethod fastMethod = fastClass.getMethod(method);
                return new KeyedFastPropertyGetter(fastMethod, index, eventAdapterService);
            }
            else
            {
                return new KeyedMethodPropertyGetter(propertyDesc.getReadMethod(), index, eventAdapterService);
            }
        }

        // Try the array as a simple property
        propertyDesc = eventType.getSimpleProperty(propertyNameAtomic);
        if (propertyDesc == null)
        {
            return null;
        }

        Class returnType = propertyDesc.getReturnType();
        if (returnType.isArray())
        {
            if (propertyDesc.getReadMethod() != null)
            {
                Method method = propertyDesc.getReadMethod();
                if (fastClass != null)
                {
                    FastMethod fastMethod = fastClass.getMethod(method);
                    return new ArrayFastPropertyGetter(fastMethod, index, eventAdapterService);
                }
                else
                {
                    return new ArrayMethodPropertyGetter(method, index, eventAdapterService);
                }
            }
            else
            {
                Field field = propertyDesc.getAccessorField();
                return new ArrayFieldPropertyGetter(field, index, eventAdapterService);
            }
        }
        else if (JavaClassHelper.isImplementsInterface(returnType, List.class))
        {
            if (propertyDesc.getReadMethod() != null)
            {
                Method method = propertyDesc.getReadMethod();
                if (fastClass != null)
                {
                    FastMethod fastMethod = fastClass.getMethod(method);
                    return new ListFastPropertyGetter(method, fastMethod, index, eventAdapterService);
                }
                else
                {
                    return new ListMethodPropertyGetter(method, index, eventAdapterService);
                }
            }
            else
            {
                Field field = propertyDesc.getAccessorField();
                return new ListFieldPropertyGetter(field, index, eventAdapterService);
            }
        }
        else if (JavaClassHelper.isImplementsInterface(returnType, Iterable.class))
        {
            if (propertyDesc.getReadMethod() != null)
            {
                Method method = propertyDesc.getReadMethod();
                if (fastClass != null)
                {
                    FastMethod fastMethod = fastClass.getMethod(method);
                    return new IterableFastPropertyGetter(method, fastMethod, index, eventAdapterService);
                }
                else
                {
                    return new IterableMethodPropertyGetter(method, index, eventAdapterService);
View Full Code Here

        {
            Method method = propertyDesc.getReadMethod();
            FastClass fastClass = eventType.getFastClass();
            if (fastClass != null)
            {
                FastMethod fastMethod = fastClass.getMethod(method);
                return new KeyedFastPropertyGetter(fastMethod, key, eventAdapterService);
            }
            else
            {
                return new KeyedMethodPropertyGetter(method, key, eventAdapterService);
            }
        }

        // Try the array as a simple property
        propertyDesc = eventType.getSimpleProperty(propertyNameAtomic);
        if (propertyDesc == null)
        {
            return null;
        }

        Class returnType = propertyDesc.getReturnType();
        if (!JavaClassHelper.isImplementsInterface(returnType, Map.class))
        {
            return null;
        }

        if (propertyDesc.getReadMethod() != null)
        {
            FastClass fastClass = eventType.getFastClass();
            Method method = propertyDesc.getReadMethod();
            if (fastClass != null)
            {
                FastMethod fastMethod = fastClass.getMethod(method);
                return new KeyedMapFastPropertyGetter(method, fastMethod, key, eventAdapterService);
            }
            else
            {
                return new KeyedMapMethodPropertyGetter(method, key, eventAdapterService);
View Full Code Here

     * @return property getter
     */
    public static EventPropertyGetter getGetter(Method method, FastClass fastClass, EventAdapterService eventAdapterService)
    {
        // Get CGLib fast method handle
        FastMethod fastMethod = null;
        try
        {
            if (fastClass != null)
            {
                fastMethod = fastClass.getMethod(method);
View Full Code Here

                propertyDescriptor = new DynamicPropertyDescriptor(target, null, false);
            }
            else
            {
                FastClass fastClass = FastClass.create(Thread.currentThread().getContextClassLoader(), target);
                FastMethod fastMethod = fastClass.getMethod(method);
                propertyDescriptor = new DynamicPropertyDescriptor(target, fastMethod, fastMethod.getParameterTypes().length > 0);
            }
            cache.add(propertyDescriptor);
            return propertyDescriptor;
        }
    }
View Full Code Here

                return null;
            }
            if (setterMethod == null) {
                return null;
            }
            final FastMethod fastMethod = fastClass.getMethod(setterMethod);
            return new BeanEventPropertyWriterMapProp(clazz, fastMethod, mapProp.getKey());
        }

        if (property instanceof IndexedProperty) {
            IndexedProperty indexedProp = (IndexedProperty) property;
            String methodName = PropertyHelper.getSetterMethodName(indexedProp.getPropertyNameAtomic());
            Method setterMethod;
            try {
                setterMethod = MethodResolver.resolveMethod(clazz, methodName, new Class[] {int.class, Object.class}, true, new boolean[2], new boolean[2]);
            }
            catch (EngineNoSuchMethodException e) {
                log.info("Failed to find indexed property setter method '" + methodName + "' for writing to property '" + propertyName + "' taking {int, Object} as parameters");
                return null;
            }
            if (setterMethod == null) {
                return null;
            }
            final FastMethod fastMethod = fastClass.getMethod(setterMethod);
            return new BeanEventPropertyWriterIndexedProp(clazz, fastMethod, indexedProp.getIndex());
        }

        return null;
    }
View Full Code Here

        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;
View Full Code Here

                allConstants = false;
            }
        }

        // Try to resolve the method
        final FastMethod staticMethod;
        Method method;
        try
        {
            method = methodResolutionService.resolveMethod(className, methodName, paramTypes);
            FastClass declaringClass = FastClass.create(Thread.currentThread().getContextClassLoader(), method.getDeclaringClass());
View Full Code Here

                return null;
            }
            if (setterMethod == null) {
                return null;
            }
            final FastMethod fastMethod = fastClass.getMethod(setterMethod);
            return new BeanEventPropertyWriterMapProp(clazz, fastMethod, mapProp.getKey());
        }

        if (property instanceof IndexedProperty) {
            IndexedProperty indexedProp = (IndexedProperty) property;
            String methodName = PropertyHelper.getSetterMethodName(indexedProp.getPropertyNameAtomic());
            Method setterMethod;
            try {
                setterMethod = MethodResolver.resolveMethod(clazz, methodName, new Class[] {int.class, Object.class}, true);
            }
            catch (EngineNoSuchMethodException e) {
                log.info("Failed to find indexed property setter method '" + methodName + "' for writing to property '" + propertyName + "' taking {int, Object} as parameters");
                return null;
            }
            if (setterMethod == null) {
                return null;
            }
            final FastMethod fastMethod = fastClass.getMethod(setterMethod);
            return new BeanEventPropertyWriterIndexedProp(clazz, fastMethod, indexedProp.getIndex());
        }

        return null;
    }
View Full Code Here

TOP

Related Classes of net.sf.cglib.reflect.FastMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.