From: Juergen H. <jho...@us...> - 2006-04-21 00:14:23
|
Update of /cvsroot/springframework/spring/src/org/springframework/beans/factory/config In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19629/src/org/springframework/beans/factory/config Modified Files: Tag: mbranch-1-2 FieldRetrievingFactoryBean.java Log Message: backported fixes and enhancements from 2.0 M4 (HEAD) Index: FieldRetrievingFactoryBean.java =================================================================== RCS file: /cvsroot/springframework/spring/src/org/springframework/beans/factory/config/FieldRetrievingFactoryBean.java,v retrieving revision 1.4 retrieving revision 1.4.4.1 diff -C2 -d -r1.4 -r1.4.4.1 *** FieldRetrievingFactoryBean.java 9 Apr 2005 11:16:35 -0000 1.4 --- FieldRetrievingFactoryBean.java 21 Apr 2006 00:13:48 -0000 1.4.4.1 *************** *** 1,4 **** /* ! * Copyright 2002-2005 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); --- 1,4 ---- /* ! * Copyright 2002-2006 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); *************** *** 18,21 **** --- 18,22 ---- import java.lang.reflect.Field; + import java.lang.reflect.Modifier; import org.springframework.beans.factory.BeanNameAware; *************** *** 152,156 **** } ! // try to parse static field into class and field int lastDotIndex = this.staticField.lastIndexOf('.'); if (lastDotIndex == -1 || lastDotIndex == this.staticField.length()) { --- 153,157 ---- } ! // Try to parse static field into class and field. int lastDotIndex = this.staticField.lastIndexOf('.'); if (lastDotIndex == -1 || lastDotIndex == this.staticField.length()) { *************** *** 166,174 **** else if (this.targetField == null) { ! // either targetClass or targetObject specified throw new IllegalArgumentException("targetField is required"); } ! // try to get the exact method first Class targetClass = (this.targetObject != null) ? this.targetObject.getClass() : this.targetClass; this.fieldObject = targetClass.getField(this.targetField); --- 167,175 ---- else if (this.targetField == null) { ! // Either targetClass or targetObject specified. throw new IllegalArgumentException("targetField is required"); } ! // Try to get the exact method first. Class targetClass = (this.targetObject != null) ? this.targetObject.getClass() : this.targetClass; this.fieldObject = targetClass.getField(this.targetField); *************** *** 177,180 **** --- 178,186 ---- public Object getObject() throws IllegalAccessException { + if (!Modifier.isPublic(this.fieldObject.getModifiers()) || + !Modifier.isPublic(this.fieldObject.getDeclaringClass().getModifiers())) { + this.fieldObject.setAccessible(true); + } + if (this.targetObject != null) { // instance field |