Action beans should/must be "prototype" scope ?
Tom Zeller
tzeller at dragonacea.biz
Thu Feb 13 17:07:43 EST 2014
Filling in some details :
> 2) BeanDefinition doesn't give you the actual Class of the bean, only the
> String name, so have to use something to load the Class instance from the
> name (perhaps not Class.forName(), maybe Thread context classloader, etc).
Spring provides a utility method to load a Class from a class name :
Class<?> beanClass = ClassUtils.resolveClassName(beanClassName,
ClassUtils.getDefaultClassLoader());
> 3) Most importantly: You probably already know this, but in Java annotations
> aren't "inherited" by design on Class instances. So assuming we'd want to be
> able to declare @Scope on superclasses and/or interfaces, this code would
> need to implement the annotation "inheritance" by traversing up the
> inheritance tree looking for the @Scope at each level (and each level's
> implemented interfaces if we wanted to support on interfaces).
Another Spring utility method traverses the inheritance tree looking
for an annotation :
Scope scope = AnnotationUtils.findAnnotation(beanClass, Scope.class);
More information about the dev
mailing list