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

JBoss Global Defaults

JBoss global defaults are defined in the standardjbosscmp-jdbc.xml file of the server/<server-name>/conf/ directory. Each application can override the global defaults in the jbosscmp-jdbc.xml file. The default options are contained in a defaults element of the configuration file, and the content model of defaults is shown in Figure 11.16.

Figure 11.16. The jbosscmp-jdbc.xml defaults content model.


An example of the defaults section follows:

<jbosscmp-jdbc>
    <defaults>
        <datasource>java:/DefaultDS</datasource>
        <datasource-mapping>Hypersonic SQL</datasource-mapping>
        <create-table>true</create-table>
        <remove-table>false</remove-table>
        <read-only>false</read-only>
        <read-time-out>300000</read-time-out>
        <pk-constraint>true</pk-constraint>
        <fk-constraint>false</fk-constraint>
        <row-locking>false</row-locking>
        <preferred-relation-mapping>foreign-key</preferred-relation-mapping>
        <read-ahead>
            <strategy>on-load</strategy>
            <page-size>1000</page-size>
            <eager-load-group>*</eager-load-group>
        </read-ahead>
        <list-cache-max>1000</list-cache-max>
    </defaults>
</jbosscmp-jdbc>

A Sample jbosscmp-jdbc.xml Defaults Declaration

Each of the following jbosscmp-jdbc.xml options can apply to entities, relationships, or both, and can be overridden in the specific entity or relationship:

  • datasource This optional element is the jndi-name that is used to look up the datasource. All database connections used by an entity or relation-table are obtained from the datasource. Having different datasources for entities is not recommended because it vastly constrains the domain over which finders and ejbSelects can query.

  • datasource-mapping This optional element specifies the name of the type-mapping, which determines how Java types are mapped to SQL types and how EJB-QL functions are mapped to database-specific functions. Type mappings are discussed in the section "Mapping," later in this chapter.

  • create-table When this optional element is TRue, JBoss attempts to create a table for the entity. When the application is deployed, JBoss checks whether a table already exists before creating the table. If a table is found, it is logged, and the table is not created. This option is very useful during the early stages of development, when the table structure changes often. The default is false.

  • alter-table If create-table is used to automatically create the schema, you can use alter-table to keep the schema current with changes to the entity bean. This element performs the following specific tasks:

    It creates new fields.

    It removes fields that are no longer used.

    It increases the length of string fields that are shorter than the declared length to the declared length. (This is not supported by all databases.)

  • remove-table When this optional element is TRue, JBoss attempts to drop the table for each entity and each relation table mapped relationship. When the application is undeployed, JBoss attempts to drop the table. This option is very useful during the early stages of development, when the table structure changes often. The default is false.

  • read-only When this optional element is TRue, the bean provider is not allowed to change the values of any fields. A field that is read-only is not stored in or inserted into the database. If a primary key field is read-only, the create method throws a CreateException. If a set accessor is called on a read-only field, it throws an EJBException. Read-only fields are useful for fields that are filled in by database triggers, such as last updates. You can override the read-only option on a per-field basis. The default is false.

  • read-time-out This optional element is the amount of time, in milliseconds, that a read on a read-only field is valid. A value of 0 means that the value is always reloaded at the start of a transaction, and a value of -1 means that the value never times out. You can override this option on a per-CMP-field basis. If read-only is false, this value is ignored. The default is -1.

  • row-locking If this optional element is true, JBoss locks all rows that are loaded in a transaction. Most databases implement this by using the SELECT FOR UPDATE syntax when loading the entity, but the actual syntax is determined by the row-locking-template in the datasource-mapping used by this entity. The default is false.

  • pk-constraint If this optional element is true, JBoss adds a primary key constraint when creating tables. The default is true.

  • preferred-relation-mapping This optional element specifies the preferred mapping style for relationships. The preferred-relation-mapping element must be either foreign-key or relation-table.

  • read-ahead This optional element controls caching of query results and CMR fields for the entity. This option is discussed earlier in this chapter, in the section "Read-ahead."

  • list-cache-max This optional element specifies the number of read-lists that this entity can track. This option is discussed earlier in this chapter, in the section "The on-load Strategy." The default is 1000.

  • clean-read-ahead-on-load When an entity is loaded from the read-ahead cache, JBoss can remove the data used from the read-ahead cache. The default is false.

  • fetch-size This optional element specifies the number of entities to read in one round-trip to the underlying datastore. The default is 0.

  • unknown-pk This optional element allows you to define the default mapping of an unknown primary key type of java.lang.Object to the persistent store.

  • entity-command This optional element allows you to define the default command for entity creation. This is described in detail earlier in this chapter, in the section "Entity Commands and Primary Key Generation."

  • ql-compiler This optional elements allows a replacement query compiler to be specified. Alternate query compilers are discussed earlier in this chapter, in the section "EJB-QL 2.1 and SQL92 Queries."