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 

  | <local-tx-datasource>
  |    <jndi-name>myDatasource</jndi-name>
  |    ....
  | </local-tx-datasource>
  | 
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;
  | 
  |    @In(create=true)
  |    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

  | <pages>
  |    <page view-id="*" action="#{loginAction.challenge}"/>
  | </pages>
  | 
What @In annotation will work here for myDatasource?
I'm sure this is very simple but please, someone hold my hand. :-)

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3956620#3956620

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3956620


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to