本文整理汇总了Java中org.springframework.beans.NotReadablePropertyException类的典型用法代码示例。如果您正苦于以下问题:Java NotReadablePropertyException类的具体用法?Java NotReadablePropertyException怎么用?Java NotReadablePropertyException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NotReadablePropertyException类属于org.springframework.beans包,在下文中一共展示了NotReadablePropertyException类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processConstraintViolations
import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
@Override
protected void processConstraintViolations(Set<ConstraintViolation<Object>> violations, Errors errors) {
for (ConstraintViolation<Object> violation : violations) {
String field = violation.getPropertyPath().toString();
FieldError fieldError = errors.getFieldError(field);
if (fieldError == null || !fieldError.isBindingFailure()) {
try {
String errorCode = violation.getConstraintDescriptor().getAnnotation().annotationType().getSimpleName();
Object[] errorArgs = getArgumentsForConstraint(errors.getObjectName(), field, violation.getConstraintDescriptor());
// NOTE: Super implementation of getInvalidValue() failed on a nested component.
// E.g. LocalizedString.fi returned LocalizedString instead of String as invalidValue
errors.rejectValue(field, errorCode, errorArgs, violation.getMessage());
}
catch (NotReadablePropertyException ex) {
throw new IllegalStateException("JSR-303 validated property '" + field +
"' does not have a corresponding accessor for Spring data binding - " +
"check your DataBinder's configuration (bean property versus direct field access)", ex);
}
}
}
}
示例2: testGetValueModelFromPAS
import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
public void testGetValueModelFromPAS() {
TestBean p = new TestBean();
TestPropertyAccessStrategy tpas = new TestPropertyAccessStrategy(p);
AbstractFormModel fm = getFormModel(tpas, true);
ValueModel vm1 = fm.getValueModel("simpleProperty");
assertEquals(1, tpas.numValueModelRequests());
assertEquals("simpleProperty", tpas.lastRequestedValueModel());
ValueModel vm2 = fm.getValueModel("simpleProperty");
assertEquals(vm1, vm2);
assertEquals(1, tpas.numValueModelRequests());
try {
fm.getValueModel("iDontExist");
fail("should't be able to get value model for invalid property");
}
catch (NotReadablePropertyException e) {
// exprected
}
}
示例3: createNotReadablePropertyException
import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
protected NotReadablePropertyException createNotReadablePropertyException(String propertyName, Exception e) {
if (JdkVersion.isAtLeastJava14()) {
NotReadablePropertyException beanException = new NotReadablePropertyException(getTargetClass(),
propertyName);
beanException.initCause(e);
return beanException;
}
else {
ByteArrayOutputStream stackTrace = new ByteArrayOutputStream();
PrintWriter stackTraceWriter = new PrintWriter(stackTrace);
e.printStackTrace(stackTraceWriter);
stackTraceWriter.close();
return new NotReadablePropertyException(getTargetClass(), propertyName,
new String(stackTrace.toByteArray()));
}
}
示例4: getValue
import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
@Override
public Object getValue(String paramName) throws IllegalArgumentException {
try {
return this.beanWrapper.getPropertyValue(paramName);
}
catch (NotReadablePropertyException ex) {
throw new IllegalArgumentException(ex.getMessage());
}
}
示例5: isSecure
import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
/**
* Checks whether the given property is secure.
*
* @param wrappedClass class the property is associated with
* @param propertyPath path to the property
* @return boolean true if the property is secure, false if not
*/
protected boolean isSecure(Class<?> wrappedClass, String propertyPath) {
if (KRADUtils.isSecure(propertyPath, wrappedClass)) {
return true;
}
// since this is part of a set, we want to make sure nested paths grow
setAutoGrowNestedPaths(true);
BeanWrapperImpl beanWrapper;
try {
beanWrapper = getBeanWrapperForPropertyPath(propertyPath);
} catch (NotReadablePropertyException | NullValueInNestedPathException e) {
LOG.debug("Bean wrapper was not found for " + propertyPath
+ ", but since it cannot be accessed it will not be set as secure.", e);
return false;
}
if (org.apache.commons.lang.StringUtils.isNotBlank(beanWrapper.getNestedPath())) {
PropertyTokenHolder tokens = getPropertyNameTokens(propertyPath);
String nestedPropertyPath = org.apache.commons.lang.StringUtils.removeStart(tokens.canonicalName,
beanWrapper.getNestedPath());
return isSecure(beanWrapper.getWrappedClass(), nestedPropertyPath);
}
return false;
}
示例6: getValue
import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
public Object getValue(String paramName) throws IllegalArgumentException {
try {
return this.beanWrapper.getPropertyValue(paramName);
}
catch (NotReadablePropertyException ex) {
throw new IllegalArgumentException(ex.getMessage());
}
}
示例7: testWriteOnlyProperty
import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
public void testWriteOnlyProperty() {
vm = pas.getPropertyValueModel("writeOnly");
vm.setValue("2");
assertEquals("2" , testBean.writeOnly);
try {
vm.getValue();
fail("should have thrown NotReadablePropertyException");
} catch(NotReadablePropertyException e) {
// expected
}
}
示例8: getIndexedPropertyValue
import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
public Object getIndexedPropertyValue(String propertyName) throws BeansException {
if (getPropertyType(propertyName) == null) {
throw new NotReadablePropertyException(getTargetClass(), propertyName,
"property type could not be determined");
}
String rootPropertyName = getRootPropertyName(propertyName);
Member readAccessor = getReadPropertyAccessor(rootPropertyName);
if (readAccessor == null) {
throw new NotReadablePropertyException(getTargetClass(), propertyName,
"Neither non-static field nor get-method exists for indexed property");
}
Object rootProperty = getPropertyValue(rootPropertyName);
if (rootProperty == null) {
if (isStrictNullHandlingEnabled()) {
throw new NullValueInNestedPathException(getTargetClass(), propertyName);
}
else if (isWritableProperty(rootPropertyName)) {
return null;
}
else {
throw new NotReadablePropertyException(getTargetClass(), propertyName);
}
}
Object[] indices;
try {
indices = getIndices(propertyName);
}
catch (Exception e) {
// could not convert indices
throw createNotReadablePropertyException(propertyName, e);
}
return getPropertyValue(rootProperty, indices);
}
示例9: getPropertyValue
import org.springframework.beans.NotReadablePropertyException; //导入依赖的package包/类
@Override
public Object getPropertyValue(String propertyName) throws BeansException {
Field field = this.fieldMap.get(propertyName);
if (field == null) {
throw new NotReadablePropertyException(
this.target.getClass(), propertyName, "Field '" + propertyName + "' does not exist");
}
try {
ReflectionUtils.makeAccessible(field);
return field.get(this.target);
}
catch (IllegalAccessException ex) {
throw new InvalidPropertyException(this.target.getClass(), propertyName, "Field is not accessible", ex);
}
}