Chapter 7 Enterprise JavaBeans Overview
The main change in EJB 1.1 involves the packaging of components. EJB 1.1 uses an XML deployment descriptor, and allows abstraction of container-specific resource references used within the source code. In addition, there are minor changes to the Java interfaces and classes.
For more details, see the EJB 1.1 and 1.0 specifications from Sun Microsystems .
The EJB 1.1 JAR file format does not specify Bean home names. Consequently, EJB 1.1 components imported into Jaguar use the default home name of package/component, where package is the Jaguar package name and matches the display-name attribute of the EJB deployment descriptor, and component is the Jaguar component name and matches the the Bean's ejb-name element in the deployment descriptor.
If you have an existing client application that invoke the component, you may have to change the component's home name or the name used in client application.
For intercomponent calls from EJB 1.1 components, you can use the EJB References property to alias the home name used in the Bean to an installed component with a different home name.
EJB 1.1 allows environment properties to be accessed using JNDI, and the EJBContext.getEnvironment method is now deprecated. Environment properties can also contain values of types other than String.
Environment properties used within a Bean must be cataloged in the Bean's deployment descriptor. For EJB 1.1 components installed in Jaguar, you configure environment properties on the Environment tab in the Component Properties dialog box. See "Configuring environment properties"
You must call the JNDI Context.lookup method to access environment properties. To locate the naming context, create a javax.naming.InitialContext object for java:comp/env. In this example, the application retrieves the value of the environment property maxExemptions and uses that value to determine an outcome:
Context initContext = new InitialCopntext();.
Context myEnv =
(Context)initContext.lookup("java:comp/env");
// Get the maximum number of tax exemptions
Integer max=(Integer)myEnv.lookup("maxExemptions");
// Get the minimum number of tax exemptions
Integer min = (Integer)myEnv.lookup("minExemptions");
// Use these properties to customize the business logic
if (numberOfExemptions > max.intValue() ||
(numberOfExemptions < min.intValue())
throw new InvalidNumberOfExemptionsException();
EJB 1.1 allows components to use logical names to access database connections, JavaMail sessions, and the home interfaces of other components. These names must be catalogued in the Bean's deployment descriptor. For components installed in Jaguar, you configure references on the Resource References tab in the Component Properties dialog box. See these sections for more information:
The getCallerIdentity and isCallerInRole(java.security.Identity) methods in the EJBContext interface are deprecated in EJB 1.1. Instead of getCallerIdentity, call getCallerPrincipal. Instead of isCallerInRole(java.security.Identity), call isCallerInRole(java.lang.String).
In Jaguar Manager, you can configure role references for your component in the Component Properties dialog box. Role references allow you to map names used in isCallerInRole(java.lang.String) calls to role names that exist on the server. Role references allow your component to be deployed on servers that do not have the same security configuration.
Declarative access control for EJB 1.1 components uses method-level settings.
Role Membership folder does not apply to EJB 1.1 components The Role Membership folder for packages and components in Jaguar Manager does not apply to EJB 1.1 components. There are two ways to control which clients can call EJB 1.1 component methods:
Configuring method permissions
Method permissions allow you to restrict access without writing code. Configure method permissions as follows:
Configuring role references
Role references are required if you call the isCallerInRole Java method to restrict access. Each reference maps a string used in isCallerInRole calls to a J2EE role that is configured in the package Role Mappings. To configure role references :
In accordance with the EJB 1.1 specification, you cannot set the transaction isolation level declaratively for EJB 1.1 components. The simplest way to configure the transaction isolation level is to configure the defaults on the databases that you access from your EJB components. If this is not possible, you must set the isolation level programmatically in the component implementation.
Except for the differences below, the EJB 1.1 client model is identical to the EJB 1.0 model:
Do not mix finder method return types All EJB components in a Jaguar package or an EJB 1.1 JAR file must use the same return type in finder methods.
Copyright © 2000 Sybase, Inc. All rights reserved. |