Ok, what we did seems to have worked, but if anyone has a better way to do this, or 
can see any potential problems, please let me know.

First, we made our deployer MBean depend on the ManagedConnectionFactory service for 
our datasource.  Without this dependency, our MBean was starting up and trying to 
modify the settings of the MCF before it was up and running.

In our MBean, as soon as we read the encrypted username and password, we lookup and 
call the setManagedConnectionFactoryAttribute method of the MCF.  This is illustrated 
by the following code...
        EncryptedProperties props = new EncryptedProperties("enc.properties"); 
        MBeanServer server = (MBeanServer) 
MBeanServerFactory.findMBeanServer(null).iterator().next();
        ObjectName objectName = new 
ObjectName("jboss.jca:service=ManagedConnectionFactory,name=EsmDS");
        server.invoke(objectName, "setManagedConnectionFactoryAttribute",
                new Object[] { "UserName", String.class, 
props.getProperty(BridgeProperties.DB_ACCOUNT_NAME) },
                new String[] { "java.lang.String", "java.lang.Class", 
"java.lang.Object" });
        server.invoke(objectName, "setManagedConnectionFactoryAttribute",
                new Object[] { "Password", String.class, 
props.getProperty(BridgeProperties.DB_ACCOUNT_PASSWORD) },
                new String[] { "java.lang.String", "java.lang.Class", 
"java.lang.Object" });

This approach appears to work since we are able to lookup the connection in jndi and 
obtain connections from it (without having to pass credentials to the ds in the 
getConnection call).  

Even though it works, the solution feels a little dirty to me.  For starters, I don't 
like the dependency that has been created between the datasource and our deployer 
service.  I am also worried that in the future this model will be broken when we move 
over to supporting the DB2 8.1 XADatasource.

Any ideas, or is this the best that we can do?

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

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


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to