I want to do some more advanced dependency injection (DAOs and other
service objects) so I started looking at Spring integration. I have
some questions.
First, do I have a correct picture of how it works? (I will definitely
put this on the Wiki; the page on Spring integration is tiny at the
moment.)
- RIFE is the outermost entity (that is, Spring is a service
managed by RIFE, not the other way around).
- Each RIFE participant can supply values for properties that are
declared in the site declaration or element declarations or wherever.
The Spring participant simply supplies beans to RIFE based on the bean
names.
- RIFE does the actual injection of values into elements and other
RIFE-managed objects.
- Spring does the wiring of dependencies between Spring-managed
beans; RIFE does no injection of values into objects Spring
instantiates.
- It would be a bad idea to list the same object in both the Spring
and the RIFE configuration since only one or the other would actually
do any dependency injection.
Assuming I'm correct about how it works, is the intended usage as
follows if I want everything to be autowired as much as possible?
- Declare all my service objects in Spring and let it wire them up.
- Declare all my elements in the RIFE configuration as usual.
- Also declare each service object in my RIFE site definition (so
they don't have to be declared for individual elements). They are just
declared as <property name="foobarService" />.
- In my element classes, provide setters of compatible types for
both the Spring beans and the RIFE-managed resources like Datasource
objects.
And assuming I've got *that* more or less right, I am unclear on how to
do one more thing: pass a RIFE-managed resource into the Spring world
for autowiring. The simple example would be a DAO that uses RIFE's
database APIs; I will need to use Spring to instantiate that DAO and
wire it with other non-element objects, but the DAO needs to be
injected with a Datasource object in order to use the RIFE APIs. How do
I tell RIFE and Spring that there's this externally-supplied object
that should be added to the autowiring mix?
The only clean solution I can think of is to write a factory class for
the Spring side that does static method calls to grab a Datasource from
RIFE. That seems wasteful, though -- there ought to be some way for
RIFE to inject dependencies into Spring, since it has already made a
Datasource for me.
What would be swell would be a Spring participant that automatically
adds all the Spring beans to the list of global RIFE properties. That
way you wouldn't have to list the beans in two places.
-Steve
|
_______________________________________________
Rife-users mailing list
[email protected]
http://lists.uwyn.com/mailman/listinfo/rife-users