2 Replies Latest reply on Jul 10, 2006 1:55 PM by Gavin King

    Need help with ds.xml/datasource and Seam Injection

    Scott Huffman Newbie

      I've used struts in the past and have a new project that I'd like to do with Seam.

      I'm not incorporating hibernate due to my inexperience with it. I need to know how to inject a DataSource that's defined in ??-ds.xml in the deploy directory. There are circumstances where I need to access data in multiple databases from the same application so I have more than one defined here.

      Assume I have the following defined in the ds.xml file


      My pojo looks similar to this
      public class LoginAction implements Login {
       // What will get my datasource injected here?
       // I've tried countless variations.
       @In or @In(value="myDatasource") or ???
       private DataSource myDatasource;
       private User user; // Session scope
       public LoginAction() { }
       public String challenge() {
       String rtn;
       if(!user.isAuthenticated()) {
       // authentication logic here/ query the database to check role/access
       // if not authenticated set rtn = "invalid"
       // otherwise store user role/access in user object in session scope
       // User object should reside in session scope for interrogation on next request.
       return rtn;

      pages.xml looks like this to force authentication on every request
       <page view-id="*" action="#{loginAction.challenge}"/>

      What @In annotation will work here for myDatasource?
      I'm sure this is very simple but please, someone hold my hand. :-)