On Dec 30, 2008, at 1:35 PM, Gavin King wrote:
The spec requires that injection points be validated at init time
for
any Bean (for XxxxxDependencyException).
Nick from the RI team has noticed that for this to be implementable,
we need to add metadata about the injection points of a bean to the
Bean interface.
It shouldn't be necessary, since "SimpleBean implements Bean" should
be responsible for its own validation. It doesn't make sense for the
Manager implementation to validate the Bean, since that breaks the
encapsulation model of both Manager and Bean. It's cleaner for
Manager to assume the Bean is valid.
On a related note, it would be cleaner if the Bean.create() method was
changed to Bean.create(Context) in order to handle circular references.
The logic of Bean.create(Context) would be
1. check if Bean is in Context (for circular ref), if so return the
bean.
2. instantiate the Bean (do not inject/initialize) and put it in
Context (so we have a ref)
3. inject/initialize the bean as usual (this may trigger the
circular reference, which would be resolved by #1 on a second call).
-- Scott
I propose:
public abstract class Bean<X> {
...
Set<InjectionPoint> getInjectionPoints();
}
Since we already have the following interface that describes
injection points:
public interface InjectionPoint {
public Type getType();
public Set<Annotation> getBindingTypes();
public Object getInstance();
public Bean<?> getBean();
public Member getMember();
public <T extends Annotation> T getAnnotation(Class<T>
annotationType);
public Annotation[] getAnnotations();
public boolean isAnnotationPresent(Class<? extends Annotation>
annotationType);
}
I will make this change to the spec, unless anyone speaks up with
any objection.
--
Gavin King
gavin.king(a)gmail.com
http://in.relation.to/Bloggers/Gavin
http://hibernate.org
http://seamframework.org