I like it. @Observable/@Obtainable probably covers 90% of the cases
where the user would normally work with a Manager
On 12/7/08, Gavin King <gavin(a)hibernate.org> wrote:
An issue that Bill brought up on the last concall, and that has been
bothering me for a while is that we have a few different cases where
the application wants to perform a dynamic lookup:
(1) when binding types vary at runtime
(2) when the dependency is optional
(3) when you want to obtain an object that belongs to a child manager
But the only way we let you do this is by injecting the Manager
object, which has really evolved into an SPI-type integration point
and has a whole bundle of operations that should not really be in the
view of the application. Furthermore, it requires use of
AnnotationLiteral for all binding types, which is pretty nasty.
So I think we need to provide a different API, one that is more
appropriate to usage by the application.
Other solutions do have sugar for this: Guice has an injectable
Provider<T> interface, Spring let's you write an abstract method which
is implemented by the container.
I think we should model a lookup interface on what we have for event
firing. Analogous to:
@Observable @SomeBinding Event<SomeEventType> someEvent;
We should let you inject:
@Obtainable @SomeBinding Instance<SomeType> someInstance;
Which would let you call someInstance.get() to obtain an instance of
the SomeType with SomeBinding.
This would involve the following new interface:
public interface Instance<T> {
public T get(Annotation... bindings);
public boolean isSatisfied(Annotation... bindings);
}
This is a *much* simpler API to use.
The isDefined() method would let you determine if any Web Bean exists
that satisfies the API type and bindings.
--
Gavin King
gavin.king(a)gmail.com
http://in.relation.to/Bloggers/Gavin
http://hibernate.org
http://seamframework.org
--
Gavin King
gavin.king(a)gmail.com
http://in.relation.to/Bloggers/Gavin
http://hibernate.org
http://seamframework.org
_______________________________________________
webbeans-dev mailing list
webbeans-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/webbeans-dev