Oracle Application Server TopLink Application Developer's Guide 10g (9.0.4) Part Number B10313-01 |
|
This chapter describes how to configure Oracle Application Server TopLink for use with J2EE containers and application servers. It includes sections on:
To run an OracleAS TopLink application within a J2EE container, your system must meet the following software requirements:
java.exe
or jre.exe)
OracleAS TopLink supports several architectures that leverage a J2EE container. To enable OracleAS TopLink in these architectures configure the following:
Place the OracleAS TopLink JARs on the application server class path. Class path configuration is container-specific. For more information, see:
OracleAS TopLink applications that run in a J2EE container often use a J2EE Datasource to access JDBC connections. To leverage a J2EE datasource, configure a datasource with the server's configuration tools, and specify the name of the datasource in the sessions.xml
file, as follows:
<login> <datasource>java:comp/env/jdbc/myJTADataSource</datasource> <uses-external-connection-pool>true</uses-external-connection-pool> ... </login>
The OracleAS TopLink Unit of Work uses the Java Transaction API (JTA) to participate in global transactions. Configure OracleAS TopLink JTA support in the sessions.xml
file as follows:
<login> ... <uses-external-transaction-controller>true</uses-external-transaction-controller> </login> <external-transaction-controller-class>oracle.toplink.jts.oracle9i.Oracle9iJTSExternal TransactionController </external-transaction-controller-class>
OracleAS TopLink support for external transaction controllers requires a J2EE datasource. OracleAS TopLink provides several container-specific external transaction controllers, as well as a generic controller.
For more information, see "J2EE Integration".
To configure OracleAS TopLink support for Oracle Application Server Containers for J2EE, include the following OracleAS TopLink JARS on the Oracle Application Server Containers for J2EE class path:
<ORACLE_HOME>
\toplink\jlib\toplink.jar<ORACLE_HOME>
\toplink\jlib\antlr.jar
For example, add the following code to the Oracle Application Server Containers for J2EE application.xml
file:
<library path="/OraHome1/toplink/jlib/toplink.jar" /> <library path="/OraHome1/toplink/jlib/antlr.jar" />
Substitute your <ORACLE_HOME>
directory for OraHome1
.
OracleAS TopLink provides support for IBM WebSphere Application Server 4.0. To configure this support for IBM WebSphere Application Server, copy the following OracleAS TopLink JARs to the application server class path directory:
<ORACLE_HOME>
\toplink\jlib\toplink.jar<ORACLE_HOME>
\toplink\jlib\antlr.jar
<ORACLE_HOME>\lib\xmlparserv2.jar
Table B-1 lists the default application class path directories for IBM container components.
Because of the way the WebSphere defines its class loader isolation mode, OracleAS TopLink supports only the APPLICATION
and MODULE
modes for module visibility.
A J2EE application (EAR file) can have multiple EJB modules (EJB JAR files). OracleAS TopLink CMP loads one toplink-ejb-jar.xml
per EJB module (EJB JAR). If you do not set the loader isolation mode to MODULE
, an EJB module can load the incorrect toplink-ejb-jar.xml
from another EJB module.
OracleAS TopLink supports class loader isolation APPLICATION
mode. However, each application must have only one EJB JAR file.
For more information about the module visibility in IBM WebSphere, see the IBM WebSphere documentation.
Table B-2 lists the application and module modes OracleAS TopLink supports.
To enable OracleAS TopLink support for IBM WebSphere Application Server 5.0, configure the following four elements for WebSphere at the Enterprise Application level:
Create a shared library that contains the following Toplink JARS and associate the shared library with the application:
<ORACLE_HOME>
\toplink\jlib\toplink.jar<ORACLE_HOME>
\toplink\jlib\antlr.jar
<ORACLE_HOME>\lib\xmlparserv2.jar
Set the application Classloader Mode to PARENT_LAST
. Note that you can also configure the Classloader at the Server level.
For more information, see the IBM WebSphere 5.0 documentation.
Set the Application Classloader Policy on the application server to Multiple
.
For more information, see the IBM WebSphere 5.0 documentation.
For applications that require JTA integration, specify the external transaction controller in the OracleAS TopLink sessions.xml
file. To enable the WebSphere 5.0 external transaction controller, add the following line to the sessions.xml
file:
<external-transaction-controller-class>oracle.toplink.jts.was. JTSExternalTransactionController_5_0</external-transaction-controller-class>
For more information, see "External Transaction Controllers".
OracleAS TopLink provides support for BEA WebLogic Application Server 6.1, 7.0 and 8.1. This support requires manual configuration, and includes a sample domain and the ability to use a security manager with BEA WebLogic.
To configure OracleAS TopLink support for BEA WebLogic Server, add the following JAR files to the application server class path:
<ORACLE_HOME>
\toplink\jlib\toplink.jar <ORACLE_HOME>\lib\xmlparserv2.jar
If you use a security manager, specify a security policy file in the weblogic.policy
file (normally located in the BEA WebLogic install directory), as follows:
-Djava.security.manager -Djava.security.policy==c:\weblogic\weblogic.policy
The BEA WebLogic installation procedure includes a sample security policy file. You need to edit the weblogic.policy
file to grant permission for OracleAS TopLink to use reflection.
This example illustrates only the permissions that OracleAS TopLink requires, but most weblogic.policy
files contain more permissions than are shown in this example.
grant {// "enableSubstitution" required to run the WebLogic console
permission java.io.SerializablePermission "enableSubstitution";// "modifyThreadGroup" required to run the WebLogic Server
permission java.lang.RuntimePermission "modifyThreadGroup";//grant permission for OracleAS TopLink to use reflection
permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; };
OracleAS TopLink provides a CMP integration for:
To enable the OracleAS TopLink CMP integration for IBM WebSphere 4.0, configure OracleAS TopLink J2EE support for WebSphere as described in "IBM WebSphere Application Server 4.0".
To enable the OracleAS TopLink CMP integration for BEA WebLogic Server 6.1, 7.0 and 8.1, use the following procedures. These procedures assume you have already installed OracleAS TopLink.
Do one of the following:
persistence.install
file in the BEA WebLogic Server persistence directory, and add a new line that references TopLink_CMP_Descriptor.xml
.
persistence.install
file with the OracleAS TopLink persistence.install
file found in the <ORACLE_HOME>
\toplink\config
directory.
<ORACLE_HOME>
\toplink\jlib\toplink.jar <ORACLE_HOME>\lib\xmlparserv2.jar
BEA WebLogic includes a clustering service that you can leverage with your OracleAS TopLink application. To leverage a cluster, make the OracleAS TopLink runtime JAR available to all servers to which you deploy OracleAS TopLink CMP beans. This section discusses the following cluster-related issues:
Although the BEA WebLogic cluster enables you to build an application across several servers, related components in the application must still be localized to a server. When you store several beans on the same server, the beans are said to be collocated.
Collocation in a BEA WebLogic cluster imposes the following restrictions:
Home
interfaces, but not instances. When you instantiate a bean, you pin it to the server on which it was instantiated.
For more information, see "Pinning".
You must collocate all related beans and objects on a single server to support relationships between beans. To simplify the application, also retrieve source and target objects on the same server.
Static partitioning refers to strategically deploying all related beans on a single server. A server can contain several groups of related beans, but collocation dictates that a group of beans cannot span several servers.
Static partitioning eliminates cache inconsistency issues, because the application loads beans only on the server on which the beans are deployed. BEA provides limited failover, and bean activity determines how the application load balances across servers.
When you create or instantiate a bean, the bean instance is associated with, or pinned to, the server on which it is instantiated. To localize transactions to a particular server, BEA WebLogic Server pins all instantiated beans in a given transaction to the server on which you run the transaction. If beans are pinned to other servers, you cannot localize the transaction.
You can pin beans to a given server dynamically, either through user transactions or through session beans.
To maintain bean localization, access beans through a transaction. If you deploy beans on multiple servers, you can initiate the transaction on any server that holds a bean in the transaction. BEA WebLogic attempts to pin all accessed beans to that server for the duration of the transaction.
Example B-2 illustrates the use of a user transaction to collocate related beans.
UserTransaction transaction = lookupUserTransaction() // Enclose all construction of relationships in the same transaction transaction.begin(); /* Look up the home interface and the bean even if they have already been looked up previously */ Employee emp = lookupEmployeeHome().findByPrimaryKey(new EmployeePK(EMP_ID)); Address address = new Address(EMP_ID, "99 Bank", "Ottawa", "Ontario", "Canada","K2P 4A1"); emp.setAddress(address); Project project = lookupProjectHome().findByPrimaryKey(new ProjectPK(PROJ_ID)); emp.addProject(project); transaction.commit();
If you access entity beans through a session bean, the application instantiates the entity beans on the same server as the session bean. By moving the application logic from the client to a session bean, you enable all bean code to run on the same JVM. The client invokes a method in the session bean, and the session bean executes all required logic on the server on which it resides.
You can use session beans to manage scalability and failover.
Cache synchronization propagates changes from one OracleAS TopLink cache to all other server caches. This eliminates the need for manual refresh, and provides a consistent view of cached data across the cluster.
Cache synchronization is a project-level option. If you implement cache synchronization, OracleAS TopLink propagates changes to all objects in the project.
To configure cache synchronization in the toplink-ejb-jar.xml
deployment descriptor, implement the following elements and sub-elements:
cache-synchronization
: Include this tag to enable cache synchronization. To configure synchronization, use the is-asynchronous
and should-remove-connection-on-error
tags.
is-asynchronous
(optional): Sets the synchronization mode. Set to True to enable asynchronous propagation, or False to force synchronous updates. The default value is True.
For more information about synchronous and asynchronous updates, see "Synchronous and Asynchronous Propagation".
should-remove-connection-on-error
(optional): Enables error handling at the connection. Set to True to enable this behavior, or False to disable it. The default value is True.
For more information about this error handling feature, see "Error Handling".
<toplink-ejb-jar> <session> <name>ejb20_AccountDemo</name> <project-class>oracle.toplink.demos.ejb20.cmp.account.AccountProject</project-class> <login> <connection-pool>ejbPool</connection-pool> </login> <cache-synchronization> <is-asynchronous>True</is-asynchronous> <should-remove-connection-on-error>True</should-remove-connection-on-error> </cache-synchronization> </session> </toplink-ejb-jar>
For more information about the toplink-ejb-jar.xml
file, see "Configuring the toplink-ejb-jar.xml File with the BEA WebLogic Server".
|
Copyright © 2000, 2003 Oracle Corporation. All Rights Reserved. |
|