twitter
    !! Tell us what you want to Learn / Know !!

Server Configurations

We said earlier that an application server is a collection of J2EE services. JBoss makes it easy to mix and match these services by grouping them in a directory structure called a Server Configuration. If you look in the JBOSS_HOME/server/ directory, you should see three named Server Configurations: all, default, and minimal.

If you don't specify a configuration on boot, JBoss uses the default configuration. The default configuration is the one that fulfills the J2EE 1.4 spec, so it is a reasonable place for most developers to start. The minimal configuration is bare dirt--nothing but a JNDI and a Log4j service. All is at the opposite end of the spectrum--everything in the minimal and default configurations, plus advanced services like clustering.

Let's shut down JBoss and start it with a different configuration. Press Ctrl-C in the JBoss console window to shut it down. Now type run -c minimal. You should see far fewer services launch and a dramatically shorter startup time.

Configuring JBoss Services:
A server configuration has three main subdirectories: conf/, deploy/, and lib/. The conf/ directory, as you might guess, contains configuration files. The main config file is jboss-service.xml. This is one place (but not the only place) where settings like port numbers can be found. The lib/ directory contains the JAR files that make up the JBoss services. The deploy/ directory contains the J2EE services, as well as any WAR and EAR files that should be deployed.

Services can be added and removed from a running JBoss instance through the magic of JMX (Java Management eXtensions). JMX is a framework that allows you to interact with live, running code. You can start and stop services, gather metrics, and even change parameters on the fly.

Services that implement the JMX interface are called "managed beans," or MBeans. Each of the J2EE services that run inside of JBoss is an MBean.

To see JMX in action, open a new terminal window next to the JBoss console, change to JBOSS_HOME/server/myapp/deploy, and create an undeploy/ directory. (It can be named anything you'd like, but undeploy/ is a common choice.) Move hsqldb-ds.xml to the undeploy/ directory and watch the JBoss console. You should see the Hypersonic database service shut down and all of the related services reconfigure themselves. Now move the file back from the undeploy/ directory to the deploy/ directory. Once again, JBoss recognizes the change in configuration and adjusts itself accordingly.

The XML file defining the MBean is another good place to look for port numbers. For instance, if you look at hsqldb-ds.xml, line 16 shows the port number that Hypersonic is configured to use.

Complex MBeans that require more than a simple XML file and a JAR in the lib/ directory can be deployed as a SAR (Service ARchive). Tomcat is a good example of this. Change to the jbossweb-tomcat50.sar/ directory, and you'll find the traditional server.xml file used to configure Tomcat, along with all of its dependent libraries.

0 comments:

Post a Comment