Search in sources :

Example 1 with CompilablePropertyAccessor

use of org.springframework.expression.spel.CompilablePropertyAccessor in project spring-framework by spring-projects.

the class PropertyOrFieldReference method getValueInternal.

@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
    TypedValue tv = getValueInternal(state.getActiveContextObject(), state.getEvaluationContext(), state.getConfiguration().isAutoGrowNullReferences());
    PropertyAccessor accessorToUse = this.cachedReadAccessor;
    if (accessorToUse instanceof CompilablePropertyAccessor) {
        CompilablePropertyAccessor accessor = (CompilablePropertyAccessor) accessorToUse;
        this.exitTypeDescriptor = CodeFlow.toDescriptor(accessor.getPropertyType());
    }
    return tv;
}
Also used : ReflectivePropertyAccessor(org.springframework.expression.spel.support.ReflectivePropertyAccessor) PropertyAccessor(org.springframework.expression.PropertyAccessor) CompilablePropertyAccessor(org.springframework.expression.spel.CompilablePropertyAccessor) CompilablePropertyAccessor(org.springframework.expression.spel.CompilablePropertyAccessor) TypedValue(org.springframework.expression.TypedValue)

Example 2 with CompilablePropertyAccessor

use of org.springframework.expression.spel.CompilablePropertyAccessor in project spring-framework by spring-projects.

the class PropertyOrFieldReference method generateCode.

@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
    PropertyAccessor accessorToUse = this.cachedReadAccessor;
    if (!(accessorToUse instanceof CompilablePropertyAccessor)) {
        throw new IllegalStateException("Property accessor is not compilable: " + accessorToUse);
    }
    ((CompilablePropertyAccessor) accessorToUse).generateCode(this.name, mv, cf);
    cf.pushDescriptor(this.exitTypeDescriptor);
}
Also used : ReflectivePropertyAccessor(org.springframework.expression.spel.support.ReflectivePropertyAccessor) PropertyAccessor(org.springframework.expression.PropertyAccessor) CompilablePropertyAccessor(org.springframework.expression.spel.CompilablePropertyAccessor) CompilablePropertyAccessor(org.springframework.expression.spel.CompilablePropertyAccessor)

Aggregations

PropertyAccessor (org.springframework.expression.PropertyAccessor)2 CompilablePropertyAccessor (org.springframework.expression.spel.CompilablePropertyAccessor)2 ReflectivePropertyAccessor (org.springframework.expression.spel.support.ReflectivePropertyAccessor)2 TypedValue (org.springframework.expression.TypedValue)1