On 2/10/2010 11:40 PM, Rick R wrote:
certainly not very.) Feel free to let me know off-list how DI has
'really' helped - not some mythical Spinal Tap "Well this one goes to
11" argument.

DI has made code simpler in the EJB3 world. With EJB2, to obtain a JNDI datasource, you had to do lookups like this:

connection = ((DataSource) (new InitialContext()).lookup("java:comp/env/jdbc/troubleticketDB")).getConnection();

With EJB3, you simply annotate like this:

@Resource(type = DataSource.class, mappedName = "java:troubleticketDB")
   private DataSource          ds;

   connection = ds.getConnection();

Much more logical to work with. And because you are no longer doing lookups, you don't have to catch NamingExceptions throughout your code.

Syntactic sugar perhaps, but sweet.

--
Guy Rouillier

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
For additional commands, e-mail: user-java-h...@ibatis.apache.org

Reply via email to