Hi,
I'm trying to run the following code from Spring In Action given under the topic Writing a bean Post Processor.but it doesn't compile: it says "Field" cannot be resolved to a type
package src.java;
import org.springframework.beans.factory.config.*;
import org.springframework.beans.*;
public class Fuddifier implements BeanPostProcessor {
public Object postProcessAfterInitialization(
Object bean, String name) throws BeansException {
Field[] fields = bean.getClass().getDeclaredFields();
try {
for(int i=0; i < fields.length; i++) {
if(fields[i].getType().equals(
java.lang.String.class)) {
fields[i].setAccessible(true);
String original = (String) fields[i].get(bean);
fields[i].set(bean, fuddify(original));
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return bean;
}
private String fuddify(String orig) {
if(orig == null) return orig;
return orig.replaceAll("(r|l)", "w")
.replaceAll(" (R|L) ", "W");
}
public Object postProcessBeforeInitialization(
Object bean, String name) throws BeansException {
return bean;
}
}
Also "Registering Bean post Processors" topic is not so clear to me.
Please help
Shaila