There are plenty of examples in the jboss
distribution. The service configurator automatically
applies them to your mbean.
Is there any way you can create it like a weblogic startup class? Meaning you can pass in arguments from a property file, in this case an XML file?
I don't know what you mean,
you can pass properties, see the sql properties
passed to the jdbc2 persistence manager
You don't need to use MBeans. In the Servlet 2.3 spec, ServletContextListeners were introduced. Implement one of those and enter it an a war's web.xml file. Then add this war file to your ear that also contains your ejb-jar files (if you need more than just a web app). Then, you can trigger startup from the contextInitialized() method and shutdown on the contextDestroyed() method. This is a standard J2EE way of doing startup/shutdown hooks of J2EE applications, and is therefore appserver agnostic.
Oh yeah. If you can't use Servlet 2.3 spec, you can use a similar (though not as elegant) mechanism in 2.2. Write a Serlvet instead of a ServletContextListener, and do your startup/shutdown code in the init()/destroy() methods, respectively. Then in web.xml, register the servlet *and be sure to add* a <load-on-startup>1</load-on-startup> element (the # doesn't really matter unless you want to order it with other servlets).
To configure it, you can put a properties file or xml file in your jar next to the ServletContextListener (or Servlet) and load in the config using yourClass.getResource().