Before you write your own code. JBOSS EAP uses hibernate as the internal JPA implementation.
In Hibernate, you configure a session factory to a database. You can declare multiple session factories to multiple databases.
A very simple example is given
here.
You may also find it needed to dynamically determine the necessary session factory to run your queries or manage your object.
In that case, you can check Routing data source samples from spring.
Internally how spring does it is, it uses a key in the
thread local. You can do the same. Use the key from the thread local to get the needed session factory.