The Object Wrapped Bank example

This example shows how one can create Object Wrappers, both typed and untyped. It also shows how to install the Object Wrappers and illustrates their behaviour in various configurations. Typed Object Wrappers can be used in various circumstances ranging from caching of results for optimizing remote calls to validating arguments to methods. Untyped Object Wrappers can be used for instrumenting calls to various objects at runtime to perform tasks like tracing and timing. These sample uses will be shown in the example. 

From this example, you will learn how to:

Directory Contents

Building this example

Note: This example will not run under JDK1.0.2. The solution to this problem is to upgrade to JDK1.1.0 or higher.

 Typing make(vbmake on Windows) in the object_wrapped_bank subdirectory will build the following classes for the examples described above:

Compilation Errors and Warnings

None

Running this example

To run the examples, first make sure that the VisiBroker Smart Agent (osagent executable) is running on your network. Then start the Server using the command: Typed Object Wrappers Wait for the "AccountManager:BankManager is ready" message and query the balance in a user's account using the command or With the default name, the output you should see for the server is:
AccountManager:BankManager is ready.
+ SecureAccountManagerObjectWrapper: Verifying Name
+ SecureAccountManagerObjectWrapper: Access Granted
+ CachingAccountManager: Before Call
Created Jack B. Quick's account: 
+ SecureAccountManagerObjectWrapper: Verifying Name
+ SecureAccountManagerObjectWrapper: Access Denied
and the output you should see for the client is (Note that you may get a different balance as that is a random number):
+ CachingAccountObjectWrapper: Before calling balance: 
+ CachingAccountObjectWrapper: After  calling balance: 
The balance in Jack B. Quick's account is $195.8
Pass two
+ CachingAccountObjectWrapper: Before calling balance: 
+ CachingAccountObjectWrapper: Returning Cached value
+ CachingAccountObjectWrapper: After  calling balance: 
The balance in Jack B. Quick's account is $195.8
Trying Unauthorized Account
No permission to open this account
Untyped Object Wrappers Wait for the "AccountManager:BankManager is ready" message and query the balance in a user's account using the command or With the default name, the output you should see for the server is(Note that the null->balance() is correct output, since the account object is transient and does not have a name):
AccountManager:BankManager is ready.
Tracing: Before Call to         BankManager->open()
Created Jack B. Quick's account: 
Tracing: After call to  BankManager->open() env:[org.omg.CORBA.Environment[exception=null]]
Tracing: Before Call to         null->balance()
Tracing: After call to  null->balance() env:[org.omg.CORBA.Environment[exception=null]]
Tracing: Before Call to         null->balance()
Tracing: After call to  null->balance() env:[org.omg.CORBA.Environment[exception=null]]
Tracing: Before Call to         BankManager->open()
Created Unauthorized Account's account: 
Tracing: After call to  BankManager->open() env:[org.omg.CORBA.Environment[exception=null]]
and the output you should see for the client is (Note that you may get a different balance as that is a random number):
Timing: BankManager->open()
Tracing: Before Call to         BankManager->open()
Tracing: After call to  BankManager->open() env:[org.omg.CORBA.Environment[exception=null]]
Timing: Time for call   BankManager->open() = 120 ms.
Timing: null->balance()
Tracing: Before Call to         null->balance()
Tracing: After call to  null->balance() env:[org.omg.CORBA.Environment[exception=null]]
Timing: Time for call   null->balance() = 38 ms.
The balance in Jack B. Quick's account is $11.53
Pass two
Timing: null->balance()
Tracing: Before Call to         null->balance()
Tracing: After call to  null->balance() env:[org.omg.CORBA.Environment[exception=null]]
Timing: Time for call   null->balance() = 50 ms.
The balance in Jack B. Quick's account is $11.53
Trying Unauthorized Account
Timing: BankManager->open()
Tracing: Before Call to         BankManager->open()
Tracing: After call to  BankManager->open() env:[org.omg.CORBA.Environment[exception=null]]
pTiming: Time for call   BankManager->open() = 52 ms.

Play with the different combinations of typed and untyped to see behaviour in different configuration.

For your convenience, both the typed and untyped object wrappers have service initializers that allow you to install the object wrappers in different configurations at runtime. Services in this example are:

  • UtilityObjectWrappers
      Sub-Properties
    1. Tracing[=(<client|server>]
    2. Timing[=(<client|server>]
    In order to specify a sub-property it is important to specify the service in the ORBservices Specifying sub-properties without the client or the server value will install the wrapper on the client and the server sides. Also, the server takes a single option