Oracle® Application Server TopLink Application Developer's Guide
10g Release 2 (10.1.2) Part No. B15901-01 |
|
Previous |
Next |
OracleAS TopLink Mapping Workbench provides the ability to create deployment files from an OracleAS TopLink Mapping Workbench project. After you build a project, you have two options to create the deployment files:
Create XML deployment files that require no compiling. This approach gives you a flexible configuration that enables you to make changes safely and easily. XML deployment files do not require third-party applications or compilers to deploy successfully.
Create Java source files, which you compile and deploy outside OracleAS TopLink Mapping Workbench.
XML deployment is the preferred method of deployment, because XML files are easier to deploy and troubleshoot than compiled Java files.
This section discusses:
To deploy an OracleAS TopLink application, create a project file, in addition to one or more supporting files, as follows:
If you deploy a non-EJB application, you require a session configuration file, known as the sessions.xml
file.
If you deploy EJBs to a J2EE container, you require the following entity bean deployment descriptors:
An ejb-jar.xml
file that specifies standard EJB deployment properties
A J2EE container file that contains the properties specific to the J2EE container you use to deploy the application
A toplink-ejb-jar.xml
file that contains properties specific to OracleAS TopLink
Related beans share the same ejb-jar.xml
file, J2EE container-specific file, and toplink-ejb-jar.xml
file.
For more information, see "Container-Managed Persistence Applications".
The project.xml
file is the core of your application. It contains the mappings and descriptors you define in OracleAS TopLink Mapping Workbench and also includes any named queries or finders associated with your project.
Because you must synchronize the project.xml
file with the classes and database associated with your application, we recommend that you do not modify this file manually. OracleAS TopLink Mapping Workbench ensures proper synchronization and is the best way to make changes to the project. Simply modify the project in OracleAS TopLink Mapping Workbench and redeploy the project.xml
file.
To redeploy a project.xml
file, shut down and restart your OracleAS TopLink application.
Note: Because thesessions.xml file includes the name of the project file, you can save the project file with a name other than project.xml ; however, for clarity, this discussion assumes that the file has not been renamed.
|
In addition to generating the deployment XML from OracleAS TopLink Mapping Workbench, you can use either of the following methods and use the DeploymentXMLGenerator
API:
Note: Before you use either method, ensure that your the classpath includes the< ORACLE_HOME>\toplink\config directory.
|
From an application, instantiate the DeploymentXMLGenerator
and your Java source. Call the following method:
generate (<MW_Project.mwp>, <output file.xml>)
From a command line, use:
java -classpath toplink.jar;toplinkmw.jar;xmlparserv2.jar;ejb.jar;. oracle.toplink.workbench.external.api.DeploymentXMLGenerator <MW_Project.mwp> <output file.xml>
The sessions.xml
file provides a simple and flexible way to configure, modify, and troubleshoot the application database sessions. Because of these attributes, the sessions.xml
file is the preferred way to configure an OracleAS TopLink session.
The OracleAS TopLink Sessions Editor is a graphical tool to build and edit the sessions.xml
file, but you can also use a text editor.
For more information about the OracleAS TopLink Sessions Editor, see "Understanding the OracleAS TopLink Sessions Editor" in the Oracle Application Server TopLink Mapping Workbench User's Guide.
For more information, see "Configuring Sessions with the sessions.xml File".
The toplink-ejb-jar.xml
file specifies all OracleAS TopLink-related information for an EJB entity bean deployment to a J2EE container. It includes several elements you use to configure the application.
The OracleAS TopLink deployment descriptor is included in the EJB JAR in the same META-INF directory as the ejb-jar.xml
file.
The session
element contains settings for the entire project. The toplink-ejb-jar.xml
file must include a session section, which includes the following XML elements:
name
: A session name (unique among all deployed JARs) that is used as a key for the deployed OracleAS TopLink project (or the JAR that contains the project).
project-xml
: Specifies the name of the XML file that contains the OracleAS TopLink project metadata. Specify the fully qualified file name, including the .xml
extension.
The project deployment XML file can be stored either in the deployable JAR file at the root directory or on the file system.
Note: If you wish, use aproject-class element rather than a project-xml tag. With the project-class element, specify the fully-qualified name of the OracleAS TopLink project class. Include this class in the deployable JAR file. You can generate the project class either with OracleAS TopLink Mapping Workbench or write it manually.
|
session-type
: The session type must always be set to server-session
.
platform-class
: The platform class controls the format of the SQL generated and other database specific behavior.
uses-external-connection-pool
and uses-external-transaction-controller
: For OracleAS TopLink to participate in WebSphere JTS transactions, set both of these to TRUE.
external-transaction-controller-class
: This is the OracleAS TopLink server-specific JTS controller class required when using external transaction control. For WebSphere 4.0, use oracle.toplink.jts.was.JTSExternalTransactionController_4_0
.
enable-logging
: When set to TRUE, OracleAS TopLink prints logging information for several of its operations. This is useful for debugging.
logging-options
: Options for different levels of OracleAS TopLink logging.
For more information about the toplink-was-ejb-jar_904.dtd
, see <
ORACLE_HOME>\toplink\config\dtds
.
The toplink-ejb-jar.xml
file specifies all OracleAS TopLink-related information for an EJB entity bean deployment to a J2EE container. It includes several elements you use to configure the application.
The OracleAS TopLink deployment descriptor is included in the EJB JAR in the same META-INF directory as the ejb-jar.xml
file.
The session
element contains settings for the entire project. The toplink-ejb-jar.xml
file must include a session section, which may include the following XML elements:
name
: Specifies the name of the session. Assign a unique session name to all projects deployed in a given server. This tag is mandatory.
project-class
: Specifies the name of the class that contains the OracleAS TopLink project metadata. Specify the fully qualified Java class name, but do not include the .class
or .java
extension.
Use this tag (and not the project-xml
tag) if you deploy your projects using exported and compiled Java code.
project-xml
: Specifies the name of the XML file that contains the OracleAS TopLink project metadata. Specify the fully qualified file name, including the .xml
extension.
Use this tag (and not the project-class
tag) if you deploy your project using an exported XML file.
login
: Specifies the login parameters for the session. This element includes the sub elements listed in Table 9-1.
Table 9-1 login Elements
Element | Description |
---|---|
connection-pool | Identifies a JDBC pool for the current OracleAS TopLink project. The name of the pool must correspond to a JDBC connection pool specified in the WebLogic administration console.
Specify a |
datasource | Identifies the JTA datasource for the current project. Use datasource in conjunction with non-jts-datasource . This provides an alternative to using a connection-pool .
Use For more information about datasources, see both "J2EE Integration" and the J2EE container documentation. |
non-jts-datasource | Identifies the read only datasource for the current project. Use non-jts-datasource in conjunction with datasource. This provides an alternative to using a connection-pool .
For more information about datasources, see both "J2EE Integration" and the J2EE container documentation. |
should-bind-all-parameters (optional) | Indicates whether all queries use parameter binding. Valid values are TRUE or FALSE. Default is FALSE. |
uses-byte-array-binding (optional) | Indicates whether byte arrays are bound. Valid values are TRUE or FALSE. Default is FALSE. |
uses-string-binding (optional) | Indicates whether strings are bound. Valid values are TRUE or FALSE. Default is FALSE. |
cache-synchronization
(optional): This element indicates that changes made to one OracleAS TopLink cache in a cluster are automatically propagated to all other server caches. You can also include the optional sub elements listed in Table 9-2.
Table 9-2 Optional cache-synchronization Elements
Element | Description |
---|---|
is-asynchronous | Specifies whether synchronization should not wait until all sessions have been synchronized before returning. Valid values are TRUE or FALSE. Default is TRUE. |
should-remove-connection-on-error | Specifies whether a synchronization connection is removed from the session if a communication error occurs. Valid values are TRUE or FALSE. Default is TRUE. |
use-remote-relationships
(optional): OracleAS TopLink enables you to define relationships between beans in terms of their remote interfaces. This is especially useful when you port EJB 1.1 applications to EJB 2.0. When you enable this option, OracleAS TopLink defines all relationships in the JAR file using remote interfaces. Valid values are TRUE or FALSE. Default is FALSE.
Note: If you enable this option, then your application no longer strictly complies with EJB 2.0, and your container may require some custom configuration. For example, when you deploy, run theweblogic.ejbc tool with the -nocompliance flag set.
|
customization-class
(optional): Specifies the fully qualified name of a DeploymentCustomization
class.
Although XML deployment is the preferred deployment method, you can also deploy your OracleAS TopLink project as Java source files. To deploy a project as Java source files, create your project and export the Java source files from OracleAS TopLink Mapping Workbench. After you generate the files, compile them with an integrated development environment (IDE). This more traditional deployment method results in OracleAS TopLink applications with the following characteristics:
They usually load more quickly than an XML-deployed project the first time they are loaded. They do not offer performance benefits after load time.
Modifying session characteristics is a multi-step process that involves modifying the project in OracleAS TopLink Mapping Workbench, recompiling the source files in an IDE, and redeploying the project.
In addition to generating the Java Source from OracleAS TopLink Mapping Workbench, you can employ either of the following methods and use the JavaSourceGenerator
API:
Note: Before you use either method, ensure that your the classpath includes the<ORACLE_HOME>\toplink\config directory.
|
From an application, instantiate the JavaSourceGenerator
and your java source. Call the method:
generate (<MW_Project.mwp>, <output file.xml>)
From a command line, use:
java -classpath toplink.jar;toplinkmw.jar;xmlparserv2.jar;ejb.jar;. oracle.toplink.workbench.external.api.JavaSourceGenerator <MW_Project.mwp> <output file.xml>
As with an XML deployment, a Java source deployment requires the sessions.xml
file (for non-EJB applications) or EJB deployment descriptor files (for EJB projects). Build these files the same way you do for an XML deployment, and deploy it with your project.
For more information, see "Sessions.xml File", and "Configuring the toplink-ejb-jar.xml File with the BEA WebLogic Server".
If you deploy your application to a J2EE container that implements container-managed persistence (CMP), you may have to configure additional files to support the deployment. This section discusses:
There is one ejb-jar.xml
file for every JAR, although you can specify multiple beans in a single ejb-jar.xml
file. The EJB specification you use determines the contents of this file.
Most IDEs provide facilities to create the ejb-jar.xml
file. For more information about generating this file, see your IDE documentation.
If you build an EJB 2.0 application, OracleAS TopLink Mapping Workbench can build the ejb-jar.xml
file for you. Because OracleAS TopLink Mapping Workbench can both read and write the ejb-jar.xml
, you can drive changes in the ejb-jar.xml
file using OracleAS TopLink Mapping Workbench either:
When you change the file manually outside OracleAS TopLink Mapping Workbench. Re-import the ejb-jar.xml
file into OracleAS TopLink Mapping Workbench project to refresh the project.
When you change OracleAS TopLink Mapping Workbench project. OracleAS TopLink Mapping Workbench updates the ejb-jar.xml
file automatically when you save the project.
For more information about managing the ejb-jar.xml
file in OracleAS TopLink Mapping Workbench, see in the Oracle Application Server TopLink Mapping Workbench User's Guide.
The contents of the [J2EE-Container]
-ejb-jar.xml
file depends on the container to which you deploy your beans. To create this file, use the tools that accompany your container.
In most cases, the [J2EE-Container]
-ejb-jar.xml
file integrates with OracleAS TopLink without revision. However, when you deploy to a WebLogic Server container, modify the weblogic-ejb-jar.xml
. The topics in this section explore the required modifications.
To deploy to a BEA WebLogic Server, modify the webLogic-ejb-jar.xml
file. Within that file, each bean must have a persistence-descriptor
entry with subentries, as follows:
Configure the persistence-descriptor
entry with subentries that indicate OracleAS TopLink is available and should be used:
If you deploy to WebLogic 6.1 (Service Pack 5). Include a persistence-type
element and a persistence-use
element. Both elements require a type-identifier
and a type-version
tag. Table 9-3 lists the options for the type-identifier
tag, and Table 9-4 contains the options for the type-version
tag.
If you deploy to WebLogic 7.0 or 8.1. Include a persistence-use
element with a type-identifier
and a type-version
tag. Table 9-3 lists the options for the type-identifier
tag, and Table 9-4 contains the options for the type-version
tag.
If you use WebLogic 6.1, add the element type-storage
to the persistence-type
element, and set it to META-INF\toplink-ejb-jar.xml
.
If you use WebLogic 7.0 or 8.1, add the element type-storage
to the persistence-use
element, and set it to META-INF\toplink-ejb-jar.xml
.
Set the enable-call-by-reference
element to TRUE
to enable Call by Reference:
<weblogic-enterprise-bean> <ejb-name>AccountBean</ejb-name> ... <enable-call-by-reference>True</enable-call-by-reference> ... </weblogic-enterprise-bean>
Table 9-3 WebLogic type-identifier Settings
EJB Version | XML Elements |
---|---|
1.1 |
<type-identifier>TopLink_CMP_1_1</type-identifier> |
2.0 |
<type-identifier>TopLink_CMP_2_0</type-identifier> |
Table 9-4 WebLogic type-version Settings
WebLogic Version | XML Elements |
---|---|
6.1 |
<type-version>4.0</type-version> |
7.0 |
<type-version>4.5</type-version> |
8.1 |
<type-version>9.0.4</type-version> |
Note: Although deprecated, thetype-version setting of version 3.5 also functions correctly with WebLogic 6.1 (Service Pack 5) under EJB 1.1.
|
The weblogic-ejb-jar.xml
file includes the following tags that OracleAS TopLink either does not support or does not require:
concurrency-strategy
: This tag specifies how WebLogic manages concurrent users for a given bean. Because OracleAS TopLink manages concurrent access internally, it does not require this element.
For more information about OracleAS TopLink concurrency strategy, see "Locking Policy".
db-is-shared: Because OracleAS TopLink does not make any assumptions about the exclusivity of database access, OracleAS TopLink does not require this tag. OracleAS TopLink addresses multi-user access issues through various locking and refreshing policies.
delay-updates-until-end-of-tx: OracleAS TopLink always delays updates until the end of a transaction and does not require this tag.
finders-load-bean: OracleAS TopLink always loads the bean upon execution of the finder and does not require this tag.
pool: OracleAS TopLink does not use a pooling strategy for entity beans. This avoids object-identity problems that can occur due to pooling.
lifecycle: This element manages beans that follow a pooling strategy. Because OracleAS TopLink does not use a pooling strategy, OracleAS TopLink ignores this tag.
is-modified-method-name: OracleAS TopLink does not require a bean developer-defined method to detect changes in object state.
isolation-level: Because isolation level settings for the cache or database transactions are specified in the OracleAS TopLink project, OracleAS TopLink ignores this tag.
cache: Because you define OracleAS TopLink cache properties in OracleAS TopLink Mapping Workbench, this tag is not necessary.