BEA Systems, Inc.

examples.axiom
Class AxiomExample

java.lang.Object
  |
  +--examples.axiom.AxiomExample

public class AxiomExample
extends java.lang.Object

Shows how to use Theory Center's Axiom package of eBusiness Smart Components. This example illustrates how to use the different types of Axiom eBusiness Smart Components, including Belongings and Entities. You can also see how to use the abstract factory pattern and the Collections API
The Axiom package contains light weight components known as belongings, as well as Entity and Session EJB components. Belongings can be aggregated to other components by value. EJBs are used alone or aggregated to other components by reference or value.
Belongings are local. Whether client or server-side, the Belonging is local. They are always passed by value. Although not EJBs, belongings still are eBusiness Smart Components and use the abstract factory pattern: you don't use new() to create one, instead, you use Home.create(). This example also shows the use of Remote Iterators, one of Theory Center's collection APIs. You can iterate through a collection both locally and remotely. Locally, the whole collection is sent to you from the server and you can traverse it. This is good for small collections where you need to iterate a lot. For large collections, you can use one or more remote iterators. Remote iterators traverse the collection in the server. That way, you only bring over the net the values that you need saving bandwidth. They also serve as "bookmarks" on a collection, since they "remember" in what position you leave them.

See Also:
Belonging, theory.smart.foundation.RemoteIterator, Email, CreditCard, Customer

Constructor Summary
AxiomExample()
          The default constructor for the AxiomExample class
 
Method Summary
 void addBelongings(Customer customer)
          Demonstrates the creation and use of Belongings Demonstrates the use of the abstract factory pattern to create belongings.
 void exitExample(java.lang.String message, java.lang.Exception e)
          Terminates the program, displaying the message and exception
 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)
          Parses the command line and runs the example.
 void removeBelongings(Customer customer)
          Shows how to remove belongings from a larger component.
 void run()
          Controls the examples sequence.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AxiomExample

public AxiomExample()
The default constructor for the AxiomExample class
Method Detail

addBelongings

public void addBelongings(Customer customer)
Demonstrates the creation and use of Belongings Demonstrates the use of the abstract factory pattern to create belongings. The newly created belongings are then aggreagated to an entity bean by value using the collection APIs.
In this method, we have a customer entity bean in our hands. Let's add belongings. Belongings are Theory Center's lightweight components. They need to be "owned" by someone, and they only make sense within the context of their owner (e.g. Email is owned by a customer).
Parameters:
customer -  

removeBelongings

public void removeBelongings(Customer customer)
Shows how to remove belongings from a larger component. It also shows how to obtain information about belonging collections from a larger component.
Parameters:
customer - The customer that has the belongings

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

run

public void run()
Controls the examples sequence.
  1. Finds (or creates) a customer.
  2. Adds belongings to this customer.
  3. It removes the belogings.
The customer object is not removed (so we can find it next time)

getInitialContext

public javax.naming.Context getInitialContext()
                                       throws javax.naming.NamingException
Gets an initial context for the current user, password and url.
Returns:
Context
Throws:
javax.naming.NamingException - If the context provider can not be found while getting the Initial Context

exitExample

public void exitExample(java.lang.String message,
                        java.lang.Exception e)
Terminates the program, displaying the message and exception
Parameters:
message - the exit message
e - the exception that was raised

main

public static void main(java.lang.String[] args)
Parses the command line and runs the example. The command-line arguments are optional, but if any are supplied, they are interpreted in this order:
  1. customerKey: Customer Key, default "TerrySmith"
  2. url: URL such as "t3://localhost:7601" of Server
  3. user: User name, default null
  4. password: User password, default null
You can also get the usage by passing -?

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved