Overview | Package | Class | Tree | Deprecated | Index | Help
| bea Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## examples.passbyvalue
Class PassByValueExample

    java.lang.Object
      |
      +--examples.passbyvalue.PassByValueExample

public class PassByValueExample
extends java.lang.Object

Pass-by-value example. This example shows how you can get and set the atributes of an Entity eBSC by value. What this means is that instead of getting/setting one attribute at a time, you can request that a local copy of all attributes be sent to you directly, in one remote call. You can then read and modify this "Value object" or local copy, and send it back in one remote call. This has tremendous performance advantages compared to accessing one attribute at a time It is also important to be able to set many attributes within a single transaction without having to begin/commit a JTS User Transaction from the client. In short, pass-by-value is really handy! Our implementation is tightly-coupled: that means that at compile time, we enforce type consistency for getting/setting attributes in the value objects. This is a great advantage over "parameter sets", or "late-binding" implementations where you pass around a set of name/value pairs: in that case, if you change the type of an attribute your client will still compile but crash at runtime. That wouldn't happen using eBSCs, since the value object would change accordingly and the client would not compile if an assigment was illegal. And in case you're wondering, our value objects are generated by Theory Center's SmartGenerator (based on a UML model), so they don't add any maintenance costs.

Author:
  Copyright (c) 1997-1999 by The Theory Center, Inc. All Rights Reserved.
See Also:
  `Customer`

Constructor Summary
`PassByValueExample()`

Method Summary
`void` | `addCustomerInfo(Customer customer)` This method adds information to a given Customer using the CustomerValue object.
`void` | `exitExample(java.lang.String message, java.lang.Exception e)` Display the message and the exception and terminate the the program
`Customer` | `findOrCreateCustomer(java.lang.String customerKey)` Finds or Creates a customer with the given customerKey.
`javax.naming.Context` | `getInitialContext()` Gets an initial context for the current user, password and url.
`static void` | `main(java.lang.String[] args)` Main driver.
`void` | `printCustomerInfo(Customer customer)` This method prints customer information using a value object.
`void` | `run()` This method runs the example.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PassByValueExample

    public PassByValueExample()

Method Detail

### addCustomerInfo

    public void addCustomerInfo(Customer customer)

  This method adds information to a given Customer using the CustomerValue object. It updates all attributes of the customer in a single remote and a single transaction
  Parameters:
    `customer` - The customer we want to modify

### findOrCreateCustomer

    public Customer findOrCreateCustomer(java.lang.String customerKey)

  Finds or Creates a customer with the given customerKey.
  Parameters:
    `customerKey` - the key for the customer
  Returns:
    the customer's entity bean

### getInitialContext

    public javax.naming.Context getInitialContext()
                                           throws java.lang.Exception

  Gets an initial context for the current user, password and url.
  Returns:
    Context
  Throws:
    java.lang.Exception - if there is an error in getting the Context

### main

    public static void main(java.lang.String[] args)

  Main driver. The comman line arguments are optional, but if any are supplied, they are interpreted in this order: customerKey Customer Key, default "TerrySmith" url URL such as "t3://localhost:7601" of Server user User name, default null password User password, default null You can also get the usage by passing -?

### exitExample

    public void exitExample(java.lang.String message,
                            java.lang.Exception e)

  Display the message and the exception and terminate the the program
  Parameters:
    `message` - The message to display upon termination
    `e` - The exception thrown or null if no exception was thrown

### printCustomerInfo

    public void printCustomerInfo(Customer customer)

  This method prints customer information using a value object. It shows how to read attributes, including collections
  Parameters:
    `customer` - the customer entity

### run

    public void run()

  This method runs the example. First it creates a Customer entity. Then, it gets the value object It fills out the value object with information, and updates the Customer (by value) Then, it retrives and prints the info (again, by value)

Overview | Package | Class | Tree | Deprecated | Index | Help
| bea Systems, Inc.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

© Copyright 2000 bea Systems, Inc. All rights reserved.