There is already an example - look at server/default/conf/jboss-login.xml, search for the "jbossmq" security domain.
You can also search the documentation for DatabaseServerLoginModule.
Wait a second, I just now noticed that you asked this in the JBoss Web Server forum. My answer was for JBoss Application Server, not JBoss Web Server. I do not know how to do this for JBoss Web Server.