This is possible but not extremely easy. There is an example of something similar for jboss 3 in the testsuite, in jca/test/DeployConnectionManagerUnitTestCase.java. The 2.4 code should be rather simpler since you only have to deal with one (XADataSourceLoader) mbean, not 3.
In JBoss 3, you can also deploy new datasources by deploying a *-ds.xml (jboss 3.2, cvs) or *-service.xml (3.0, 3.0.1) file. This is somewhat easier.