I'm running JBoss AS 7.1.0.CR1b. I've got several datasources defined in my standalone.xml e.g.
<datasource jndi-name="java:/MyDS" pool-name="MyDS_Pool" enabled="true" use-java-context="true" use-ccm="true">
Everything works great.
I'm trying to access the information contained here within my code - specifically the `connection-url` and `driver` properties.
I've tried getting the Datasource from JNDI, as normal, but it doesn't appear to provide access to these properties:
// catches removed
DataSource dataSource = null;
context = new InitialContext();
dataSource = (DataSource) context.lookup(jndi);
ClientInfo and DatabaseMetadata from a Connection object from this Datasource also don't contain these granular, JBoss properties.
My code will be running inside the container with the datasource specfied, so all should be available. I've looked at the IronJacamar interface
, and its implementing class, and these seem to have accessible hooks to the information I require, but I can't find any information on how to create such objects with these already deployed resources within the container (only constructor on impl involves inputting all properties manually).
JBoss AS 7's Command-Line Interface allows you to navigate and list the datasources as a directory system. http://www.paykin.info/java/add-datasource-programaticaly-cli-jboss-7/ provides an excellent post on how to use what I've been told is the Java Management API, but this appears to involve connecting to the target JBoss server externally:
ModelControllerClient client = ModelControllerClient.Factory.create(
My code is already running within that server, so I was hoping there was a way to achieve this without a connection. Can I inject an instance of some JBoss class which I can then query to get the populated IronJacamar objects, or similar? Or is the Management API the best way to get at them?
Hope you can help, many thanks.