See my comments inline.

--------------------------------------------------
From: "Scott Kurz" <[email protected]>
Sent: Thursday, May 21, 2009 6:48 AM
To: <[email protected]>
Subject: ideas for adding SDO HelperContext annotation/injector?

Say we wanted to invent an SCA annotation that injected an SDO
HelperContext into a Java impl field/method.    (A change to the SCA
programming model would need to be discussed, but I wanted to try it
out on a prototype).

Seems to be a good use case. Should we consider to use @Resource annotation (or SCA @Context) instead of creating our own?

http://java.sun.com/javaee/5/docs/api/javax/annotation/Resource.html


I was wondering what would be a nice way to do this?

Writing the class visitor seems easy enough, but what extension point
can I register it with?

Good question. We don't have a class visitor extension point today that allows you to declare your own extensions. The Tuscany visitors are added programmatically using the module activators. For now, you can do that too. Ideally, we should add a new extension point.


I can see how JavaImplementationProvider.handleResources() sets up an
ObjectFactory associated with the field/method name.   Not sure
precisely when/how this ObjectFactory gets called but I might not need
to;  writing this ObjectFactory would be easy enough.

But JavaImplementationProvider.handleResources() is hard-coded to only
look at a specific list:  ComponentContext, RequestContext, etc.

You find the right hook. We can provide an extension point for that too. Basically an injector will be added by a class visitor for each of the DI point. The injector is attached to a field or setter and it is backed by an ObjectFactory which is used to create an instance of the injected value upon the injection.


I don't think I want to introduce a dependency from impl-java-runtime
to databinding-sdo.   I'm not sure I can write a new
JavaImplementationProvider from scratch without dragging-in/rewriting
some of the other classes....

The IoC engine is coupled with Java implementation at this point. I think Luciano has refactored that out in 2.x.


Any ideas would be appreciated.

Thanks,
Scott

Reply via email to