AFAIK, this is not covered by the spec, and is against their philosophy, if not the letter, however I think this is a very reasonable capability. It is mostly implemented in jboss 3: there right now you can deploy a my-app-db-service.xml file containing the ConnectionFactoryLoader for your db instance (replaces XADataSourceLoader). We plan to make it possible to put such a file inside an ear, although I don't think it is implemented yet.
In jboss 2.4.x, you can apply the patch 443701 "make configuration service a deployer" and deploy a mini-jboss.jcml style file in deploy along with your app. You could also write an external application to create and configure the appropriate mbean using the jmx connector (or maybe it's an adapter)