本文整理了Java中org.springframework.expression.AccessException
类的一些代码示例,展示了AccessException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AccessException
类的具体详情如下:
包路径:org.springframework.expression.AccessException
类名称:AccessException
[英]An AccessException is thrown by an accessor if it has an unexpected problem.
[中]如果访问器出现意外问题,则会引发访问异常。
代码示例来源:origin: spring-projects/spring-framework
@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);
}
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Decode the AccessException, throwing a lightweight evaluation exception or,
* if the cause was a RuntimeException, throw the RuntimeException directly.
*/
private void throwSimpleExceptionIfPossible(Object value, AccessException ex) {
if (ex.getCause() instanceof InvocationTargetException) {
Throwable rootCause = ex.getCause().getCause();
if (rootCause instanceof RuntimeException) {
throw (RuntimeException) rootCause;
}
throw new ExpressionInvocationTargetException(getStartPosition(),
"A problem occurred when trying to execute method '" + this.name +
"' on object of type [" + value.getClass().getName() + "]", rootCause);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void setValue(@Nullable Object newValue) {
Class<?> contextObjectClass = getObjectClass(this.targetObject);
try {
if (Indexer.this.cachedWriteName != null && Indexer.this.cachedWriteName.equals(this.name) &&
Indexer.this.cachedWriteTargetType != null &&
Indexer.this.cachedWriteTargetType.equals(contextObjectClass)) {
// It is OK to use the cached accessor
PropertyAccessor accessor = Indexer.this.cachedWriteAccessor;
Assert.state(accessor != null, "No cached write accessor");
accessor.write(this.evaluationContext, this.targetObject, this.name, newValue);
return;
}
List<PropertyAccessor> accessorsToTry = AstUtils.getPropertyAccessorsToTry(
contextObjectClass, this.evaluationContext.getPropertyAccessors());
for (PropertyAccessor accessor : accessorsToTry) {
if (accessor.canWrite(this.evaluationContext, this.targetObject, this.name)) {
Indexer.this.cachedWriteName = this.name;
Indexer.this.cachedWriteTargetType = contextObjectClass;
Indexer.this.cachedWriteAccessor = accessor;
accessor.write(this.evaluationContext, this.targetObject, this.name, newValue);
return;
}
}
}
catch (AccessException ex) {
throw new SpelEvaluationException(getStartPosition(), ex,
SpelMessage.EXCEPTION_DURING_PROPERTY_WRITE, this.name, ex.getMessage());
}
}
代码示例来源:origin: spring-projects/spring-framework
@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");
}
代码示例来源:origin: spring-projects/spring-framework
throw new SpelEvaluationException(getStartPosition(), ex,
SpelMessage.EXCEPTION_DURING_METHOD_INVOCATION, this.name,
value.getClass().getName(), ex.getMessage());
代码示例来源:origin: org.springframework/spring-expression
/**
* Decode the AccessException, throwing a lightweight evaluation exception or,
* if the cause was a RuntimeException, throw the RuntimeException directly.
*/
private void throwSimpleExceptionIfPossible(Object value, AccessException ex) {
if (ex.getCause() instanceof InvocationTargetException) {
Throwable rootCause = ex.getCause().getCause();
if (rootCause instanceof RuntimeException) {
throw (RuntimeException) rootCause;
}
throw new ExpressionInvocationTargetException(getStartPosition(),
"A problem occurred when trying to execute method '" + this.name +
"' on object of type [" + value.getClass().getName() + "]", rootCause);
}
}
代码示例来源:origin: spring-projects/spring-framework
@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");
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
BeanResolver beanResolver = state.getEvaluationContext().getBeanResolver();
if (beanResolver == null) {
throw new SpelEvaluationException(
getStartPosition(), SpelMessage.NO_BEAN_RESOLVER_REGISTERED, this.beanName);
}
try {
return new TypedValue(beanResolver.resolve(state.getEvaluationContext(), this.beanName));
}
catch (AccessException ex) {
throw new SpelEvaluationException(getStartPosition(), ex, SpelMessage.EXCEPTION_DURING_BEAN_RESOLUTION,
this.beanName, ex.getMessage());
}
}
代码示例来源:origin: spring-projects/spring-framework
if (ex.getCause() instanceof InvocationTargetException) {
Throwable rootCause = ex.getCause().getCause();
if (rootCause instanceof RuntimeException) {
throw (RuntimeException) rootCause;
代码示例来源:origin: org.springframework/spring-context
@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);
}
}
代码示例来源:origin: org.springframework/spring-expression
@Override
public void setValue(@Nullable Object newValue) {
Class<?> contextObjectClass = getObjectClass(this.targetObject);
try {
if (Indexer.this.cachedWriteName != null && Indexer.this.cachedWriteName.equals(this.name) &&
Indexer.this.cachedWriteTargetType != null &&
Indexer.this.cachedWriteTargetType.equals(contextObjectClass)) {
// It is OK to use the cached accessor
PropertyAccessor accessor = Indexer.this.cachedWriteAccessor;
Assert.state(accessor != null, "No cached write accessor");
accessor.write(this.evaluationContext, this.targetObject, this.name, newValue);
return;
}
List<PropertyAccessor> accessorsToTry = AstUtils.getPropertyAccessorsToTry(
contextObjectClass, this.evaluationContext.getPropertyAccessors());
for (PropertyAccessor accessor : accessorsToTry) {
if (accessor.canWrite(this.evaluationContext, this.targetObject, this.name)) {
Indexer.this.cachedWriteName = this.name;
Indexer.this.cachedWriteTargetType = contextObjectClass;
Indexer.this.cachedWriteAccessor = accessor;
accessor.write(this.evaluationContext, this.targetObject, this.name, newValue);
return;
}
}
}
catch (AccessException ex) {
throw new SpelEvaluationException(getStartPosition(), ex,
SpelMessage.EXCEPTION_DURING_PROPERTY_WRITE, this.name, ex.getMessage());
}
}
代码示例来源:origin: org.springframework/spring-expression
if (ex.getCause() instanceof InvocationTargetException) {
Throwable rootCause = ex.getCause().getCause();
if (rootCause instanceof RuntimeException) {
throw (RuntimeException) rootCause;
代码示例来源:origin: org.springframework/spring-context
@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");
}
代码示例来源:origin: org.springframework/spring-expression
throw new SpelEvaluationException(getStartPosition(), ex,
SpelMessage.EXCEPTION_DURING_METHOD_INVOCATION, this.name,
value.getClass().getName(), ex.getMessage());
代码示例来源:origin: apache/servicemix-bundles
/**
* Decode the AccessException, throwing a lightweight evaluation exception or,
* if the cause was a RuntimeException, throw the RuntimeException directly.
*/
private void throwSimpleExceptionIfPossible(Object value, AccessException ex) {
if (ex.getCause() instanceof InvocationTargetException) {
Throwable rootCause = ex.getCause().getCause();
if (rootCause instanceof RuntimeException) {
throw (RuntimeException) rootCause;
}
throw new ExpressionInvocationTargetException(getStartPosition(),
"A problem occurred when trying to execute method '" + this.name +
"' on object of type [" + value.getClass().getName() + "]", rootCause);
}
}
代码示例来源:origin: org.springframework/spring-context
@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");
}
代码示例来源:origin: spring-projects/spring-framework
name, ex.getMessage());
代码示例来源:origin: apache/servicemix-bundles
if (ex.getCause() instanceof InvocationTargetException) {
Throwable rootCause = ex.getCause().getCause();
if (rootCause instanceof RuntimeException) {
throw (RuntimeException) rootCause;
代码示例来源:origin: spring-projects/spring-framework
@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);
}
}
}
代码示例来源:origin: org.springframework/spring-expression
@Override
public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
BeanResolver beanResolver = state.getEvaluationContext().getBeanResolver();
if (beanResolver == null) {
throw new SpelEvaluationException(
getStartPosition(), SpelMessage.NO_BEAN_RESOLVER_REGISTERED, this.beanName);
}
try {
return new TypedValue(beanResolver.resolve(state.getEvaluationContext(), this.beanName));
}
catch (AccessException ex) {
throw new SpelEvaluationException(getStartPosition(), ex, SpelMessage.EXCEPTION_DURING_BEAN_RESOLUTION,
this.beanName, ex.getMessage());
}
}
内容来源于网络,如有侵权,请联系作者删除!