On Jun 3, 2008, at 6:54 PM, David Blevins wrote:
This idea just popped into my head and I'm interested in thoughts.
So I've been racking my brain all throughout the 3.x cycle on a
possible good way to get an injection service of some kind into the
mix. Something that would allow you to annotate a test case for
example and say "inject me". Same would go for a standalone app
client or any object really.
We could of course make a class for this say InjectionManager.class
with a method "public void inject(Object o)" but who wants to bind
themselves directly to org.apache.openejb.* classes -- I wouldn't.
Then suddenly this came to me....
The javax.naming.Context.bind(*) methods are off limits anyway for
EJB-land, they don't do anything... So... what if we started co-
opting it for our own evil purposes :) We could start designating
special names that if you "bind" to them will perform specific
operations.
Say for example:
context.bind("<some-standard-prefix>/inject", myObject);
We'd take the myObject, scrape the annotations and inject everything
we could into the myObject instance.
Possibly going totally off into crazy-land, we could expose other apis
in this JNDI-RESTful way.
context.bind("<some-standard-prefix>/deploy", myFile);
context.bind("<some-standard-prefix>/undeploy", myFile);
If we ever get support for manipulating containers or resources at
runtime, we could even do:
context.bind("<some-standard-prefix>/system/<id>.<property>",
<value>);
As in:
context.bind("<some-standard-prefix>/system/myContainer.PoolSize",
100);
---
We could also support querying in this sort of JNDI-RESTful way. Say
for example:
Integer poolSize = (Integer) context.lookup("<some-standard-prefix>/
system/myContainer.PoolSize");
---
Certainly, interesting.
-David