Java Code Examples for org.springframework.expression.spel.support.ReflectivePropertyAccessor#OptimalPropertyAccessor
The following examples show how to use
org.springframework.expression.spel.support.ReflectivePropertyAccessor#OptimalPropertyAccessor .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Indexer.java From spring-analysis-note with MIT License | 6 votes |
@Override public boolean isCompilable() { if (this.indexedType == IndexedType.ARRAY) { return (this.exitTypeDescriptor != null); } else if (this.indexedType == IndexedType.LIST) { return this.children[0].isCompilable(); } else if (this.indexedType == IndexedType.MAP) { return (this.children[0] instanceof PropertyOrFieldReference || this.children[0].isCompilable()); } else if (this.indexedType == IndexedType.OBJECT) { // If the string name is changing the accessor is clearly going to change (so no compilation possible) return (this.cachedReadAccessor != null && this.cachedReadAccessor instanceof ReflectivePropertyAccessor.OptimalPropertyAccessor && getChild(0) instanceof StringLiteral); } return false; }
Example 2
Source File: Indexer.java From java-technology-stack with MIT License | 6 votes |
@Override public boolean isCompilable() { if (this.indexedType == IndexedType.ARRAY) { return (this.exitTypeDescriptor != null); } else if (this.indexedType == IndexedType.LIST) { return this.children[0].isCompilable(); } else if (this.indexedType == IndexedType.MAP) { return (this.children[0] instanceof PropertyOrFieldReference || this.children[0].isCompilable()); } else if (this.indexedType == IndexedType.OBJECT) { // If the string name is changing the accessor is clearly going to change (so no compilation possible) return (this.cachedReadAccessor != null && this.cachedReadAccessor instanceof ReflectivePropertyAccessor.OptimalPropertyAccessor && getChild(0) instanceof StringLiteral); } return false; }
Example 3
Source File: Indexer.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public boolean isCompilable() { if (this.indexedType == IndexedType.ARRAY) { return (this.exitTypeDescriptor != null); } else if (this.indexedType == IndexedType.LIST) { return this.children[0].isCompilable(); } else if (this.indexedType == IndexedType.MAP) { return (this.children[0] instanceof PropertyOrFieldReference || this.children[0].isCompilable()); } else if (this.indexedType == IndexedType.OBJECT) { // If the string name is changing the accessor is clearly going to change (so compilation is not possible) if (this.cachedReadAccessor != null && (this.cachedReadAccessor instanceof ReflectivePropertyAccessor.OptimalPropertyAccessor) && (getChild(0) instanceof StringLiteral)) { return true; } } return false; }
Example 4
Source File: Indexer.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public boolean isCompilable() { if (this.indexedType == IndexedType.ARRAY) { return (this.exitTypeDescriptor != null); } else if (this.indexedType == IndexedType.LIST) { return this.children[0].isCompilable(); } else if (this.indexedType == IndexedType.MAP) { return (this.children[0] instanceof PropertyOrFieldReference || this.children[0].isCompilable()); } else if (this.indexedType == IndexedType.OBJECT) { // If the string name is changing the accessor is clearly going to change (so compilation is not possible) if (this.cachedReadAccessor != null && (this.cachedReadAccessor instanceof ReflectivePropertyAccessor.OptimalPropertyAccessor) && (getChild(0) instanceof StringLiteral)) { return true; } } return false; }
Example 5
Source File: Indexer.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public TypedValue getValue() { Class<?> targetObjectRuntimeClass = getObjectClass(this.targetObject); try { if (Indexer.this.cachedReadName != null && Indexer.this.cachedReadName.equals(this.name) && Indexer.this.cachedReadTargetType != null && Indexer.this.cachedReadTargetType.equals(targetObjectRuntimeClass)) { // It is OK to use the cached accessor return Indexer.this.cachedReadAccessor.read(this.evaluationContext, this.targetObject, this.name); } List<PropertyAccessor> accessorsToTry = AstUtils.getPropertyAccessorsToTry( targetObjectRuntimeClass, this.evaluationContext.getPropertyAccessors()); if (accessorsToTry != null) { for (PropertyAccessor accessor : accessorsToTry) { if (accessor.canRead(this.evaluationContext, this.targetObject, this.name)) { if (accessor instanceof ReflectivePropertyAccessor) { accessor = ((ReflectivePropertyAccessor) accessor).createOptimalAccessor( this.evaluationContext, this.targetObject, this.name); } Indexer.this.cachedReadAccessor = accessor; Indexer.this.cachedReadName = this.name; Indexer.this.cachedReadTargetType = targetObjectRuntimeClass; if (accessor instanceof ReflectivePropertyAccessor.OptimalPropertyAccessor) { ReflectivePropertyAccessor.OptimalPropertyAccessor optimalAccessor = (ReflectivePropertyAccessor.OptimalPropertyAccessor) accessor; Member member = optimalAccessor.member; Indexer.this.exitTypeDescriptor = CodeFlow.toDescriptor(member instanceof Method ? ((Method) member).getReturnType() : ((Field) member).getType()); } return accessor.read(this.evaluationContext, this.targetObject, this.name); } } } } catch (AccessException ex) { throw new SpelEvaluationException(getStartPosition(), ex, SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE, this.targetObjectTypeDescriptor.toString()); } throw new SpelEvaluationException(getStartPosition(), SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE, this.targetObjectTypeDescriptor.toString()); }
Example 6
Source File: Indexer.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public TypedValue getValue() { Class<?> targetObjectRuntimeClass = getObjectClass(this.targetObject); try { if (Indexer.this.cachedReadName != null && Indexer.this.cachedReadName.equals(this.name) && Indexer.this.cachedReadTargetType != null && Indexer.this.cachedReadTargetType.equals(targetObjectRuntimeClass)) { // It is OK to use the cached accessor return Indexer.this.cachedReadAccessor.read(this.evaluationContext, this.targetObject, this.name); } List<PropertyAccessor> accessorsToTry = AstUtils.getPropertyAccessorsToTry( targetObjectRuntimeClass, this.evaluationContext.getPropertyAccessors()); if (accessorsToTry != null) { for (PropertyAccessor accessor : accessorsToTry) { if (accessor.canRead(this.evaluationContext, this.targetObject, this.name)) { if (accessor instanceof ReflectivePropertyAccessor) { accessor = ((ReflectivePropertyAccessor) accessor).createOptimalAccessor( this.evaluationContext, this.targetObject, this.name); } Indexer.this.cachedReadAccessor = accessor; Indexer.this.cachedReadName = this.name; Indexer.this.cachedReadTargetType = targetObjectRuntimeClass; if (accessor instanceof ReflectivePropertyAccessor.OptimalPropertyAccessor) { ReflectivePropertyAccessor.OptimalPropertyAccessor optimalAccessor = (ReflectivePropertyAccessor.OptimalPropertyAccessor) accessor; Member member = optimalAccessor.member; Indexer.this.exitTypeDescriptor = CodeFlow.toDescriptor(member instanceof Method ? ((Method) member).getReturnType() : ((Field) member).getType()); } return accessor.read(this.evaluationContext, this.targetObject, this.name); } } } } catch (AccessException ex) { throw new SpelEvaluationException(getStartPosition(), ex, SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE, this.targetObjectTypeDescriptor.toString()); } throw new SpelEvaluationException(getStartPosition(), SpelMessage.INDEXING_NOT_SUPPORTED_FOR_TYPE, this.targetObjectTypeDescriptor.toString()); }