Package net.sf.cglib.reflect

Examples of net.sf.cglib.reflect.FastMethod


    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


        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

                isReturnsConstantResult = isConstantParameters && modifiedChain.isEmpty();

                // Resolve the method - last choice
                String className = firstItem.getName();
                Method method;
                FastMethod staticMethod;
                try
                {
                    method = validationContext.getMethodResolutionService().resolveMethod(firstItem.getName(), secondItem.getName(), paramTypes);
                    FastClass declaringClass = FastClass.create(Thread.currentThread().getContextClassLoader(), method.getDeclaringClass());
                    staticMethod = declaringClass.getMethod(method);
View Full Code Here

                isReturnsConstantResult = isConstantParameters && modifiedChain.isEmpty();

                // Resolve the method - last choice
                String className = firstItem.getName();
                Method method;
                FastMethod staticMethod;
                try
                {
                    method = validationContext.getMethodResolutionService().resolveMethod(firstItem.getName(), secondItem.getName(), paramTypes);
                    FastClass declaringClass = FastClass.create(Thread.currentThread().getContextClassLoader(), method.getDeclaringClass());
                    staticMethod = declaringClass.getMethod(method);
View Full Code Here

        else {
            throw new IllegalStateException("Invalid value cache code " + valueCache);
        }

        // Try to resolve the method
        final FastMethod staticMethod;
        Method method;
    try
    {
      method = validationContext.getMethodResolutionService().resolveMethod(clazz.getName(), firstItem.getName(), paramTypes);
      FastClass declaringClass = FastClass.create(Thread.currentThread().getContextClassLoader(), method.getDeclaringClass());
      staticMethod = declaringClass.getMethod(method);
    }
    catch(Exception e)
    {
      throw new ExprValidationException(e.getMessage());
    }

        // this may return a pair of null if there is no lambda or the result cannot be wrapped for lambda-function use
        ExprDotStaticMethodWrap optionalLambdaWrap = ExprDotStaticMethodWrapFactory.make(method, validationContext.getEventAdapterService(), chainList);
        ExprDotEvalTypeInfo typeInfo = optionalLambdaWrap != null ? optionalLambdaWrap.getTypeInfo() : ExprDotEvalTypeInfo.scalarOrUnderlying(method.getReturnType());

        ExprDotEval[] eval = ExprDotNodeUtility.getChainEvaluators(typeInfo, chainList, validationContext, false, new ExprDotNodeFilterAnalyzerInputStatic()).getChainWithUnpack();
        evaluator = new ExprDotEvalStaticMethod(validationContext.getStatementName(), clazz.getName(), staticMethod, childEvals, allConstants, optionalLambdaWrap, eval);

        // If caching the result, evaluate now and return the result.
        if (isReturnsConstantResult) {
            final Object result = evaluator.evaluate(null, true, null);
            evaluator = new ExprEvaluator() {
                public Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context) {
                    return result;
                }

                public Class getType() {
                    return staticMethod.getReturnType();
                }

                public Map<String, Object> getEventType() throws ExprValidationException {
                    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

                    else {
                        target = currentInputType.getEventType().getUnderlyingType();
                    }
                    Method method = validationContext.getMethodResolutionService().resolveMethod(target, chainElement.getName(), paramTypes);
                    FastClass declaringClass = FastClass.create(Thread.currentThread().getContextClassLoader(), method.getDeclaringClass());
                    FastMethod fastMethod = declaringClass.getMethod(method);

                    ExprDotEval eval;
                    if (currentInputType.isScalar()) {
                        eval = new ExprDotMethodEvalNoDuck(validationContext.getStatementName(), fastMethod, paramEvals);
                    }
View Full Code Here

          return method.invoke(target, parameters);
        }
      };
    } else {
      FastClass fastClass = newFastClass(method.getDeclaringClass(), Visibility.forMember(method));
      final FastMethod fastMethod = fastClass.getMethod(method);

      methodInvoker = new MethodInvoker() {
        public Object invoke(Object target, Object... parameters)
            throws IllegalAccessException, InvocationTargetException {
          return fastMethod.invoke(target, parameters);
        }
      };
    }

    parameterInjectors = injector.getParametersInjectors(injectionPoint.getDependencies(), errors);
View Full Code Here

  final Object source;
  final Invokable invokable;
 
  /** Default constructor that uses the {@code map} method defined in subclass for mapping. */
  protected Mapper() {
    FastMethod method = mapMethod(getClass());
    this.source = method;
    this.invokable = Invokables.method(this, method);
  }
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.