More Books
JBoss 4.0 The Official Guide
JBoss® 4.0 The Official Guide
Table of Contents
Copyright
About the Authors
We Want to Hear from You!
Introduction
What This Book Covers
About JBoss
About Open Source
About Professional Open Source
What's New in JBoss 4.0
Chapter 1.  Installing and Building the JBoss Server
Getting the Binary Files
Installing the Binary Package
Basic Installation Testing
Booting from a Network Server
Building the Server from Source Code
Chapter 2.  The JBoss JMX Microkernel
JMX
The JBoss JMX Implementation Architecture
Connecting to the JMX Server
Using JMX as a Microkernel
The JBoss Deployer Architecture
Exposing MBean Events via SNMP
Remote Access to Services, Detached Invokers
Chapter 3.  Naming on JBoss
An Overview of JNDI
The JBossNS Architecture
Chapter 4.  Transactions on JBoss
Transaction and JTA Overview
JBoss Transaction Internals
Chapter 5.  EJBs on JBoss
The EJB Client-Side View
The EJB Server-Side View
The EJB Container
Entity Bean Locking and Deadlock Detection
Chapter 6.  Messaging on JBoss
JMS Examples
JBossMQ Overview
JBossMQ Configuration and MBeans
Specifying the MDB JMS Provider
Chapter 7.  Connectors on JBoss
JCA Overview
An Overview of the JBossCX Architecture
Configuring JDBC Datasources
Configuring Generic JCA Adaptors
Chapter 8.  Security on JBoss
J2EE Declarative Security Overview
An Introduction to JAAS
The JBoss Security Model
The JBossSX Architecture
The Secure Remote Password (SRP) Protocol
Running JBoss with a Java 2 Security Manager
Using SSL with JBoss and JSSE
Configuring JBoss for Use Behind a Firewall
Securing the JBoss Server
Chapter 9.  Web Applications
The Tomcat Service
The Tomcat server.xml File
The Engine Element
The Host Element
Using SSL with the JBoss/Tomcat Bundle
Setting the Context Root of a Web Application
Setting Up Virtual Hosts
Serving Static Content
Using Apache with Tomcat
Using Clustering
Integrating Third-Party Servlet Containers
Chapter 10.  MBean Services Miscellany
System Properties Management
Property Editor Management
Services Binding Management
Scheduling Tasks
The Log4j Service MBean
RMI Dynamic Class Loading
Chapter 11.  The CMP Engine
Example Code
The jbosscmp-jdbc Structure
Entity Beans
CMP Fields
Container-Managed Relationships
Declaring Queries
Optimized Loading
The Loading Process
Transactions
Optimistic Locking
Entity Commands and Primary Key Generation
JBoss Global Defaults
Datasource Customization
Chapter 12.  Web Services
JAX-RPC Service Endpoints
Enterprise JavaBean Endpoints
Web Services ClientsA JAX-RPC Client
Service References
Chapter 13.  Hibernate
The Hibernate MBean
Hibernate Archives
Using Hibernate Objects
Using a HAR File Inside an EAR File
The HAR Deployer
Chapter 14.  Aspect-Oriented Programming (AOP) Support
JBoss AOP: EJB-Style Services for Plain Java Objects
Why AOP?
Basic Concepts of AOP
Building JBoss AOP Applications
The JBoss AOP Deployer
Packaging and Deploying AOP Applications to JBoss
Appendix A.  The GNU Lesser General Public License (LGPL)
GNU General Public License
Appendix B.  Example Installation
Index
SYMBOL
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X

The JBoss Deployer Architecture

JBoss has an extensible deployer architecture that allows you to incorporate components into the bare JBoss JMX microkernel. MainDeployer is the deployment entry point. Requests to deploy a component are sent to MainDeployer, which determines whether there is a subdeployer capable of handling the deployment; if there is, it delegates the deployment to the subdeployer. (You saw an example of this earlier in this chapter, when you looked at how MainDeployer uses the SARDeployer to deploy MBean services.) The following are some of the deployers provided with JBoss:

  • AbstractWebDeployer This subdeployer handles WARs. It accepts deployment archives and directories whose names end with the .war suffix. WARs must have a WEB-INF/web.xml descriptor and may have a WEB-INF/jboss-web.xml descriptor.

  • EARDeployer This subdeployer handles EARs. It accepts deployment archives and directories whose names end with the .ear suffix. EARs must have a META-INF/application.xml descriptor and may have a META-INF/jboss-app.xml descriptor.

  • EJBDeployer This subdeployer handles Enterprise Bean JARs. It accepts deployment archives and directories whose names end with the .jar suffix. EJB JARs must have a META-INF/ejb-jar.xml descriptor and may have a META-INF/jboss.xml descriptor.

  • JARDeployer This subdeployer handles library JAR archives. The only restriction it places on an archive is that it cannot contain a WEB-INF directory.

  • RARDeployer This subdeployer handles JCA RARs. It accepts deployment archives and directories whose names end with the .rar suffix. RARs must have a META-INF/ra.xml descriptor.

  • SARDeployer This subdeployer handles JBoss MBean SARs. It accepts deployment archives and directories whose names end with the .sar suffix, as well as standalone XML files that end with service.xml. SARs that are JARs must have a META-INF/jboss-service.xml descriptor.

  • XSLSubDeployer This subdeployer deploys arbitrary XML files. JBoss uses XSLSubDeployer to deploy ds.xml files and transform them into service.xml files for SARDeployer. However, it is not limited to just this task.

  • HARDeployer This subdeployer deploys HARs. It accepts deployment archives and directories whose names end with the .har suffix. HARs must have a META-INF/hibernate-service.xml descriptor.

  • AspectDeployer This subdeployer deploys AOP archives. It accepts deployment archives and directories whose names end with the .aop suffix as well as aop.xml files. AOP archives must have a METAINF/jboss-aop.xml descriptor.

  • ClientDeployer This subdeployer deploys J2EE application clients. It accepts deployment archives and directories whose names end with the .jar suffix. J2EE clients must have a META-INF/application-client.xml descriptor and may have a META-INF/jboss-client.xml descriptor.

  • BeanShellSubDeployer This subdeployer deploys bean shell scripts as MBeans. It accepts files whose names end with the .bsh suffix.

MainDeployer, JARDeployer, and SARDeployer are hard-coded deployers in the JBoss server core. All other deployers are MBean services that register themselves as deployers with the MainDeployer by using the addDeployer(SubDeployer) operation.

MainDeployer communicates information about the component to be deployed to the SubDeployer by using a DeploymentInfo object. The DeploymentInfo object is a data structure that encapsulates the complete state of a deployable component.

When MainDeployer receives a deployment request, it iterates through its registered subdeployers and invokes the accepts(DeploymentInfo) method on the subdeployer. The first subdeployer to return true is chosen. The MainDeployer will delegate the init, create, start, stop, and destroy deployment life cycle operations to the subdeployer.

Deployers and Class Loaders

Deployers are the mechanism by which components are brought into a JBoss server. Deployers are also the creators of the majority of UCL instances, and the primary creator is MainDeployer. MainDeployer creates the UCL for a deployment early on during its init method. The UCL is created by calling the DeploymentInfo.createClassLoaders() method. Only the topmost DeploymentInfo actually creates a UCL. All subdeployments add their classpaths to their parent DeploymentInfo UCL. Every deployment does have a standalone URLClassLoader that uses the deployment URL as its path. This is used to localize the loading of resources such as deployment descriptors. Figure 2.20 provides an illustration of the interaction between deployers, DeploymentInfos, and class loaders.

Figure 2.20. The class loaders involved with an EAR deployment.


Figure 2.20 illustrates an EAR deployment with EJB and WAR subdeployments. The EJB deployment references the lib/util.jar utility JAR via its manifest. The WAR includes classes in its WEB-INF/classes directory as well as in WEB-INF/lib/jbosstest-web-util.jar. Each deployment has a DeploymentInfo instance that has a URLClassLoader pointing to the deployment archive. The DeploymentInfo associated with some.ear is the only one to have a UCL created. ejbs.jar and web.war DeploymentInfos add their deployment archives to the some.ear UCL classpath, and they share this UCL as their deployment UCL. The EJBDeployer also adds any manifest JARs to the EAR UCL.

The WARDeployer behaves differently than other deployers in that it only adds its WAR archive to the DeploymentInfo UCL classpath. The loading of classes from the WAR WEB-INF/classes and WEB-INF/lib locations is handled by the servlet container class loader. The servlet container class loaders delegate to the WAR DeploymentInfo UCL as their parent class loader, but the server container class loader is not part of the JBoss class loader repository. Therefore, classes inside a WAR are not visible to other components. Classes that need to be shared between web application components and other components such as EJBs and MBeans need to be loaded into the shared class loader repository either by including the classes in a SAR or EJB deployment or by referencing a JAR containing the shared classes through a manifest Class-Path entry. In the case of a SAR, the SAR classpath element in the service deployment serves the same purpose as a JAR manifest Class-Path.