Looking up the raw XA datasource?

63 views
Skip to first unread message

thje...@redhat.com

unread,
Apr 14, 2015, 12:23:41 PM4/14/15
to ironjaca...@googlegroups.com
Hi,

Is there a way with IronJacamar to look up the raw XADataSource. For example:

XADataSource foo = (XADataSource)jndi.lookup("java:/ExampleDS")

Thanks!

Jesper Pedersen

unread,
Apr 14, 2015, 12:30:41 PM4/14/15
to ironjaca...@googlegroups.com
That isn't supported, as it would allow access to the application to create connections, and thereby bypassing the JCA container - investigated through https://issues.jboss.org/browse/JBJCA-657

At least there would be a lot involved to support a scenario like that which has side effects, f.ex. no access to underlying API.

HTH


thje...@redhat.com

unread,
Apr 15, 2015, 6:51:40 AM4/15/15
to ironjaca...@googlegroups.com
Thanks for the response. I can see we used to use a method to configure the same XADataSource as the container in older version of Narayana: http://anonsvn.jboss.org/repos/labs/labs/jbosstm/branches/JBOSSTS_4_6_1_GA_CP/atsintegration/classes/com/arjuna/ats/internal/jbossatx/jta/AppServerJDBCXARecovery.java but it wasn't as simple as looking up the DS, it was a set of JMX calls to get the parameters to do that:
ObjectName objectName = new ObjectName("jboss.jca:name="+_dataSourceId+",service=ManagedConnectionFactory");
String className = (String)server.invoke(objectName, "getManagedConnectionFactoryAttribute", new Object[] {"XADataSourceClass"}, new String[] {"java.lang.String"});
String properties = (String)server.invoke(objectName, "getManagedConnectionFactoryAttribute", new Object[] {"XADataSourceProperties"}, new String[] {"java.lang.String"});
ObjectName txCmObjectName = new ObjectName("jboss.jca:name=" +_dataSourceId + ",service=XATxCM");
String securityDomainName = (String) server.getAttribute(txCmObjectName, "SecurityDomainJndiName");
etc...

Is it possible to do anything similar with later revisions of IronJacamar at all (i.e. access the configuration for a datasource looked up by JNDI name)?

Jesper Pedersen

unread,
Apr 15, 2015, 8:05:59 AM4/15/15
to ironjaca...@googlegroups.com
You can do a similar trick.

  1. Look up javax.sql.DataSource
  2. Get a connection
  3. Reflect on the connection to get BaseWrapperManagedConnection ('mc')
  4. Check return value of isXA()
  5. If true, type cast to XAManagedConnection

This is of course completely unsupported, and you may have to change your code to follow the project.

If you are looking to deploy a <xa-datasource>, it is much simpler to do https://github.com/ironjacamar/ironjacamar/blob/1.2/adapters/src/test/java/org/jboss/jca/adapters/jdbc/unit/H2XATestCase.java

HTH

thje...@redhat.com

unread,
Apr 16, 2015, 7:02:13 AM4/16/15
to ironjaca...@googlegroups.com
It does help - thanks Jesper
Reply all
Reply to author
Forward
0 new messages