Defining an EJB component  Deploying the component classes

Chapter 7: Creating Enterprise JavaBeans Components

Configuring the component properties

After you have defined the component and its methods, you may need to configure the properties described here.

StepsConfiguring EJB component properties

  1. If you are defining a stateful session bean, optionally switch to the Resources tab and enter a time limit in the Instance Timeout field. This value specifies how long, in seconds, that a client can hold an instance reference without making any calls. If you do not enter a value, or you specify 0, client references do not expire.

  2. If creating an entity bean with container-managed persistence, configure the persistence settings as described in “Configuring automatic or EJB CMP persistence”.

  3. Optionally configure the transaction properties for each method in the home and remote interfaces, or if all are the same, configure the component’s transaction properties. See “Component properties: Transactions” for more information.

  4. If defining a version 2.0 or 1.1 EJB that calls other components, configure the properties described in “Configuring EJB references”.

  5. If defining a version 2.0 or 1.1 EJB that uses database connections or JavaMail sessions, configure the properties described in “Configuring resource references”.

  6. If defining a version 2.0 or 1.1 EJB, configure method security constraints as described in “Configuring role references and method permissions”.

  7. If defining a version 2.0 EJB that calls other components, optionally configure the Run-As Identity properties to specify the identity used in intercomponent calls. See “Component properties: Run-As Identity” for more information.

  8. If defining a version 2.0 EJB that uses JMS, configure the properties described in “Component properties: Resource Environment Refs”.

  9. If defining a version 1.0 EJB that calls other components, configure the properties described in “Component properties: Run-As Mode”.

  10. Optionally configure environment properties as described in “Configuring environment properties”.

Configuring EJB references

Your EJB can use EJB references to instantiate proxies for other EJBs. You do not need to create references in order to invoke other EJBs from your code. However, doing so ensures that EJB references will be cataloged in the deployment descriptor if you export the EJB. There are two types of references:

NoteStubs used for EJB references must be in the custom class list You must list stubs used for intercomponent calls in the custom class list for your component, as described in “Custom class lists for Java and EJB components”.

Configuring resource references

Resource references are used to obtain connector and database connections, and to access JMS connection factories, JavaMail sessions, and URL links.

StepsAdding or editing a resource reference

  1. Open the Component Properties dialog box.

  2. Follow the instructions in “Adding a resource reference”, or “Editing a resource reference”.

Configuring role references and method permissions

To configure authorized access to an EJB 2.0 or 1.1 component, you must configure method permissions settings or call the isCallerInRole Java method to restrict access. See Chapter 2, “Securing Component Access,” in the EAServer Security Administration and Programming guide for more information.

Configuring environment properties

Environment properties allow you to specify read-only data for use by an EJB. For example, you might use environment properties to tune the size of a data cache used in your implementation, or to specify the name of a log file. Use environment properties for any constant value that might change when the EJB is deployed to another server.

When coding your EJB, use JNDI to retrieve environment properties, using the prefix java:comp/env in JNDI lookups.

When you export your EJB, the deployment descriptor catalogs the environment properties used by your servlets and JSPs, as well as each property’s Java datatype and default value. When the EJB is imported to another server, the deployer can override the default value for each environment property.

NoteEnvironment properties for EJB 1.0 components An EJB 1.0 component can only have environment properties with datatype String, and these properties must be configured in the Advanced window. Any property name that does not begin with is considered an environment property. In source code, use the EJBContext.getEnvironment method to retrieve property values. You cannot use the JNDI InitialContext.lookup method to retrieve these values.

StepsAdding or editing an EJB environment property

  1. Open the Component Properties dialog box.

  2. Follow the instructions in “Adding an environment property”, or “Editing an environment property”.

Copyright © 2005. Sybase Inc. All rights reserved. Deploying the component classes