not sure if this got solved in the meantime, but javaagent was pure pita when I tried it,
since it doesn't work well with complicated classloader hierarchies. It always used
the SystemClassLoader instead of the webapp classloaders where my JPA libs did reside. But
maybe it was only my bad...
LieGrue,
strub
--- On Sun, 11/14/10, Marius Bogoevici <mariusb(a)redhat.com> wrote:
From: Marius Bogoevici <mariusb(a)redhat.com>
Subject: Re: [weld-dev] Automatic non contextual injection using bytecode
instrumentation
To: "Stuart Douglas" <stuart.w.douglas(a)gmail.com>
Cc: "Weld" <weld-dev(a)lists.jboss.org>
Date: Sunday, November 14, 2010, 11:08 PM
I think it would be something nice to
have. For example, Spring does this via @Configurable,
backed by AspectJ.
I think that exploring bytecode instrumentation would be
interesting for Weld,and I have for some time considered the
possibility of using it as an option for
interception/decoration as well.
Regarding javaagent: for certain classloaders that support
instrumentation and registering a ClassFileTransformer
directly, we may forgo using a javaagent altogether and
register the transformer during the bootstrap process. In
the least, this would possible with Tomcat,
Glassfish(partly) and JBoss.
On 2010-11-14, at 5:35 PM, Stuart Douglas wrote:
> I just had an idea for something that I think would be
rather cool,
> and allow objects created using new to be injected
automatically.
>
> Conceptually it would look something like this:
>
> @AutoInject
> public class AccountService
> {
> private final Account account;
>
> @Inject
> private PaymentProcessor paymentProcessor;
>
> AccountService(Account account)
> {
> this.account = account;
> }
>
> public void doPayment(double amount)
> {
> paymentProcessor.processPayment(account,
amount);
> }
> }
>
> We could then create the object using new and the
fields will still be injected:
>
> AccountService a = new AccountService(account);
> a.doPayment(10);
>
> To implement this will require a javaagent, which will
modify the
> bytecode of @AutoInject annotated classes as they are
loaded, so that
> the constructor bytecode looks up the values to inject
and sets the
> injected field values appropriately. Would this be
something that is
> worth putting into weld extensions?
>
> Stuart
> _______________________________________________
> weld-dev mailing list
> weld-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/weld-dev
_______________________________________________
weld-dev mailing list
weld-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/weld-dev