Sample business object properties

This section provides the following examples that illustrate how the connector processes a business object:

EJB JAR file code

The following sample code is an excerpt from an EJB JAR file that defines the methods of an EJB class called MusicCartBean. Notice the method defined at the end of the code sample: getCustomer.

Note:
Not all of the methods for this class are defined in the code sample provided here. The sample is a section of a larger file

The business object that corresponds to this code is illustrated in Figure 4.

public class MusicCartBean implements SessionBean {
   CustomerHelper customerHelper;
   ArrayList shoppingList;
   RecordingHelper[] recordHelperArr;
  
  
    // EJB Methods
    public void ejbRemove() {}
    public void ejbActivate() {}
    public void ejbPassivate() {}
    public void setSessionContext (SessionContext ctx) {}
  
   public void ejbCreate(String person,String password, String email)
       throws CreateException {
            if (person == null || person.equals("")) {
              throw new CreateException(
                "Name cannot be null or empty.");
            }
            else {
              customerHelper = new
                CustomerHelper(person, password, email);
              customerHelper.setName(person);
              customerHelper.setEmail(email);
              customerHelper.setPassword(password);
            }
            shoppingList = new ArrayList();
   }
  
    public void ejbCreate(CustomerHelper customerHelper)
       throws CreateException {
           customerHelper.setName(customerHelper.name);
           customerHelper.setEmail(customerHelper.email);
           customerHelper.setPassword(customerHelper.password);
           shoppingList = new ArrayList();
   }
    // Business methods implementation
  
   public CustomerHelper getCustomer() {
       return customerHelper;
   }
  
 

Business object sample

The following sample screen illustrates the business object structure that corresponds to the source code presented in EJB JAR file code. This business object is created by the ODA, which discovers the objects and constructs defined in the original EJB JAR file and generates corresponding business objects. For information about how to use the ODA to generate this example, see Creating and modifying business objects.

Notice the fourth attribute, getCustomer. This attribute contains a complex method object that corresponds to the getCustomer method defined at the end of the sample code for the MusicCartBean class, presented in EJB JAR file code.


Figure 4. Business object level ASI and supported verbs

Copyright IBM Corp. 1997, 2003