@Override public Object resolve(EvaluationContext context, String beanName) throws AccessException { try { return this.beanFactory.getBean(beanName); } catch (BeansException ex) { throw new AccessException("Could not resolve bean reference against BeanFactory", ex); } }
@Override public void write(EvaluationContext context, @Nullable Object target, String name, @Nullable Object newValue) throws AccessException { throw new AccessException("Beans in a BeanFactory are read-only"); }
@Override public void write(EvaluationContext context, @Nullable Object target, String name, @Nullable Object newValue) throws AccessException { throw new AccessException("Beans in a BeanFactory are read-only"); }
@Override public Object resolve(EvaluationContext context, String beanName) throws AccessException { try { return this.beanFactory.getBean(beanName); } catch (BeansException ex) { throw new AccessException("Could not resolve bean reference against BeanFactory", ex); } }
@Override public void write(EvaluationContext context, @Nullable Object target, String name, @Nullable Object newValue) throws AccessException { throw new AccessException("Beans in a BeanFactory are read-only"); }
@Override public void write(EvaluationContext context, @Nullable Object target, String name, @Nullable Object newValue) throws AccessException { throw new AccessException("Beans in a BeanFactory are read-only"); }
@Nullable private Object resolveImplicitVariable(String name) throws AccessException { if (this.variableResolver == null) { return null; } try { return this.variableResolver.resolveVariable(name); } catch (Exception ex) { throw new AccessException( "Unexpected exception occurred accessing '" + name + "' as an implicit variable", ex); } } }
@Override public TypedValue read(EvaluationContext context, @Nullable Object target, String name) throws AccessException { if (this.member instanceof Method) { Method method = (Method) this.member; try { ReflectionUtils.makeAccessible(method); Object value = method.invoke(target); return new TypedValue(value, this.typeDescriptor.narrow(value)); } catch (Exception ex) { throw new AccessException("Unable to access property '" + name + "' through getter method", ex); } } else { Field field = (Field) this.member; try { ReflectionUtils.makeAccessible(field); Object value = field.get(target); return new TypedValue(value, this.typeDescriptor.narrow(value)); } catch (Exception ex) { throw new AccessException("Unable to access field '" + name + "'", ex); } } }
@Nullable private Object resolveImplicitVariable(String name) throws AccessException { if (this.variableResolver == null) { return null; } try { return this.variableResolver.resolveVariable(name); } catch (Exception ex) { throw new AccessException( "Unexpected exception occurred accessing '" + name + "' as an implicit variable", ex); } } }
throw new AccessException("PropertyAccessor for property '" + name + "' on target [" + target + "] does not allow write operations"); throw new AccessException("Type conversion failure", evaluationException); throw new AccessException("Unable to access property '" + name + "' through setter method", ex); throw new AccessException("Unable to access field '" + name + "'", ex); throw new AccessException("Neither setter method nor field found for property '" + name + "'");
@Override public Object resolve(EvaluationContext context, String beanName) throws AccessException { if (beanName.equals("foo")) { return "custard"; } else if (beanName.equals("foo.bar")) { return "trouble"; } else if (beanName.equals("&foo")) { return "foo factory"; } else if (beanName.equals("goo")) { throw new AccessException("DONT ASK ME ABOUT GOO"); } return null; } }
@Override public Object resolve(EvaluationContext context, String beanName) throws AccessException { if (beanName.equals("foo") || beanName.equals("bar")) { return new Spr9751_2(); } throw new AccessException("not heard of " + beanName); } }
@Override public TypedValue execute(EvaluationContext context, Object... arguments) throws AccessException { try { ReflectionHelper.convertArguments( context.getTypeConverter(), arguments, this.ctor, this.varargsPosition); if (this.ctor.isVarArgs()) { arguments = ReflectionHelper.setupArgumentsForVarargsInvocation( this.ctor.getParameterTypes(), arguments); } ReflectionUtils.makeAccessible(this.ctor); return new TypedValue(this.ctor.newInstance(arguments)); } catch (Exception ex) { throw new AccessException("Problem invoking constructor: " + this.ctor, ex); } }
throw new AccessException("Cannot access length on array class itself"); throw new AccessException("Unable to access property '" + name + "' through getter method", ex); throw new AccessException("Unable to access field '" + name + "'", ex); throw new AccessException("Neither getter method nor field found for property '" + name + "'");
@Override public TypedValue execute(EvaluationContext context, Object target, Object... arguments) throws AccessException { try { this.argumentConversionOccurred = ReflectionHelper.convertArguments( context.getTypeConverter(), arguments, this.originalMethod, this.varargsPosition); if (this.originalMethod.isVarArgs()) { arguments = ReflectionHelper.setupArgumentsForVarargsInvocation( this.originalMethod.getParameterTypes(), arguments); } ReflectionUtils.makeAccessible(this.methodToInvoke); Object value = this.methodToInvoke.invoke(target, arguments); return new TypedValue(value, new TypeDescriptor(new MethodParameter(this.originalMethod, -1)).narrow(value)); } catch (Exception ex) { throw new AccessException("Problem invoking method: " + this.methodToInvoke, ex); } }
throw new AccessException("Failed to resolve method", ex);
@Override public void write(EvaluationContext context, Object target, String name, Object newValue) throws AccessException { if (!name.equals("flibbles")) { throw new RuntimeException("Assertion Failed! name should be flibbles"); } try { flibbles = (Integer) context.getTypeConverter().convertValue(newValue, TypeDescriptor.forObject(newValue), TypeDescriptor.valueOf(Integer.class)); } catch (EvaluationException ex) { throw new AccessException("Cannot set flibbles to an object of type '" + newValue.getClass() + "'"); } } }
@Override public TypedValue execute(EvaluationContext context, Object... arguments) throws AccessException { try { ReflectionHelper.convertArguments( context.getTypeConverter(), arguments, this.ctor, this.varargsPosition); if (this.ctor.isVarArgs()) { arguments = ReflectionHelper.setupArgumentsForVarargsInvocation( this.ctor.getParameterTypes(), arguments); } ReflectionUtils.makeAccessible(this.ctor); return new TypedValue(this.ctor.newInstance(arguments)); } catch (Exception ex) { throw new AccessException("Problem invoking constructor: " + this.ctor, ex); } }
throw new AccessException("Failed to resolve constructor", ex);
@Override public TypedValue execute(EvaluationContext context, Object target, Object... arguments) throws AccessException { try { Method m = HasRoleExecutor.class.getMethod("hasRole", String[].class); Object[] args = arguments; if (args != null) { ReflectionHelper.convertAllArguments(tc, args, m); } if (m.isVarArgs()) { args = ReflectionHelper.setupArgumentsForVarargsInvocation(m.getParameterTypes(), args); } return new TypedValue(m.invoke(null, args), new TypeDescriptor(new MethodParameter(m,-1))); } catch (Exception ex) { throw new AccessException("Problem invoking hasRole", ex); } }