<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="generator" content="Osso Notes">
<title></title></head>
<body>
<p>Pete,
<br>
<br>I agree, weld x would be the spot for it.
<br>
<br>Walter
<br>
<br>
<br>----- Original message -----
<br>> We definitely want something like this in WeldX.
<br>>
<br>> However I would argue we should follow the design of interceptors much
<br>> more closely.
<br>>
<br>> 1) The aroundInvoke method should take an InvocationContext, returning
<br>> null for getTarget (what is the reason for passing the proxy into the
<br>> method in the design below)? 2) Drop the interface implementation
<br>> requirement, and use the @AroundInvoke annotation 3) Add an annotation
<br>> used to find the handlers e.g. @ServiceHandler 4) Add a meta-annotation
<br>> @ServiceBinding(QueryInvocationHandler.class) @interface QueryService {}
<br>>
<br>> WDYT?
<br>>
<br>> On 28 Jun 2010, at 08:54, Stuart Douglas wrote:
<br>>
<br>> > After some discussions with Walter White I have added some
<br>> > experimental code to weld extensions to enable the automatic proxying
<br>> > of interfaces.
<br>> >
<br>> > To demonstrate how this works, here is a sample:
<br>> >
<br>> > @AutoProxy(QueryInvocationHandler.class)
<br>> > public interface QueryService<T> {};
<br>> >
<br>> > public interface UserQuery extends QueryService<User>
<br>> > {
<br>> >
<br>> > @Query("select u from user u where u.username=:1")
<br>> > public User findUserByUsername(String username);
<br>> >
<br>> > }
<br>> >
<br>> > public class QueryInvocationHandler implements InvocationHandler
<br>> > {
<br>> >
<br>> > @Inject EntityManager entityManager;
<br>> >
<br>> > public Object invoke(Object proxy, Method method, Object[] args)
<br>> > throws Throwable
<br>> > {
<br>> > //run the query based on the annotations on the method
<br>> > }
<br>> >
<br>> > }
<br>> >
<br>> > Any interface that extends QueryService will be automatically proxied
<br>> > by the container, using the InvocationHander specified in the
<br>> > @AutoProxy annotation. This proxy is registered as a bean, and if any
<br>> > qualifiers are present on the Interface being proxied these are added
<br>> > to the bean. It is also possible to inject into the InvocationHandler.
<br>> >  I also plan to make @AutoProxy a meta annotation, so the above could
<br>> > also be represented as:
<br>> >
<br>> >
<br>> > @AutoProxy(QueryInvocationHandler.class)
<br>> > public @interface QueryService{}
<br>> >
<br>> > @QueryService
<br>> > public interface UserQuery
<br>> > {
<br>> >
<br>> > @Query("select u from user u where u.username=:1")
<br>> > public User findUserByUsername(String username);
<br>> >
<br>> > }
<br>> >
<br>> > Does all this sound ok, or does it not have a strong enough use case
<br>> > to include it in Weld Extensions?
<br>> >
<br>> > Stuart
<br>>
<br><br></p>
</body>
</html>