Developingejb
Developingejb
Developingejb
January 2002
Apple Computer, Inc. Java and all Java-based trademarks
© 2001–2002 Apple Computer, Inc. are trademarks or registered
All rights reserved. trademarks of Sun Microsystems, Inc.
No part of this publication may be in the United States and other
reproduced, stored in a retrieval countries.
system, or transmitted, in any form or Simultaneously published in the
by any means, mechanical, electronic, United States and Canada
photocopying, recording, or Even though Apple has reviewed this
otherwise, without prior written manual, APPLE MAKES NO
permission of Apple Computer, Inc., WARRANTY OR REPRESENTATION,
with the following exceptions: Any EITHER EXPRESS OR IMPLIED, WITH
person is hereby authorized to store RESPECT TO THIS MANUAL, ITS
documentation on a single computer QUALITY, ACCURACY,
for personal use only and to print MERCHANTABILITY, OR FITNESS
copies of documentation for personal FOR A PARTICULAR PURPOSE. AS A
use provided that the documentation RESULT, THIS MANUAL IS SOLD “AS
contains Apple’s copyright notice. IS,” AND YOU, THE PURCHASER, ARE
The Apple logo is a trademark of ASSUMING THE ENTIRE RISK AS TO
Apple Computer, Inc. ITS QUALITY AND ACCURACY.
Use of the “keyboard” Apple logo IN NO EVENT WILL APPLE BE LIABLE
(Option-Shift-K) for commercial FOR DIRECT, INDIRECT, SPECIAL,
purposes without the prior written INCIDENTAL, OR CONSEQUENTIAL
consent of Apple may constitute DAMAGES RESULTING FROM ANY
trademark infringement and unfair DEFECT OR INACCURACY IN THIS
competition in violation of federal MANUAL, even if advised of the
and state laws. possibility of such damages.
No licenses, express or implied, are THE WARRANTY AND REMEDIES SET
granted with respect to any of the FORTH ABOVE ARE EXCLUSIVE AND
technology described in this book. IN LIEU OF ALL OTHERS, ORAL OR
Apple retains all intellectual property WRITTEN, EXPRESS OR IMPLIED. No
rights associated with the technology Apple dealer, agent, or employee is
described in this book. This book is authorized to make any modification,
intended to assist application extension, or addition to this warranty.
developers to develop applications
only for Apple-labeled or Some states do not allow the exclusion or
Apple-licensed computers limitation of implied warranties or
liability for incidental or consequential
Every effort has been made to ensure
damages, so the above limitation or
that the information in this document
exclusion may not apply to you. This
is accurate. Apple is not responsible
warranty gives you specific legal rights,
for typographical errors.
and you may also have other rights which
Apple Computer, Inc. vary from state to state.
1 Infinite Loop
Cupertino, CA 95014
408-996-1010
Apple, the Apple logo, Mac,
Macintosh, and WebObjects are
trademarks of Apple Computer, Inc.,
registered in the United States and
other countries.
Enterprise Objects and trademark is a
of NeXT Software, Inc., registered in
the United States and other countries.
Contents
Enterprise JavaBeans 15
Enterprise JavaBeans in WebObjects 17
3
Apple Computer, Inc. January 2002
C O N T E N T S
Configuration Overview 56
Configuring the Transaction Manager 57
Configuring the EJB Container 58
Configuring the Persistence Manager 60
LocalTransactionConfiguration.xml 60
GlobalTransactionConfiguration.xml 60
CMPConfiguration.xml 60
Transaction Manager Configuration 61
Persistence Manager Configuration 62
Mapping Enterprise Beans to Data Stores 63
The Mapping File 64
Primary Keys 64
Defining Local and Global Data Stores 69
Container Configuration 70
Containers Section 70
Facilities Section 73
Using External Containers 73
4
Apple Computer, Inc. January 2002
C O N T E N T S
5
Apple Computer, Inc. January 2002
C O N T E N T S
<jndi-context> 108
<jndi-enc> 109
<intra-vm-server> 109
<managed-connection-factory> 110
<method> 110
<method-params> 111
<method-permission> 112
<method-transaction> 112
<openejb> 113
<properties> 113
<property> 113
<query> 114
<remote-jndi-contexts> 114
<resource> 115
<resource-ref> 115
<role-mapping> 117
<security-role> 117
<security-role-ref> 118
<security-service> 118
<services> 119
<stateful-bean> 119
<stateful-session-container> 120
<stateless-bean> 120
<stateless-session-container> 121
<transaction-service> 122
Glossary 125
Index 127
6
Apple Computer, Inc. January 2002
Figures, Listings, and Tables
7
Apple Computer, Inc. January 2002
F I G U R E S A N D T A B L E S
8
Apple Computer, Inc. January 2002
F I G U R E S A N D T A B L E S
9
Apple Computer, Inc. January 2002
F I G U R E S A N D T A B L E S
10
Apple Computer, Inc. January 2002
C H A P T E R 1
11
Apple Computer, Inc. January 2002
C H A P T E R 1
You should read this book if you want to learn how to incorporate an EJB-based
solution in a WebObjects application or you want to develop your own enterprise
beans using WebObjects tools. However, it is not the purpose of this book to teach
you EJB development. If you want to develop enterprise beans, you must already
have a sound knowledge of the technology.
To get the most out of this book you should be an experienced WebObjects
application developer. In particular, you need to know how to create applications
using Project Builder and be familiar with the layout of a Project Builder project. To
make use of enterprise beans in an application, you are required to edit
configuration files written in XML; therefore, you should be familiar with XML’s
rules and syntax.
If you need to learn the basics about developing WebObjects applications, you can
find that information in the following books:
■ Inside WebObjects: WebObjects Overview provides you with a survey of
WebObjects technologies and capabilities.
■ Inside WebObjects: Discovering WebObjects for HTML shows you how to develop
HTML-based applications.
12
Apple Computer, Inc. January 2002
C H A P T E R 1
For additional WebObjects documentation and links to other resources, visit http:/
/developer.apple.com/webobjects.
If you need to learn about EJB development, these books provide you introductory
information as well as development guidelines:
■ Enterprise JavaBeans (O’Reilly)
■ Professional EJB (Wrox Press)
■ Applying Enterprise JavaBeans: Component-Based Development for the J2EE Platform
(Addison-Wesley)
■ OpenORB Programmers Guide and RMI over IIOP for OpenORB deal with the
Object Request Broker (ORB) implementation used in WebObjects. They are
located in /System/Library/Frameworks/JavaOpenORB.framework/Resources/
English.lproj/Documentation.
13
Apple Computer, Inc. January 2002
C H A P T E R 1
14
Apple Computer, Inc. January 2002
C H A P T E R 2
2 Introduction to EJB in
WebObjects
WebObjects provides all the tools you need to develop and deploy enterprise
applications. However, WebObjects is not the only technology available. Other
companies provide tools that accomplish the same task, albeit using different
methods and requiring specialized deployment environments. Therefore, it’s
difficult for a WebObjects application to talk to an application developed and
deployed under a different environment. J2EE and EJB bridge the schism between
environments from different vendors.
J2EE standardizes the way Web applications communicate with the resources they
need to operate. Akin to JDBC, the goal of J2EE is to provide an infrastructure that
applications from different developers can utilize to get their work done.
Enterprise JavaBeans
Enterprise JavaBeans 15
Apple Computer, Inc. January 2002
C H A P T E R 2
In addition, beans have a deployment descriptor. This is an XML file that gives the
container information about each bean and data-source connection details, among
many other items.
There are two major types of enterprise beans: session beans and entity beans.
■ Session beans come in two flavors: stateful and stateless. Stateful session beans
maintain state between method invokations; stateless session beans do not.
Stateless session beans are useful for grouping related methods in one place.
Stateful session beans can be used to encapsulate workflow. In most cases it’s
more efficient for client applications to use session beans (stateless or stateful) to
accomplish their tasks than to use entity beans directly because network traffic
is reduced.
■ Entity beans are similar to enterprise objects in WebObjects’s Enterprise Object
technology. They encapsulate access to data entities.
16 Enterprise JavaBeans
Apple Computer, Inc. January 2002
C H A P T E R 2
One of the most important functions of the container is bean pooling, which is used
to share bean instances among several clients. WebObjects includes the OpenEJB
open-source container system. OpenEJB consists of four main components:
■ EJB container: The EJB container implements the lifecycle of enterprise beans
and the server contracts in the EJB specification.
■ Object Request Broker (ORB): The OpenORB object request broker implements
RMI-over-IIOP, naming service, and CORBA ORB.
■ Transaction manager: The Tyrex transaction manager implements the Java
Naming and Directory Interface (JNDI) specification, and a transaction manager
compliant with the Java Transactions (JTA) and Object Transaction Service
(OTS) specifications.
■ Persistence manager: The Castor JDO persistence manager implements bean
persistence for entity beans. It’s used in the implementation of CMP (container-
managed persistence) beans. An entity bean is a type of enterprise bean that
represents a data entity, such as a Person or a Department.
You can use WebObjects development tools to develop enterprise beans from
scratch or to integrate third-party EJB-based solutions in a WebObjects application.
Bean development in WebObjects is divided in two phases: development and
deployment.
You develop enterprise beans by writing the .java and deployment descriptor files.
Project Builder provides you with templates for all these files. You can also obtain
the source code or JAR files for enterprise beans from a third party.
You deploy one or more beans by generating a bean framework, which contains the
beans’ JAR and deployment descriptor files, and placing it somewhere in a
development computer’s file system; for example, in /Library/Frameworks. After
you deploy a bean framework, it’s available to be integrated in client applications
for their use.
Client applications can be developed in two ways: using an internal bean container,
or using an external container:
■ Internal container: This approach is the most scalable because each application
instance has its own container and naming-service object.
If the user load of your site becomes too large for one instance to handle, all you
have to do is add more instances of it. Each container answers only to one
application, so there is no application-to-container bottleneck.
■ External container: This approach is beneficial if you already have a robust bean
container, running on a fast computer, that you want to leverage. In this case, no
configuration files should be present in the bean-client application project. For
more on the configuration files, see “Configuring EJB Applications” (page 55).
Before developing WebObjects applications that use enterprise beans, you have to
create enterprise-bean frameworks. These frameworks contain the JAR and
deployment descriptor files needed to deploy enterprise beans.
You can create a bean framework by writing the beans yourself or by using third-
party beans (either from Java source and deployment descriptor files or JAR files).
Project Builder helps you create beans from scratch by providing you with bean
templates that get you started.
In most cases, you save both time and money when you use third-party beans in
your projects instead of developing them from scratch. This is because you obtain a
solution that has been tested by the solution vendor and other developers like you.
Also remember that you cannot take advantage of Enterprise Object technology in
your enterprise beans; for example, you have to implement primary-key classes,
finder methods, primary-key–value generation, and so on in your entity beans. In
addition, you have to choose between implementing a bean as an entity bean or a
session bean. It’s a bean provider’s job to design an effective and efficient bean
solution for you. You can then compare similar solutions from various vendors and
purchase the one that most closely addresses your situation.
The following sections show you how to develop a stateless session bean for use in
a WebObjects application both on Mac OS X and Windows.
19
Apple Computer, Inc. January 2002
C H A P T E R 3
This section shows you how you develop a stateless session bean for use in a
WebObjects application in Mac OS X.
5. In the Create New Enterprise JavaBean pane of the Assistant, select “Create
source files for a new Enterprise JavaBean” and click Next.
6. In the Choose Bean Type pane, make sure Stateless Bean is selected under
Enterprise Java Bean Types, and click Next.
After you’re done, you’ll see a window similar to the one in Figure 3-1.
This is the template for the home interface of the Hello enterprise bean
(HelloHome.java):
package com.my.ejb;
import javax.ejb.*;
import java.rmi.RemoteException;
package com.my.ejb;
import javax.ejb.*;
import java.rmi.RemoteException;
import java.rmi.Remote;
//
// Business Logic Interfaces
//
// Example:
// public String hello() throws java.rmi.RemoteException;
package com.my.ejb;
import javax.ejb.*;
//
// Creation methods
//
public HelloBean() {
//
// SessionBean interface implementation
//
//
// Business Logic Implementations
//
// Example:
// public String hello() { return "hello"; }
}
<ejb-jar>
<description>deployment descriptor for HelloBean</description>
<display-name>HelloBean</display-name>
<enterprise-beans>
<session>
<description>deployment descriptor for HelloBean</description>
<display-name>HelloBean</display-name>
<ejb-name>HelloBean</ejb-name>
<home>com.my.ejb.HelloHome</home>
<remote>com.my.ejb.Hello</remote>
<ejb-class>com.my.ejb.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
In addition to providing you with most of the code needed to deploy a bean, Project
Builder also partitions the source code appropriately between two targets: EJB
Deployment and EJB Client Interfaces.
If you choose the EJB Deployment target, you’ll see that all of the bean’s source files
are assigned to it.
When you view the EJB Client Interfaces target, however, you see that the
implementation class and the deployment descriptor files are not assigned to it.
After the framework is built, you can find it in the project’s build directory:
HelloBean/
build/
HelloBean.framework
3. In the Enable J2EE Integration pane of the Project Builder Assistant, select
“Deploy as an EJB Container” and click Next.
When you deploy the client application as an EJB container, each application
instance has its own EJB container. See “Enterprise JavaBeans in WebObjects”
(page 17) for details in internal and external containers.
4. This example doesn’t require the use of any data-source adaptors, so make sure
no adaptors are selected in the Choose EOAdaptors pane.
You need to select a data-source adaptor only if your application uses enterprise
objects in addition to enterprise beans. Entity beans that use bean-managed
persistence (BMP) are responsible for interfacing with the necessary data stores.
For entity beans that use container-managed persistence (CMP), the bean
container has this responsibility. This example application does not use
enterprise objects.
Editing Session.java
Now, you’ll edit Session.java so that each new session creates a Hello-bean proxy
that your components can access.
import com.my.ejb.Hello;
import com.my.ejb.HelloHome;
import java.rmi.RemoteException;
import java.util.Properties;
import javax.ejb.CreateException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
Now, add two instance variables: one to hold the Hello bean’s home interface and
another to hold its remote interface.
public Session() {
super();
return _helloHome;
}
Editing Main.wo
Open Main.wo in WebObjects Builder by double-clicking Main.wo, which is located
under the Main subgroup of the Web Components group in the Groups & Files list.
Add a String key called greeting to Main.wo through the Edit Source pop-up menu.
Add a WOString element to the component, and bind it to the greeting key.
Editing Main.java
When a Main page is about to be displayed, the Main object needs to invoke the
message method of its Hello bean proxy to obtain the bean’s greeting, and store the
value returned in its greeting instance variable. When the WOString element is
rendered on the page, its value binding provides the text to be displayed; in this
case, the value comes from greeting in the Main object.
import com.my.ejb.Hello;
import java.rmi.RemoteException;
try {
greeting = session.hello.message();
<domain>
<name>default</name>
</domain>
This section shows you how you develop a stateless session bean for use in a
WebObjects application in Windows.
Edit Hello.java by adding the following code (the file is located in the Classes
bucket):
HelloBean/
HelloBean.framework
1. Select the Frameworks bucket and choose Project > Add Files.
2. Navigate to the HelloBean project directory, select HelloBean.framework, and
click Open.
3. Click Add in the search order dialog.
cd /Apple/Library/WebObjects/JavaApplications/OpenEJBTool.woa
./OpenEJBTool.cmd -o c:/<HelloBean_Client_path>
c:/<HelloBean_path>HelloBean.framework
When the tool is finished, you need to add the configuration files it generated
(OpenEJBConfiguration.xml and TransactionManagerConfiguration.xml) to the
Resources bucket of the HelloBean_Client project.
Note: You have to run OpenEJBTool manually every time you add bean
frameworks to your project.
Editing Session.java
Now, you’ll edit Session.java so that each new session creates a Hello proxy and
provides access to it to components.
import com.my.ejb.Hello;
import com.my.ejb.HelloHome;
import java.rmi.RemoteException;
import java.util.Properties;
import javax.ejb.CreateException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
Now, add two instance variables: one to hold the Hello bean’s home interface and
another to hold its remote interface.
public Session() {
super();
re.printStackTrace();
} catch (CreateException ce) {
ce.printStackTrace();
}
}
return _helloHome;
}
Editing Main.wo
Open Main.wo in WebObjects Builder by double-clicking Main.wo, which is located
under the Web Components bucket.
Add a String key called greeting to Main.wo through the Edit Source pop-up menu.
Add a WOString element to the component, and bind it to the greeting key.
Editing Main.java
When a Main page is about to be displayed, the Main object needs to invoke the
message method of its Hello bean proxy to obtain the bean’s greeting, and store the
value returned in its greeting instance variable. When the WOString element is
rendered on the page, its value binding provides the text to be displayed; in this
case, the value comes from greeting in the Main object.
import com.my.ejb.Hello;
import java.rmi.RemoteException;
try {
greeting = session.hello.message();
<domain>
<name>default</name>
</domain>
This chapter tells you how to create enterprise-bean framework to be used by client
applications. It contains the following sections:
■ “Adding Enterprise-Bean Source Files to a Bean- Framework Project” (page 45).
■ “Adding Enterprise-Bean JAR Files to a Bean Framework Project” (page 48).
■ “Creating Enterprise-Bean Frameworks From Bean JAR Files in Windows”
(page 50).
■ “Adding CMP Fields to an Enterprise Bean Deployment Descriptor” (page 53).
4. Select “Create source files for a new Enterprise Java Bean” in the Create New
Enterprise Java Bean pane and click Next.
a. Enter the class name of the bean in the Class Name text field.
b. Enter the package name in the Package Name text field.
c. Click Finish.
In Windows, you have to create one enterprise-bean framework per JAR file. Follow
these steps to create an enterprise-bean framework:
After WebObjects finishes generating the project, you should see a window like the
one in Figure 4-1.
After creating a bean framework using Project Builder, you have to add to the
deployment descriptor the fields whose persistence is to be managed by the EJB
container. To accomplish this, you add <cmp-field> and </cmp-field> tags to the
ejb-jar.xml file in the META-INF directory of your project.
Listing 4-1 lists the deployment descriptor of a simple entity bean with container-
managed persistence.
<res-auth>Container</res-auth>
</resource-ref>
<cmp-field>
<field-name>personID</field-name>
</cmp-field>
<cmp-field>
<field-name>firstName</field-name>
</cmp-field>
<cmp-field>
<field-name>lastName</field-name>
</cmp-field>
</entity>
</enterprise-beans>
</ejb-jar>
This chapter shows you how to configure a bean-client application project so that it
can use resources like databases and JavaMail connections, and it explains how to
ensure that each enterprise bean is bound to the appropriate resources.
You need to configure three major items before deploying a bean-client application:
■ Transaction manager. This is where you define the data stores that your
enterprise beans use to store their data and the JavaMail connections they use for
messaging.
■ Persistence manager. Here you map the fields of your CMP (container-
managed persistence) beans to columns in tables of your data stores so that the
container can perform database transactions for the beans.
■ EJB container. This is where you set bean-deployment properties such as
method transactions and permissions.
Filename Purpose
TransactionManagerConfiguration.xml Defines data stores and JavaMail
connections.
LocalTransactionConfiguration.xml Defines data-store connection
information for local databases.
55
Apple Computer, Inc. January 2002
C H A P T E R 5
Filename Purpose
GlobalTransactionConfiguration.xml Defines the JNDI name of a remote data
store.
CMPConfiguration.xml Defines bean-to-table and field-to-
column mapping.
OpenEJBConfiguration.xml Defines enterprise-bean deployment
behavior for the container.
Configuration Overview
This section gives you a quick look at the configuration process for bean-client
applications. It lists the major points you need to look at before deploying your
application. It’s divided in the following sections:
■ “Configuring the Transaction Manager” (page 57).
■ “Configuring the EJB Container” (page 58).
■ “Configuring the Persistence Manager” (page 60).
56 Configuration Overview
Apple Computer, Inc. January 2002
C H A P T E R 5
<dataSource>
<name>DefaultDatabase</name>
<!-- path to your database-driver JAR file if not present in the
extensions directory -->
<jar>file:///tmp/oracle.jar</jar>
<class>oracle.jdbc.xa.client.OracleXADataSource</class>
<config>
<serverName>gamow</serverName>
<portNumber>1968</portNumber>
<databaseName>bigbang</databaseName>
<driverType>thin</driverType>
<user>george</user>
<password>fire</password>
</config>
<limits>
<maximum>10</maximum>
<minimum>0</minimum>
<initial>0</initial>
<maxRetain>300</maxRetain>
<timeout>10</timeout>
</limits>
</dataSource>
Configuration Overview 57
Apple Computer, Inc. January 2002
C H A P T E R 5
If you need to define more than one data store, you can add <dataSource> tags for
each additional data store. See “Transaction Manager Configuration” (page 61) for
more information.
<javamail>
<name>DefaultSMTPServer</name>
<property>
<key>mail.smtp.host</key>
<value>post.office.com</value>
</property>
</javamail>
■ Environment entries.
Scan the file for <env-entry> tags and make sure that they contain the
appropriate values for your situation. See “<env-entry>” (page 107).
■ Method-transaction settings.
Make sure that the <trans-attribute> of <method-transaction> tags is set to the
appropriate transaction type. If the enterprise bean does not define the
transaction type for a method, WebObjects sets it to Required. See “Containers
Section” (page 70), and “<method-transaction>” (page 112) for details.
58 Configuration Overview
Apple Computer, Inc. January 2002
C H A P T E R 5
■ Performance.
If you need to tailor the performance of your application, you can fine-tune the
container by adjusting the pool size, the eviction or passivation strategy, and so
on. For details see “Configuration Reference” (page 77).
■ One <entity-container> tag per database.
When your CMP beans use more than one database, you need to
■ group the CMP beans that use the same data store under the same <entity-
container> tag
Configuration Overview 59
Apple Computer, Inc. January 2002
C H A P T E R 5
LocalTransactionConfiguration.xml
You define a data-store connection for the container in XML files. WebObjects
provides you with a default configuration in the
LocalTransactionConfiguration.xml file. If your enterprise beans use additional
data stores, you need to create additional files, one per data store. You can duplicate
the default one and add it to your project. For details on how to configure databases,
see “Elements of the Data-Store Configuration Files” (page 90).
GlobalTransactionConfiguration.xml
This is where you define the JNDI name of a remote data store. It must be identical
to the name used in the <resource-ref> tag of a bean in the CMPConfiguration.xml
file. As with the LocalTransactionConfiguration.xml file, you must have one per
data store. For more information on local and global data-store configuration files,
see “<database>” (page 92).
CMPConfiguration.xml
This is where you map enterprise beans to tables and their fields (or instance
variables) to columns in those tables. You also define a bean’s identity or primary
key and configure key-value generators. This is an example of a
CMPConfiguration.xml file:
60 Configuration Overview
Apple Computer, Inc. January 2002
C H A P T E R 5
WebObjects includes the Tyrex transaction manager. You configure it through the
TransactionManagerConfiguration.xml file.
The only item you need to configure for the transaction manager is the domain. A
transaction domain provides centralized management of transactions. It defines the
policy for all transactions created from that domain, such as default timeout,
maximum number of open transactions, support, and journaling. In addition, the
domain maintains resource managers such as JDBC data sources and JCA (J2EE
Connector Architecture) connectors.
<domain>
<name>default</name>
<resources>
<dataSource>
<name>DefaultDatabase</name>
<jar>file:///tmp/oracle.jar</jar>
<class>oracle.jdbc.xa.client.OracleXADataSource</class>
<config>
<serverName>HOSTNAME</serverName>
<portNumber>PORTNUMBER</portNumber>
<databaseName>DATABASENAME</databaseName>
<driverType>thin</driverType>
<user>ejb</user>
<password>ejb</password>
</config>
<limits>
<maximum>10</maximum>
<minimum>0</minimum>
<initial>0</initial>
<maxRetain>300</maxRetain>
<timeout>10</timeout>
</limits>
</dataSource>
</resources>
</domain>
For details on how to write the transaction manager configuration file, see
“Elements of the Transaction Manager Configuration File” (page 96).
The persistence manager configuration files specify how the persistence manager
obtains a connection to a data source, the mapping between Java classes and tables
in the data source, and the service provider to use to talk to the data source.
This file defines the correspondence between table columns and the fields of
your enterprise beans. It also defines how CMP beans are made persistent. This
mapping is used in both local and global transaction configuration files.
■ LocalTransactionConfiguration.xml
This file defines the configuration that the persistence manager uses when a
client uses an enterprise bean without a transaction context.
■ GlobalTransactionConfiguration.xml
This file defines the configuration that the persistence manager uses when a
client uses an enterprise bean with a transaction context. This configuration
requires that the data source be specified in the JNDI registry. The persistence
manager creates the data source connection, which can be used in bean-
managed as well as container-managed persistence beans.
For details in how to write the CMPConfiguration.xml file, see “Elements of the
Component-Managed Persistence Configuration File” (page 78).
Primary Keys
The persistence manager can generate the values of identity properties
automatically with the key generator. When the enterprise bean’s create method is
invoked, the persistence manager sets the value of the identity property to the value
obtained from the key generator. The key generator can use one of several
algorithms available to generate the value. You can use generic algorithms or
algorithms specific to your data source. For details on setting the algorithm to use
for an enterprise bean’s identity property, see “<class>” (page 81) and “<key-
generator>” (page 86).
You can use the key generator only under the following conditions:
■ The primary-key value is not determined from the arguments to the bean’s
ejbCreate method.
■ The bean’s identity can be determined through a single field of numeric (byte
through long) or String type.
The following sections describe the key-generator algorithms you can use.
MAX
This generic algorithm fetches the maximum value of the primary key (MAX) and
locks the record found until the end of the transaction. When the transaction ends,
the value generated is (MAX + 1). Because of the lock, concurrent transactions that
use the same algorithm wait until the end of the original transaction to obtain a new
primary-key value. Note that it is still possible to perform multiple inserts during
the same transaction.
With this algorithm, duplicate-key exceptions are almost completely avoided. The
only case in which they might occur is when inserting a row into an empty table
because there are no rows to lock. In this case, the value generated is 1.
<key-generator name="MAX">
<param name="table" value="PERSON"/>
<param name="key-column" value="PERSON_ID"/>
</key-generator>
HIGH/LOW
The following table describes the parameters used by the HIGH/LOW key
generator.
The first time the key generator is called, it finds the row for the target table in the
sequence table, locks it, reads the last reserved primary-key value, increases it by
the grab size (the number of primary-key values to reserve at a time), and unlocks
the row. In subsequent requests for primary-key values for the same target table, the
key generator provides primary-key values from the reserved values until it runs
out. When it has no more primary-key values, it accesses the sequence table to
obtain a new group of primary-key values.
Note: The sequence table must be in the same database as the table for which
primary-key values are to be generated. When working with multiple databases,
you must have one sequence table in each database that contains a table for which
the key generator is to provide primary-key values.
If grab-size is set to 1, the sequence tables contain the true maximum primary-key
value at all times. In this case, the HIGH/LOW key generator is essentially
equivalent to the MAX key generator.
If the global is set to true, the sequence table contains only one row instead of one
row per table. The key generator uses this row for all tables.
UUID
This algorithm generates global unique primary-key values. The value generated is
a combination of the host’s IP address, the current time in milliseconds since 1970,
and a static counter. The complete key consists of a 30-character, fixed-length string.
This algorithm has no parameters. The primary-key column must be of type char,
varchar, or longvarchar.
IDENTITY
The IDENTITY key generator can be used only with auto-increment primary-key
columns (identities) in Sybase ASE/ASA, MS SQL Server, MySQL, and Hypersonic
SQL.
After an insert, except when using MySQL or Hypersonic SQL, the key generator
obtains the primary-key value from the @@identity system variable, which contains
the last identity value for the current database connection. When using MySQL, the
system function LAST_INSERT_ID() is used. For Hypersonic SQL, IDENTITY() is used.
SEQUENCE
This algorithm can be used with only Oracle, Oracle8i, PostgreSQL, Interbase, and
SAP DB. It generates keys using sequences.
The following table describes the parameters for the SEQUENCE key generator.
Table 5-3
Usually a sequence is used for only one table. Therefore, in general, you have to
define one key generator per table. However, if you adhere to a naming convention
for sequences, you can use one key generator for multiple tables.
For example, if you always obtain sequence names by adding _seq to the name of
the corresponding table, you can set sequence to "{0}_seq" (the default).
The way this key generator performs its function depends on the data-source server
being used.
With Oracle, by default (returning="false") and with SAP DB, the key generator
transforms the insert statement generated by the persistence manager to the form
INSERT INTO table_name (pk_name, ...) VALUES (sequence_name.nextval, ...),
executes it, and then it performs SELECT sequene_name.currval FROM table_name to
obtain the identity value.
With Oracle8i, when you set returning to "true", RETURNING primary_key_name INTO
? is appended to the insert statement shown above, which is a more efficient
procedure to generate primary-key values. Therefore, the persistence manager
fetches the identity value when it executes the insert statement (both the insertion
and the procurement of the identity value occur in one statement).
If your table has an on_Insert trigger, like the one listed below, that already
generates values for the table’s primary key, you can set trigger to "true".
This prevents "sequence_name".nextval from being pulled twice: first during the
insert and then in the trigger. It’s also useful in combination with returning="true"
for Oracle, in which case you may not specify the sequence name.
The persistence manager can obtain a connection to a data store in one of three
ways:
■ using a JDBC 2.0 driver and URL
■ using a JDBC 2.0 data source
■ using a JNDI data source
If you are deploying the application inside a J2EE environment, you should use the
JNDI method because it allows the application server to manage connection pooling
and distributed transactions.
To allow for concurrent transactions and to ensure data integrity, two data-store
definitions should never use overlapping mappings. This is an example of a local
data store definition using an Oracle driver:
For details on how to write the data-store configuration files, see “Elements of the
Data-Store Configuration Files” (page 90).
Container Configuration
Containers Section
This section of the EJB configuration file holds four types of tags: <containers>,
<security-role>, <method-permission>, and <method-transaction>.
70 Container Configuration
Apple Computer, Inc. January 2002
C H A P T E R 5
The containers section (demarcated by the <containers> tag) can contain three types
of tags: <stateless-session-container>, <stateful-session-container>, and
<entity-container>. Each of these tags holds definitions for the corresponding
types of enterprise beans: stateless session bean, stateful session bean, and entity
bean (CMP and BMP).
One or more logical security roles are defined using <security-role> tags. Physical
security roles are mapped to logical security roles in the facilities section of the file.
You have to define the logical security roles that you want to use in your
application. Then you assign those roles to the methods of the enterprise beans—
using <method-permission> tags—as you see fit.
The <method-transaction> tag tells the container how to manage transactions for
each method invocation. You must determine what kind of transaction attribute
each enterprise bean’s methods should have, and modify the contents of the
<method-transaction> tag as appropriate. Table 5-4 provides a brief explanation of
transaction attributes.
Container Configuration 71
Apple Computer, Inc. January 2002
C H A P T E R 5
<container-system>
<containers>
<stateless-session-container>
<container-name>Basic Stateless Container</container-name>
<properties>
<property>
<property-name>org/openejb/core/InstanceManager/
STRICT_POOLING</property-name>
<property-value>true</property-value>
</property>
</properties>
<stateless-bean>
<description>deployment descriptor for HelloBean</
description>
<display-name>HelloBean</display-name>
<ejb-deployment-id>HelloBean</ejb-deployment-id>
<home>com.my.ejb.HelloHome</home>
<remote>com.my.ejb.Hello</remote>
<ejb-class>com.my.ejb.HelloBean</ejb-class>
<transaction-type>Container</transaction-type>
</stateless-bean>
</stateless-session-container>
</containers>
<security-role>
<role-name>everyone</role-name>
72 Container Configuration
Apple Computer, Inc. January 2002
C H A P T E R 5
</security-role>
<method-permission>
<role-name>everyone</role-name>
<method>
<ejb-deployment-id>HelloBean</ejb-deployment-id>
<method-name>*</method-name>
</method>
</method-permission>
<method-transaction>
<method>
<ejb-deployment-id>HelloBean</ejb-deployment-id>
<method-intf>Remote</method-intf>
<method-name>message</method-name>
<method-params/>
</method>
<trans-attribute>NotSupported</trans-attribute>
</method-transaction>
</container-system>
Facilities Section
This section of the EJB configuration file specifies the runtime environment: proxy-
generation attributes, remote JNDI contexts, data-source connections, and J2EE
services. The tags used are <intra-vm-server>, <remote-jndi-contexts>,
<connectors>, and <services>, respectively. You should not edit this part of the
OpenEJBConfiguration.xml file.
You may want to use an external EJB container instead of an internal one in your
bean-client applications when you already have a powerful, reliable container. In
this case, you need to remove all the configuration files listed at the beginning of this
chapter from your project.
To configure your application to use a single, external EJB container, you need to set
system properties when you launch your application. You can set them through the
command line. The following list details the properties you need to set for various
EJB containers:
■ OpenEJB
-Djava.naming.factory.initial=org.openorb.rmi.jndi.CtxFactory
-Djava.naming.provider.url=
corbaloc::1.2@$<HOST>:$<NAMESERVICE_PORT>/NameService"
-Dorg.omg.CORBA.ORBClass=org.openorb.CORBA.ORB
-Dorg.omg.CORBA.ORBSingletonClass=org.openorb.CORBA.ORBSingleton
-Djavax.rmi.CORBA.StubClass=org.openorb.rmi.system.StubDelegateImpl
-Djavax.rmi.CORBA.UtilClass=org.openorb.rmi.system.UtilDelegateImpl
-Djavax.rmi.CORBA.PortableRemoteObjectClass=
org.openorb.rmi.system.PortableRemoteObjectDelegateImpl
■ iPlanet
-Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory
-Djava.naming.provider.url=iiop://$<HOST>:$<NAMESERVICE_PORT>
■ Web Logic
-Djava.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
-Djava.naming.provider.url=t3://$<HOST>:$<NAMESERVICE_PORT>
■ WebSphere
-Djava.naming.factory.initial=
com.ibm.websphere.naming.WsnInitialContextFactory
-Djava.naming.provider.url=iiop://$<HOST>:$<NAMESERVICE_PORT>"
If you want to use more than one EJB container in your application, you’ll have to
set these properties through code. For example, to set the JNDI context for the Web
Logic EJB container, you would add the following method:
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, "t3://
$<HOST>:$<NAMESERVICE_PORT>");
6 Configuration Reference
The elements (defined by tags) of an XML file can include attributes, other elements,
or both. The sections below include tables that describe those elements. The
attributes and sub-elements of a parent element can be tags or attributes: If the
item’s name is surrounded by < and >, the item is a sub-element (or tag); otherwise,
it’s an attribute. Table 6-1 describes the meaning of the symbols in the Use column
in the tables that describe an element’s members.
Symbol in
Use column Meaning
Nothing The tag or attribute is required by the parent tag.
? The element or attribute can be omitted.
* The element can be present zero or more times
within the parent element.
+ The element must be present at least once within
the parent element.
77
Apple Computer, Inc. January 2002
C H A P T E R 6
Configuration Reference
Configuration Reference
Configuration Reference
<bind-xml>
The attribute or element name and XML schema must be specified for all XML-
dependent fields. The node attribute indicates whether the field maps to an attribute,
another tag, or the textual content of this tag. Only simple types (primitives, date,
string, and so on) can be used for attribute values. Only one field can be specified as
the content model in a given object. Table 6-2 describes the <bind-xml> tag’s
members.
Configuration Reference
<cache-type>
This tag tells the container how to cache instances of this enterprise bean. Table 6-3
describes the members of this element.
<class>
This tag describes the mapping between a Java class (enterprise bean
implementation) and an SQL table, an XML element, an LDAP entry, or any other
engine. To map a class into LDAP, an identity field must be specified.
A class is specified by its Java class name, including the package name; for example,
com.my.ejb.Person. If a class extends another class for which a mapping file exists,
you should use the extends attribute to include the class being extended. Do not use
the extends attribute to describe Java class inheritance that is not reflected in any
mapping.
Configuration Reference
The class mapping specifies each field in the class that is mapped to a table column.
Fields that are not mapped are not stored, read, or otherwise processed. Table 6-4
describes the <class> tag’s members.
Configuration Reference
<field>
This tag specifies the mapping between an enterprise bean’s field and an SQL table
column, an XML element or attribute, an LDAP attribute, and so on. Table 6-5
describes its members.
The mapping is specified from the perspective of the bean’s implementation class.
The field name is required even if no such field exists in the class in order to support
field references. A field is an abstraction of an enterprise bean’s property: It can refer
to a property directly (by mapping to a public instance variable, not static nor
transient) or indirectly by using accessor methods.
Configuration Reference
Unless specified otherwise, the persistence manager accesses the field through get
and set methods, whose names are derived from the field name. For example, for a
field called lastName, the accessors String getName() and void setName(String) are
used. Collection fields require only a get method, except an array requires both a get
and a set method. If the accessors are specified through the get-method and set-
method attributes, the persistence manager accesses the field only through those
methods. The methods must be public and not static.
If the direct attribute is true, the field is accessed directly. The field must be public,
not static nor transient.
The type attribute indicates the type of the instance variable being mapped or the
type of each a collection’s elements. You can use fully qualified class names or a
short name, as Table 6-6 illustrates.
Table 6-6 Values for the type attribute of the <field> tag for CMP beans
string java.lang.String
integer integer
long long
boolean boolean
double double
float float
big-decimal java.math.BigDecimal
byte byte
date java.util.Date
short short
char char
bytes byte[]
Configuration Reference
Table 6-6 Values for the type attribute of the <field> tag for CMP beans
strings string[]
locale java.lang.Locale
If the field is a collection, you specify the collection type through the collection
attribute and the type of each element of the collection through the type attribute.
Use the following table to determine the appropriate value for the collection
attribute.
Table 6-7 Values for the collection attribute of the <field> tag in CMP beans
The “Default implementation” column indicates the type used if the object holding
the collection is null and needs to be instantiated. For hashtable and map collections,
the persistence manager adds an object with the put(Object, Object) method: The
object added is both the key and the value.
Table 6-5 (page 83) describes the members of the <field> tag.
Configuration Reference
<key-generator>
This tag specifies parameters for the key generator (if needed). For example, to
obtain sequential values from the table SEQTAB, use
<key-generator name="SEQUENCE">
<param name="table" value="SEQTAB">
<param name="global" value="0">
</key-generator>
<class key-generator="SEQUENCE">
...
</class>
If you have to use several key generators of the same type for the same data store,
use aliases:
Configuration Reference
Table 6-9 lists the key-generator names supported in the persistence manager.
Name Description
MAX MAX(pk) + 1 generic algorithm.
HIGH/LOW HIGH/LOW generic algorithm.
UUID UUID generic algorithm.
IDENTITY Supports auto-increase identity fields in Sybase ASE/ASA, MS SQL
Server, MySQL, and Hypersonic SQL.
SEQUENCE Supports the SEQUENCE algorithm in Oracle, PostgreSQL, Interbase,
and SAP DB.
<ldap>
This tag contains field mapping information for fields mapped to LDAP resources.
Table 6-10 describes its members.
Configuration Reference
<map-to>
This tag specifies the mapping between an enterprise bean and an SQL table. Table
6-11 describes the tag’s members.
<mapping>
The <mapping> tag is the root element of the entire file. It defines a collection of class
mappings. Its members are described in Table 6-12.
Configuration Reference
<param>
This tag is used to provide named parameters to the containing element. Table 6-13
describes the members of this tag.
<sql>
This tag provides field mapping information that is relevant only for fields mapped
to SQL tables. The type can be the proper Java-class type returned by the JDBC
driver or the SQL type without precision, for example, "java.math.BigDecimal" or
"numeric". However, the type could contain the parameter for the SQL-to-Java type
convertors in square brackets, for example, "char[01]" for false=0, true=1
conversion from the boolean Java type to the char SQL type.
Configuration Reference
The DTD for the local and global transaction configuration files can be found at
http://castor.exolab.org/jdo-conf.dtd, and is shown in Listing 6-2.
Configuration Reference
<data-source>
This tag specifies the JDBC 2.0 data-source used to obtain new connections to the
database server. Table 6-15 describes its members.
<data-source class-name="org.postgresql.PostgresqlDataSource">
<param host="host" database="db"
user="user" password="secret"/>
</data-source>
Configuration Reference
<database>
This tag specifies the database server that the persistence manager uses to establish
connections to a database. Table 6-16 describes its members.
Configuration Reference
■ PostgreSQL
<data-source class-name="org.postgresql.PostgresqlDataSource">
<params host="host" database="db"
user="user" password="secret"/>
</data-source>
■ InstantDB
<driver class-name="org.enhydra.instantdb.jdbc.idbDriver"
url="jdbc:idb:C:\\castor-0.8.8\\db\\test\\test.prp">
<param name="user" value=""/>
<param name="password" value=""/>
</driver>
<driver>
This tag specifies the JDBC 2.0 driver used to obtain new connections to the data-
source server. Table 6-17 describes the members of this element.
Configuration Reference
engine
This attribute specifies a database engine. Table 6-18 lists the engines supported by
the persistence manager.
Configuration Reference
<jndi>
This tag specifies the database you want to connect to. The persistence manager
uses the JNDI environment naming context (ENC) to obtain a connection to the
database. Table 6-19 describes this element’s only attribute.
<jndi name="java:comp/env/jdbc/mydb"/>
Configuration Reference
<config>
The <config> tag provides the configuration for a JDBC data source. Table 6-20
describes its members.
Configuration Reference
<connector>
The <connector> tag specifies a database-connection factory. Table 6-21 describes its
members.
<dataSource>
The <dataSource> tag contains a specification for a JDBC data source. Table 6-22
describes the members of this element.
Configuration Reference
<domain>
The <domain> tag is the root tag of the entire file. Table 6-23 describes the members
of this element.
<limits>
The <limits> tag provides resource limits for a data source or a connector. Table 6-
24 describes its members.
Configuration Reference
<resources>
The <resources> tag is the top-level tag of a list of JDBC data sources and JCA
connectors. Table 6-25 describes the members of the <resources> tag.
<?xml encoding="US-ASCII"?>
<!ELEMENT class-name (#PCDATA)>
<!ELEMENT cmp-field-name (#PCDATA)>
<!ELEMENT codebase (#PCDATA)>
<!ELEMENT connection-manager (connection-manager-id, class-
name,properties?)>
<!ELEMENT connection-manager-id (#PCDATA)>
<!ELEMENT connector (connector-id, connection-manager-id, managed-connection-
factory)>
<!ELEMENT connector-id (#PCDATA)>
Configuration Reference
Configuration Reference
Configuration Reference
<connection-manager>
This tag specifies a connection manager. Table 6-26 describes its members.
Configuration Reference
<connector>
This tag defines a connector. Table 6-27 describes its members.
<connectors>
This tag encloses connectors or connection managers. Table 6-28 describes its
members.
Configuration Reference
<container-system>
This tag delimits the container configuration section of the deployment
configuration file. Table 6-29 describes its members.
<containers>
This tag encloses containers for the three types of enterprise beans: stateless session
beans, stateful session beans, and entity beans. Table 6-30 describes its members.
Configuration Reference
<ejb-ref>
This tag defines a reference to a bean so that the bean can be accessed using JNDI
calls. Table 6-31 describes its members.
<ejb-ref-location>
This tag identifies a bean through its name (using its <ejb-deployment-id> member)
or through its remote interface and JNDI context ID. Table 6-32 describes its
members.
Configuration Reference
<entity-bean>
This tag defines an entity session bean. Table 6-33 describes its members.
Configuration Reference
<entity-container>
This tag defines an entity-bean container and encloses the definition of entity beans.
Table 6-34 describes its members.
<env-entry>
This tag defines an environment variable and its value (which can be accessed by
other beans through JNDI). Table 6-35 describes its members.
Configuration Reference
<facilities>
This tag specifies the runtime environment: proxy-generation attributes, remote
JNDI contexts, data-source connections, and J2EE services. You should not change
the information within <facilities> and </facilities> tags. Table 6-36 describes
its members.
<remote-jndi-contexts> ?
<connectors> ?
<services>
<jndi-context>
This tag defines one external JNDI context to be used by the application. Table 6-37
describes its members.
Configuration Reference
<jndi-enc>
This tag encloses naming information so that this bean can be located through JNDI.
Table 6-38 describes the members of the <jndi-enc> tag.
<intra-vm-server>
This tag specifies the dynamic factory proxy to use to create client proxies of the real
EJB objects. Table 6-39 describes its member.
Configuration Reference
<managed-connection-factory>
This tag defines a managed-connection factory. Table 6-43 describes its members.
<method>
This tag specifies a home or remote interface method of an enterprise bean. Table 6-
41 describes its members.
Configuration Reference
These examples of the three possible styles of the <method> tag’s syntax:
■ Referring to all the methods (home and remote interfaces) defined within the
<container-system> tag.
<method>
<method-name>*</method-name>
</method>
<method>
<method-name>METHOD</method-name>
<method-params>
<method-param>PARAM-1</method-param>
<method-param>PARAM-2</method-param>
...
<method-param>PARAM-n</method-param>
</method-params>
</method>
<method-params>
This tag is used when further identification of a method is needed due to method-
name overloading. Table 6-42 describes its members.
Configuration Reference
<method-permission>
This tag maps security roles to methods. Table 6-43 describes its members.
<method-transaction>
This tag specifies how the container manages transaction scopes when delegating a
method invocation to an enterprise bean’s implementation class. Table 6-44
describes its members.
Configuration Reference
<openejb>
This is the root tag of the deployment configuration file. Table 6-45 describes its
members.
<properties>
This tag encloses a set of property-value definitions. Table 6-46 describes its
member.
<property>
This tag encloses a property-value definition. Table 6-47 describes its members.
Configuration Reference
<query>
This tag can be used to declare a query statement and bind it to a specific finder
method. The value can be retrieved using the
org.openejb.core.DeploymentInfo.getQuery method. Table 6-48 describes the
members of the <query> tag.
<remote-jndi-contexts>
This tag groups external JNDI contexts. Table 6-49 describes its members.
Configuration Reference
<resource>
This tag defines a resource. Table 6-50 describes its members.
<resource-ref>
This tag specifies a reference to an external resource. Table 6-51 describes its
members.
Configuration Reference
<resource-ref>
<res-ref-name>comp/env/jdbc/Employee</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<properties>
<property>
<property-name>url</property-name>
<property-value>jdbc:odbc:orders</property-value>
</property>
<property>
<property-name>username</property-name>
<property-value>Admin</property-value>
</property>
<property>
<property-name>password</property-name>
<property-value></property-value>
</property>
</properties>
</resource-ref>
Configuration Reference
<role-mapping>
This tag maps a logical security role to a physical security role. Table 6-52 describes
its members.
<security-role>
This tag defines a logical role name. Table 6-53 describes its members.
Configuration Reference
<security-role-ref>
This tag specifies a security-role reference. Table 6-54 describes its members
<security-service>
This tag defines a security service. Table 6-55 describes its members.
Configuration Reference
<services>
This tag encloses services used by the container. Table 6-56 describes its members.
<stateful-bean>
This tag defines a stateful session bean. Table 6-57 describes its members.
Configuration Reference
<stateful-session-container>
This tag defines a stateful session bean container and encloses the definitions of
stateful session beans. Table 6-58 describes its members.
<stateless-bean>
This tag defines a stateless session bean. Table 6-59 describes its members.
Configuration Reference
<stateless-session-container>
This tag defines a stateless session bean container and encloses the definitions of
stateless session beans. Table 6-60 describes its members.
Configuration Reference
<transaction-service>
This tag defines a transaction service. Table 6-61 describes its members.
Date Notes
January Reorganized Chapter 6, “Configuration Reference” (page 77), in
2002 alphabetical order.
Added index and glossary.
123
Apple Computer, Inc. January 2002
A P P E N D I X A
124
Apple Computer, Inc. January 2002
7 Glossary
bean class The bean class implements the remote interface The remote interface
methods defined in an enterprise bean’s defines an enterprise bean’s business
business methods, which are defined in the methods, which are used by its clients to
remote interface. interact with the bean.
bean client An application or enterprise Web application, Web app File structure
bean that makes use of an enterprise bean. that contains servlets, JSP pages, HTML
documents and other resources. This
deployment descriptor XML file that structure can be deployed on any servlet-
describes the configuration of a Web enabled HTTP server. See also servlet
application. It’s located in the WEB-INF container.
directory of the application’s WAR file and
named web.xml. See also WAR.
125
Apple Computer, Inc. January 2002
G L O S S A R Y
126
Apple Computer, Inc. January 2002
Index
B D
bean class 16 data stores, defining local and global 69
bean clients 15 databases
bean frameworks connection definitions
creating 19–44 InstantDB 93
in Mac OS X 20–29 jConnect 92
in Windows 39–40, 49–50 Oracle thin driver 92
deploying 17 PostgreSQL 93
bean proxy, creating a 33, 41 grouping beans in the EJB-container
bean source files, working with 45–49 configuration file 59
bean-client applications primary-key–generator algorithms
adding bean frameworks 40 Interbase 68
configuring 55–74 Oracle 68
data stores 57 PostgreSQL 68
EJB Containers 58 supported servers 62
creating deployment descriptor 16, 27
in Mac OS X 30–38
in Windows 40–44
grouping beans 59
E, F
EJB (Enterprise JavaBeans) 11
C EJB Client Interfaces target 28
EJB Deployment target 28
CMPConfiguration.xml file 56, 60, 78 ejb-jar.xml file 27
containers, EJB engine attribute 94
external 18, 73 enterprise beans
internal 17 See also bean frameworks
iPlanet 74 mapping to data stores 63–69
OpenEJB 16, 74 third-party 19
responsibilities 16 enterprise objects and bean-client applications
Web Logic 74 32
WebSphere 74 entity beans 16
127
© Apple Computer, Inc. January 2002
INDEX
G M, N
GlobalTransactionConfiguration.xml file 56, Main.java file 36, 43
60 mapping beans to data stores 63–69
greeting instance variable 36, 43 See also primary-key–generator algorithms
mapping files 63
primary keys 64
message method 29, 36, 43
H
Hello.java file 29, 39
HelloBean project 20, 39 O
HelloBean_Client project 40
home interface 16, 25 OpenEJB EJB container 74
openejb_config.dtd file 99
OpenEJBConfiguration.xml file 56, 70, 99
Oracle database, SEQUENCE
I primary-key–generator algorithm for 68
Oracle thin-driver database, connection
InstantDB database, connection definition for 93 definition for 92
Interbase database, primary-key–generator ORB (Object Request Broker), OpenORB 17
algorithm for 68
iPlanet EJB container 74
P, Q
J, K performance, application 59
persistence manager
J2EE (Java 2 Platform, Enterprise Edition) 11 Castor JDO 17, 62
JavaMail 55, 58 configuring 62
jConnect, connection definition for 92 PostgreSQL
connection definition 93
SEQUENCE primary-key–generator algorithm
68
L primary-key–generator algorithms 65–69
LocalTransactionConfiguration.xml file 55, See also tags
60 <key-generator>
HIGH/LOW 65
IDENTITY 67
MAX 65
SEQUENCE 67
UUID 67
128
© Apple Computer, Inc. January 2002
INDEX
R <managed-connection-factory> 110
<mapping> 88
remote interface 16, 26 <map-to> 88
<method> 110
<method-params> 111
<method-permission> 71, 112
S <method-transaction> 71, 112
<openejb> 113
session beans, stateful and stateless 16 <param> 89
Session.java file, creating a bean proxy in 33, <query> 114
41 <resource> 115
<resource-ref> 115
<resources> 99
<role-mapping> 117
T, U, V <security-role> 71, 117
tags <security-role-ref> 118
<bind-xml> 80 <services> 119
<cache-type> 81 <sql> 89
<class> 81 <stateful-bean> 119
<config> 96 <stateful-session-container> 120
<connection-manager> 102 <stateless-bean> 120
<connector> 97, 103 <stateless-session-container> 121
<connectors> 103 <transaction-service> 122
<containers> 71, 104 third-party beans 19
<container-system> 104 transaction manager
<database> 92 configuring
<dataSource> 97 See also data stores, local and global
<data-source> 91 local and global configuration files 59, 90
<domain> 98 summary 61
<driver> 93 Tyrex 17
<ejb-ref> 105 TransactionManagerConfiguration.xml file
<ejb-ref-location> 105 configuring the EJB container in a bean-client
<entity-bean> 106 application 37
<entity-container> 107 description of XML tags 96
<env-entry> 107 example 61
<facilities> 108 purpose 55
<field> 83
<intra-vm-server> 109
<jndi> 95
<jndi-context> 108
W, X, Y, Z
<jndi-enc> 109 Web Logic EJB container 74
<key-generator> 86 WebSphere EJB container 74
<ldap> 87
<limits> 98
129
© Apple Computer, Inc. January 2002
INDEX
130
© Apple Computer, Inc. January 2002