I've found a way to dynamically create a datasource. Create a servlet that can return the "somedb-service.xml" formated xml data and then issue the following commands:
javax.management.MBeanServer server =
org.jboss.util.jmx.MBeanServerLocator.locate(null);
server.invoke(
new ObjectName("jboss.system:service=MainDeployer"),
"deploy",
new Object[] {
new String("http://localhost/<your servlet here>/somename-service.xml")},
new String[] {(java.lang.String.class).getName()});
There is undoubtedly a better way to invoke the deployer, but this works. The above URL does not reference an actual file, but is used to specify a temporary file to be used on the server. The servlet will return the xml needed to deploy the datasource. Has anyone found a better way to do this?