Hi,
ConnectionManager, the current implementation of javax.sql.DataSource,
does not support 'res-auth' of 'resource-ref'.
The ConnectionManager returned from Context.lookup() always the one
whose 'user' and 'password' is set.
This may not matter for most case, but I've tried to modify
DataSourceFactory to return the appropriate ConnectionManager.
Given BeanDescriptor as one of the environment, DataSourceFactory can
determine whether it should set the user name and the password of
ConnectionManager.
Any comment and questions are welcome.
Note that I'm not the member of this mailing list. I wish to join the
list, but at this time, I have enough time to participate in.
So, please mail to me([EMAIL PROTECTED]) directly!
--
Happy Java programming!
Jun Inamori
E-mail: [EMAIL PROTECTED]
URL: http://www.oop-reserch.com
PS:
I attached the my source of DataSourceFactory. The diff for related
classes are the following:
diff -bwr modified_src//org/objectweb/jonas/container/Container.java
modified_org//org/objectweb/jonas/container/Container.java
111,113d110
< //Start:Jun Inamori
< context.addToEnvironment("BeanDesc",desc);
< //End:Jun Inamori
239,247d235
< //Start:Jun Inamori modified
< /**
< * Adm.stopServer()
< * -->Container.unbindBeans()
< * -->JSessionHome.removeInstance()
< */
< if(bbh instanceof JSessionHome){
< JSessionHome sh=(JSessionHome)bbh;
< sh.removeInstance();
249,250d236
< //End:Jun Inamori modified
< }
diff -bwr modified_src//org/objectweb/jonas/container/JBeanEntity.java
modified_org//org/objectweb/jonas/container/JBeanEntity.java
345,348d344
< //Start:Jun Inamori
< home.prepareDataSource();
< //End:Jun Inamori
<
diff -bwr modified_src//org/objectweb/jonas/container/JBeanHome.java
modified_org//org/objectweb/jonas/container/JBeanHome.java
331,345d330
< //Start:Jun Inamori
< public void prepareDataSource()
< throws RemoteException{
< Trace.outln(trace, "JBeanHome.prepareDataSource");
< try{
< Context context=NamingManager.getInitialContext();
< context.addToEnvironment("BeanDesc",ejbDescriptor);
< }
< catch (Exception e) {
< Trace.errln("prepareDataSource: " + e);
< throw new RemoteException("Container exception", e);
< }
< }
< //End:Jun Inamori
<
diff -bwr modified_src//org/objectweb/jonas/container/JBeanSession.java
modified_org//org/objectweb/jonas/container/JBeanSession.java
249,252d248
< //Start:Jun Inamori
< home.prepareDataSource();
< //End:Jun Inamori
<
diff -bwr modified_src//org/objectweb/jonas/container/JEntityHome.java
modified_org//org/objectweb/jonas/container/JEntityHome.java
279,282d278
< //Start:Jun Inamori
< prepareDataSource();
< //End:Jun Inamori
<
diff -bwr modified_src//org/objectweb/jonas/container/JSessionHome.java
modified_org//org/objectweb/jonas/container/JSessionHome.java
43,46d42
< //Start:Jun Inamori modified
< import java.util.Vector;
< import java.util.Enumeration;
< //End:Jun Inamori modified
60,63d55
< //Start:Jun Inamori modified
< public Vector session_obj=new Vector();
< //End:Jun Inamori modified
<
115,123d106
< //Start:Jun Inamori
< try{
< prepareDataSource();
< }
< catch(Exception ex){
< Trace.errln("Can't prepare DataSource :"+ex);
< }
< //End:Jun Inamori
<
138,153d120
< //Start:Jun Inamori modified
< /**
< * Adm.stopServer()
< * -->Container.unbindBeans()
< * -->JSessionHome.removeInstance()
< */
< public void removeInstance() throws RemoteException{
< Trace.outln(trace,"removeInstance()");
< Enumeration en=session_obj.elements();
< String mess="";
< String ln=System.getProperty("line.separator");
< while(en.hasMoreElements()){
< JBeanSession sb=(JBeanSession)en.nextElement();
< if(!sb.nosuchobject){
< try{
< sb.remove();
155,169d121
< catch(RemoteException ex){
< mess+=ex.getMessage()+ln;
< }
< catch(RemoveException ex){
< mess+=ex.getMessage()+ln;
< }
< }
< }
< if(!mess.equals("")){
< throw (new RemoteException(mess));
< }
< }
< //End:Jun Inamori modified
<
< }
diff -bwr modified_src//org/objectweb/jonas/dbm/ConnectionManager.java
modified_org//org/objectweb/jonas/dbm/ConnectionManager.java
425,440d424
< //Start:Jun Inamori modified
< /**
< * Adm.stopServer()
< * -->DataBaseManager.unbindDataSources()
< * -->ConnectionManager.closeAllConnection()
< * -->Pool.closeAllConnection()
< */
< public void closeAllConnection(){
< Trace.outln(trace,"Pool.closeAllConnection()");
< Enumeration e=hXAC2Item.keys();
< try{
< while(e.hasMoreElements()) {
< XAConnection xc=(XAConnection)e.nextElement();
< Connection conn=xc.getConnection();
< if(!conn.isClosed()){
< xc.close();
442,448d425
< }
< }catch(java.sql.SQLException ex) {
< Trace.errln(ex.toString());
< }
< }
< //End:Jun Inamori modified
< }
544,554d520
< //Start:Jun Inamori
< /**
< * @serial default user
< */
< private String old_userName = null;
< /**
< * @serial default passwd
< */
< private String old_password = null;
< //End:Jun Inamori
<
613,615d578
< //Start:Jun Inamori
< if(s!=null){
< old_userName=s;
617,618d579
< //End:Jun Inamori
< }
628,630d588
< //Start:Jun Inamori
< if(s!=null){
< old_password=s;
632,633d589
< //End:Jun Inamori
< }
930,933c886,887
< //Start:Jun Inamori
< ref.add(new StringRefAddr("datasource.username",
old_userName));
< ref.add(new StringRefAddr("datasource.password",
old_password));
< //End:Jun Inamori
---
> ref.add(new StringRefAddr("datasource.username", getUserName()));
> ref.add(new StringRefAddr("datasource.password", getPassword()));
946,957d899
< //Start:Jun Inamori modified
< /**
< * Adm.stopServer()
< * -->DataBaseManager.unbindDataSources()
< * -->ConnectionManager.closeAllConnection()
< * -->Pool.closeAllConnection()
< */
< public void closeAllConnection(){
< Trace.outln(trace,"ConnectionManager.closeAllConnection()");
< pool.closeAllConnection();
< }
< //End:Jun Inamori modified
DataSOurceFactory.java