In this third part of a series that focuses on managing OC4J and configuring J2EE applications, we look at how to configure the OC4HJ server. It is excerpted from chapter eight of the Oracle 10g Application Server Exam Guide, written by Sam Alapati (McGraw-Hill; ISBN: 0072262710).
Besides the main OC4J configuration file, server.xml, several other OC4J server XML files help to configure the OC4J instance. Let’s take a quick look at these.
jazn.xml and jazn-data.xml The jazn-data.xml and the jazn.xml files are used for security configuration if you’re using the Java Authentication and Authorization (JAAS) Service. The file contains user and group configuration information for the default JAZNUserManager client-admin console.
The data-sources.xml file To make their applications portable across servers, application developers use logical representation of databases and publish these data sources in the Java Naming and Directory Interface (JNDI) tree. The applications retrieve database connections through javax.sql.dataSource objects and look up the objects through the JNDI. These objects are called data sources, and the deployer must specify the mapping between a logical dataSource object and the physical databases. The connection methods that are specified are used by the applications to connect to the specified database.
on the job: The properties and methods of the data source objects are specified by the javax.sql.DataSource interface.
The data-sources.xml file lets you configure OC4J database sources used by the various applications hosted by the OC4J instance. In addition, the file contains information on retrieving JDBC connections. The data-sources.xml file contains the following types of information:
Maximum number of database connections allowed
Username and password for the data source
JNDI name in the JNDI lookup, to retrieve the data source
Note that the data-sources.xml file establishes the data source object definitions at the OC4J instance level. These global data sources are specified by an XML tag, and the XML attributes for each data source include the JDBC connection string and sometimes the username and password information. All applications deployed in the OC4J container can share the data sources defined at the container level. Applications can also use application-specific data sources by incorporating the <data-sources> tag in the application.xml file to refer to the data-sources.xml file and directly use the data sources defined therein.
When the OC4J instance starts, it parses the data-sources.xml file, instantiates the DataSource objects, and binds them into the JNDI namespace. After you deploy an application, the application accesses the data sources by looking up the JNDI tree. Note that there’s a separate JNDI namespace for each application.
The different types of data sources, such as emulated and non-emulated data sources as well as native data sources, are discussed in detail later in this chapter. Here’s a typical data-sources.xml file showing how to use the Oracle JDBC driver to create a JDBC thin connection type data source:
In the sample data-sources.xml file, this is what the various elements stand for:
Class is the type of data resources or the DataSource class.
Name is the name of the data source—in our case, OracleDS, which is the default data source.
Location, xa-location, and ejb-location are the JNDI names that the data source will bind to. You must specify all three of the location attributes for emulated data sources, but you use only the value specified for the ejb-location attribute.
Connection-driver is the type of connection to be returned. This attribute refers to the class that actually implements the data source connection.
Username and password are the username and password for the database users.
url is the JDBC connection URL for the database being mapped to this data source.
Inactivity-timeout and connection-retry-interval are the default timeout and connection retry intervals, in seconds.
principals.xml The principals.xml file contains user and group information as well as permissions and certificates.
rmi.xml The rmi.xml file contains Remote Method Invocation (RMI) configuration information. The RMI listener, which provides remote access for EJBs, has its settings defined in this file as well. Here are the main components of the rmi.xml file:
Host name or IP address
Port number to which the RMI server binds
Clustering and log settings
jms.xml The jms.xml file contains the OC4J Java Messaging Service (JMS) implementation configuration information. The following are the key components in this file:
Host name or IP address
Port number to which the JMS server binds
Settings for queues bound to the JMDI tree
on the job: The global application for the OC4J server acts as the parent for all applications in that OC4J instance. The applications inherit the parent application’s properties, but you can override the default parent application properties with application-specific properties.