On Mar 11, 2009, at 7:43 PM, Karan Malhi wrote:


Definitely. We went with the new class over the InitialContext as it gives us the ability to add methods and functionality in future specs. Always a
nice door to leave open.

EJBContainer container = EJBContainer.createEJBContainer(p);


Would love to see some more methods in EJBContainer like

public Object inject(Class clazz){
// creates a new instance of the clazz and injects dependencies in it and
returns the object
}
public void inject(Object obj){
 // inject dependencies into obj
}

The above would make it easy to add injection support to other frameworks
like struts, jsf etc.

You and me both. There was talk of general functionality like that at the JSR-316 (EE 6) level and as a result there was moratorium on identical functionality in the other specs. The talks stalled and nothing was ever flushed out. Now it's too late.

Regardless, that won't stop us from implementing it :) I suspect if we do it and other vendors follow suit, it'll pretty much have to make it into the spec next time around.

Would also be nice to have a method which returns the current instance of
the  EJBContainer.

We had something like that and it got messy quick. The questions it raises are 1) what happens if it is called before createEJBContainer and no instance has yet been created; do you create one automatically, return null, or throw an exception, 2) what happens if it is called after the EJBContainer has been closed 3) if more than one EJBContainer is active and the most recently created one is closed, do you return the current closed container, the most recent open container, null, or throw an exception.

I personally never liked it as 'public static EJBContainer ejbContainer' in your own code is extremely simple and doesn't require people to learn anything, reduces the amount of new things they have to deal with, and there's zero chance for misinterpreting the spec.

-David

Reply via email to