[jboss-dev-forums] [Design of POJO Server] - Re: Generalizing dependency injection
wolfc
do-not-reply at jboss.com
Wed Mar 12 07:57:21 EDT 2008
"scott.stark at jboss.org" wrote : Working through the resolution implementation more, we want a simple lookup to resolve a reference, so the ejbName of the providing cannot be part of at least one form of the key. That is an unknown element from the point of view of the referencer. We need multiple keys for each provider, some of which may be non-unique.
| @EJB(beanInterface=X.class)
| translates to a lookup of the provider "ejb/X". If we have multiple providers of the X interface, only the first to be processed would be the provider? If we want to fail an attempt at injection of a non-unique provider, we would have to track the duplicate providers to thrown an exception with the duplicates.
|
Exception if there are multiple providers are found in the same ear.
"scott.stark at jboss.org" wrote :
| @EJB(beanInterface=X.class, name="XBean")
| translates to a lookup of "ejb/X/XBean". The ejb-name is only unique within an ejb-jar, so here again we can have duplicates sources matching this key.
We are talking MC lookups here, right?
"scott.stark at jboss.org" wrote :
| @EJB(beanInterface=X.class, name="some.jar#XBean")
| translates to a lookup of "ejb/X/some.jar/XBean". This is the only guaranteed unique key within a deployment.
And I say reverse the bind. So the bind becomes:
"ejb/X/some.jar/XBean"
some.jar:
| class TestBean { @EJB X a; }
Hooks java:comp/env/TestBean/a to MC "ejb/X/some.jar" (which is a map). If the during injection the map contains more than 1 item, exception.
@EJB(beanName="XBean") X b;
Hooks java:comp/env/TestBean/b to MC "ejb/X/some.jar/XBean".
@EJB(beanName="other.jar#XBean") X c;
Hooks java:comp/env/TestBean/c to MC "ejb/X/other.jar/XBean".
Note: 'name' is something else:
@EJB(name="x", beanName="XBean") X d;
Hooks java:comp/env/x to MC "ejb/X/some.jar/XBean".
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4135895#4135895
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4135895
More information about the jboss-dev-forums
mailing list