VisiBroker for Java Developer’s Guide : Using object wrappers

Using object wrappers
This section describes the object wrapper feature of VisiBroker, which allows your applications to be notified or to trap an operation request for an object.
Object wrappers overview
The VisiBroker object wrapper feature allows you to define methods that are called when a client application invokes a method on a bound object or when a server application receives an operation request. Unlike the interceptor feature which is invoked at the VisiBroker ORB level, object wrappers are invoked before an operation request has been marshalled. In fact, you can design object wrappers to return results without the operation request having ever been marshalled, sent across the network, or actually presented to the object implementation. For more information about VisiBroker Interceptors, see “Using VisiBroker Interceptors”.
Object wrappers may be installed on just the client-side, just the server-side, or they may be installed in both the client and server portions of a single application.
The following are a few examples of how you might use object wrappers in your application:
Note
Externalizing a reference to an object for which object wrappers have been installed, using the VisiBroker ORB Object's object_to_string method, will not propagate those wrappers to the recipient of the stringified reference if the recipient is a different process.
Typed and un-typed object wrappers
VisiBroker offers two kinds of object wrappers: typed and untyped. You can mix the use of both of these object wrappers within a single application. For information on typed wrappers, see “Typed object wrappers”. For information on untyped wrappers, see “Untyped object wrappers”. The following table summarizes the important distinctions between these two kinds of object wrappers.
Special idl2java requirements
Whenever you plan to use typed or untyped object wrappers, you must ensure that you use the -obj_wrapper option with the idl2java compiler when you generate the code for your applications. This will result in the generation of:
Object wrapper example applications
The sample client and server applications used to illustrate both the typed and untyped object wrapper concepts in this section are located in the following directory:
<install_dir>\examples\vbroker\interceptors\objectWrappers\
Untyped object wrappers
Untyped object wrappers allow you to define methods that are to be invoked before an operation request is processed, after an operation request is processed, or both. Untyped wrappers can be installed for client or server applications and you can also install multiple versions.
You may also mix the use of both typed and untyped object wrappers within the same client or server application.
By default, untyped object wrappers have a global scope and will be invoked for any operation request. You can design untyped wrappers so that they have no effect for operation requests on object types in which you are not interested.
Note
Unlike typed object wrappers, untyped wrapper methods do not receive the arguments that the stub or object implementation would receive nor can they prevent the invocation of the stub or object implementation.
The following figure shows how an untyped object wrapper's pre_method is invoked before the client stub method and how the post_method is invoked afterward. It also shows the calling sequence on the server-side with respect to the object implementation.
Figure 34
Using multiple, untyped object wrappers
Figure 35
Order of pre_method invocation
When a client invokes a method on a bound object, each untyped object wrapper pre_method will receive control before the client's stub routine is invoked. When a server receives an operation request, each untyped object wrapper pre_method will be invoked before the object implementation receives control. In both cases, the first pre_method to receive control will be the one belonging to the object wrapper that was registered first.
Order of post_method invocation
When a server's object implementation completes its processing, each post_method will be invoked before the reply is sent to the client. When a client receives a reply to an operation request, each post_method will be invoked before control is returned to the client. In both cases, the first post_method to receive control will be the one belonging to the object wrapper that was registered last.
Note
If you choose to use both typed and untyped object wrappers, see “Combined use of untyped and typed object wrappers” for information on the invocation order.
Using untyped object wrappers
The following are the required steps for using untyped object wrappers. Each step is discussed in further detail in the following sections.
1
2
Generate the code from your IDL specification using the idl2java compiler with the -obj_wrapper option.
3
4
5
6
7
Use the ChainUntypedObjectWrapperFactory add method to add your factory to the chain.
Implementing an untyped object wrapper factory
The implementation of the TimingUnTypedObjectWrapperFactory, part of the objectWrappers sample applications, shows how to define an untyped object wrapper factory, derived from the UntypedObjectWrapperFactory.
Your factory's create method will be invoked to create an untyped object wrapper whenever a client binds to an object or a server invokes a method on an object implementation. The create method receives the target object, which allows you to design your factory to not create an untyped object wrapper for those object types you wish to ignore. It also receives an enum specifying whether the object wrapper created is for the server side object implementation or the client side object.
The following code sample illustrates an example of the TimingObjectWrapperFactory, which is used to create an untyped object wrapper that displays timing information for method calls.
package UtilityObjectWrappers;
import com.inprise.vbroker.interceptor.*;
public class
TimingUntypedObjectWrapperFactory implements
UntypedObjectWrapperFactory {
public UntypedObjectWrapper create(org.omg.CORBA.Object target,
com.inprise.vbroker.interceptor.Location loc) {
return new TimingUntypedObjectWrapper();
}
}
Implementing an untyped object wrapper
The following code sample shows the implementation of the TimingObjectWrapper. Your untyped wrapper must be derived from the UntypedObjectWrapper class, and you may provide an implementation for both the pre_method or post_method methods in your untyped object wrapper.
Once your factory has been installed, either automatically by the factory's constructor or manually by invoking the ChainUntypedObjectWrapper::add method, an untyped object wrapper object will be created automatically whenever your client binds to an object or when your server invokes a method on an object implementation.
The pre_method shown in the following code sample obtains the current time, saves it in a private variable, and prints a message. The post_method also obtains the current time, determines how much time that has elapsed since the pre_method was called, and prints the elapsed time.
package UtilityObjectWrappers;
import com.inprise.vbroker.interceptor.*;
Public class
TimingUntypedObjectWrapper implements UntypedObjectWrapper {
private long time;
public void pre_method(String operation,
org.omg.CORBA.Object target,
Closure closure) {
System.out.println("Timing: " +
((com.inprise.vbroker.CORBA.Object) target)._object_name() + "->"
+ operation + "()");
time = System.currentTimeMillis();
}
public void post_method(String operation,
org.omg.CORBA.Object target,
org.omg.CORBA.Environment env,
Closure closure) {
long diff = System.currentTimeMillis() - time;
System.out.println("Timing: Time for call \t" + ((com.inprise.vbroker.CORBA.Object)
target)._object_name() + "->" + operation + "() = " + diff + " ms.");
}
}
pre_method and post_method parameters
Both the pre_method and post_method receive the parameters shown in the following table.
post_method only parameter used to inform the user of any exceptions that might have occurred during the previous steps of the method invocation.
Creating and registering untyped object wrapper factories
The following code shows a portion of the sample file UntypedClient.java, which shows the creation and installation of two untyped object wrapper factories for a client. The factories are created after the VisiBroker ORB has been initialized, but before the client binds to any objects.
// UntypedClient.java
import com.inprise.vbroker.interceptor.*;
Public class UntypedClient {
public static void main(String[] args) throws Exception {
// Initialize the ORB.
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);
doMain (orb, args);
}
public static void domain(org.omg.CORBA.ORB orb, String[] args) throws
Exception {
ChainUntypedObjectWrapperFactory Cfactory =
ChainUntypedObjectWrapperFactoryHelper.narrow(
orb.resolve_initial_references("ChainUntypedObjectWrapperFactory")
);
Cfactory.add(new UtilityObjectWrappers.TimingUntypedObjectWrapperFactory(),
Location.CLIENT);
Cfactory.add(new
UtilityObjectWrappers.TracingUntypedObjectWrapperFactory(),
Location.CLIENT);
// Locate an account manager... .
}
}
The following code sample illustrates the sample file UntypedServer.Java, which shows the creation and registration of untyped object wrapper factories for a server. The factories are created after the VisiBroker ORB is initialized, but before any object implementations are created.
// UntypedServer.java
import com.inprise.vbroker.interceptor.*;
import org.omg.PortableServer.*;
Import com.inprise.vbroker.PortableServerExt.BindSupportPolicyValue;
import com.inprise.vbroker.PortableServerExt.BindSupportPolicyValueHelper;
import com.inprise.vbroker.PortableServerExt.BIND_SUPPORT_POLICY_TYPE;
public class UntypedServer {
public static void main(String[] args) throws Exception {
// Initialize the ORB.
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);
ChainUntypedObjectWrapperFactory Sfactory =
ChainUntypedObjectWrapperFactoryHelper.narrow
(orb.resolve_initial_references("ChainUntypedObjectWrapperFactory"));
Sfactory.add(new
UtilityObjectWrappers.TracingUntypedObjectWrapperFactory(),
Location.SERVER);
// get a reference to the root POA
POA rootPoa =
POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
// Create a BindSupport Policy that makes POA register each servant
// with osagent
org.omg.CORBA.Any any = orb.create_any();
BindSupportPolicyValueHelper.insert(any,
BindSupportPolicyValue.BY_INSTANCE);
org.omg.CORBA.Policy bsPolicy =
orb.create_policy(BIND_SUPPORT_POLICY_TYPE.value, any);
// Create policies for our testPOA
org.omg.CORBA.Policy[] policies = {
rootPoa.create_lifespan_policy
(LifespanPolicyValue.PERSISTENT), bsPolicy
};
// Create myPOA with the right policies
POA myPOA = rootPoa.create_POA( "bank_agent_poa",
rootPoa.the_POAManager(),
policies );

// Create the account manager object.
AccountManagerImpl managerServant = new AccountManagerImpl();
// Decide on the ID for the servant
byte[] managerId = "BankManager".getBytes();
// Activate the servant with the ID on myPOA
myPOA.activate_object_with_id(managerId, managerServant);
// Activate the POA manager
rootPoa.the_POAManager().activate();
System.out.println("AccountManager: BankManager is ready.");
for( int i = 0; i < args.length; i++ ) {
if( args[i].equalsIgnoreCase("-runCoLocated") ) {
if( args[i+1].equalsIgnoreCase("Client") ){
Client.doMain(orb, new String[0]);
} else if( args[i+1].equalsIgnoreCase("TypedClient") ){
TypedClient.doMain(orb, new String[0]);
}
if( args[i+1].equalsIgnoreCase("UntypedClient") ){
UntypedClient.doMain(orb, new String[0]);
}
System.exit(1);
}
}
// Wait for incoming requests
orb.run();
}
}
Removing untyped object wrappers
The ChainUntypedObjectWrapperFactory class remove method can be used to remove an untyped object wrapper factory from a client or server application. You must specify a location when removing a factory. This means that if you have added a factory with a location of Both , you can selectively remove it from the Client location, the Server location, or Both.
Note
Removing one or more object wrapper factories from a client will not affect objects of that class that are already bound by the client. Only subsequently bound objects will be affected. Removing object wrapper factories from a server will not affect object implementations that have already been created. Only subsequently created object implementations will be affected.
Typed object wrappers
When you implement a typed object wrapper for a particular class, you define the processing that is to take place when a method is invoked on a bound object. The following figure shows how an object wrapper method on the client is invoked before the client stub class method and how an object wrapper on the server-side is invoked before the server's implementation method.
Note
Your typed object wrapper implementation is not required to implement all methods offered by the object it is wrapping.
You may also mix the use of both typed and untyped object wrappers within the same client or server application. For more information, see “Combined use of untyped and typed object wrappers”.
Figure 36
Using multiple, typed object wrappers
You can implement and register more than one typed object wrapper for a particular class of object, as shown in the following figure.
On the client side, the first object wrapper registered is client_wrapper_1, so its methods will be the first to receive control. After performing its processing, the client_wrapper_1 method may pass control to the next object's method in the chain or it may return control to the client.
On the server side, the first object wrapper registered is server_wrapper_1, so its methods will be the first to receive control. After performing its processing, the server_wrapper_1 method may pass control to the next object's method in the chain or it may return control to the servant.
Figure 37
Order of invocation
The methods for a typed object wrapper that are registered for a particular class will receive all of the arguments that are normally passed to the stub method on the client side or to the skeleton on the server side. Each object wrapper method can pass control to the next wrapper method in the chain by invoking the parent class' method, super.<method_name> . If an object wrapper wishes to return control without calling the next wrapper method in the chain, it can return with the appropriate return value.
A typed object wrapper method's ability to return control to the previous method in the chain allows you to create a wrapper method that never invokes a client stub or object implementation. For example, you can create an object wrapper method that caches the results of a frequently requested operation. In this scenario, the first invocation of a method on the bound object results in an operation request being sent to the object implementation. As control flows back through the object wrapper method, the result is stored. On subsequent invocations of the same method, the object wrapper method can simply return the cached result without actually issuing the operation request to the object implementation.
If you choose to use both typed and untyped object wrappers, see “Combined use of untyped and typed object wrappers” for information on the invocation order.
Typed object wrappers with co-located client and servers
When the client and server are both packaged in the same process, the first object wrapper method to receive control will belong to the first client-side object wrapper that was installed. The following figure illustrates the invocation order.
Figure 38
Using typed object wrappers
The following are the required steps for using typed object wrappers. Each step is discussed in further detail in the following sections.
1
2
Generate the code from your IDL specification using the idl2java compiler with the -obj_wrapper option.
3
Derive your typed object wrapper class from the <interface_name>ObjectWrapper class generated by the compiler, and provide an implementation of those methods you wish to wrap.
4
Implementing typed object wrappers
You derive typed object wrappers from the <interface_name>ObjectWrapper class that is generated by the idl2java compiler.
The following code sample shows the implementation of a typed object wrapper for the Account interface in Java.
Notice that this class is derived from the AccountObjectWrapper interface and provides a simple caching implementation of the balance method, which provides these processing steps:
1
Check the _initialized flag to see if this method has been invoked before.
2
If this is the first invocation, the balance method on the next object in the chain is invoked and the result is saved to _balance, the _initialized flag is set to true, and the value is returned.
3
package BankWrappers;
public class
CachingAccountObjectWrapper extends Bank.AccountObjectWrapper {
private boolean _initialized = false;
private float _balance;
public float balance() {
System.out.println("+ CachingAccountObjectWrapper: Before calling|
balance:
");
try {
if( !_initialized ) {
_balance = super.balance();
_initialized = true;
} else {
System.out.println("+ CachingAccountObjectWrapper: Returning Cached
value");
}
return _balance;
} finally {
System.out.println("+ CachingAccountObjectWrapper: After calling
balance: ");
}
}
}
Registering typed object wrappers for a client
A typed object wrapper is registered on the client-side by invoking the addClientObjectWrapperClass method in Java that is generated for the class by the idl2java compiler. Client-side object wrappers must be registered after the ORB.init method has been called, but before any objects are bound. The following code sample shows a portion of the TypedClient.java file that creates and registers a typed object wrapper.
// TypedClient.java
import com.inprise.vbroker.interceptor.*;
Public class
TypedClient {
public static void main(String[] args) throws Exception {
// Initialize the ORB.
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);
domain (orb, args);
}
public static void domain(org.omg.CORBA.ORB orb, String[] args) {
// Add a typed object wrapper for Account objects
Bank.AccountHelper.addClientObjectWrapperClass(orb,
BankWrappers.CachingAccountObjectWrapper.class);
// Locate an account manager.
Bank.AccountManager manager =
Bank.AccountManagerHelper.bind(orb, "BankManager");
...
}
}
The VisiBroker ORB keeps track of any object wrappers that have been registered for it on the client side. When a client invokes the _bind method to bind to an object of that type, the necessary object wrappers will be created. If a client binds to more than one instance of a particular class of object, each instance will have its own set of wrappers.
Registering typed object wrappers for a server
As with a client application, a typed object wrapper is registered on the server side by invoking the addServerObjectWrapperClass method offered by the Helper class. Server side, typed object wrappers must be registered after the ORB.init method has been called, but before an object implementation services a request. The following code sample shows a portion of the TypedServer.java file that installs a typed object wrapper.
// TypedServer.java
import org.omg.PortableServer.*;
import com.inprise.vbroker.PortableServerExt.BindSupportPolicyValue;
import com.inprise.vbroker.PortableServerExt.BindSupportPolicyValueHelper;
import com.inprise.vbroker.PortableServerExt.BIND_SUPPORT_POLICY_TYPE;
public class TypedServer {
public static void main(String[] args) throws Exception {
// Initialize the ORB.
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);
// Add two typed object wrappers for AccountManager objects
Bank.AccountManagerHelper.addServerObjectWrapperClass(orb,
BankWrappers.SecureAccountManagerObjectWrapper.class);
Bank.AccountManagerHelper.addServerObjectWrapperClass(orb,
BankWrappers.CachingAccountManagerObjectWrapper.class);
// get a reference to the root POA
POA rootPoa =
POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
// Create a BindSupport Policy that makes POA register each servant
// with osagent
org.omg.CORBA.Any any = orb.create_any();
BindSupportPolicyValueHelper.insert(any,
BindSupportPolicyValue.BY_INSTANCE);
org.omg.CORBA.Policy bsPolicy =
orb.create_policy(BIND_SUPPORT_POLICY_TYPE.value, any);
// Create policies for our testPOA
org.omg.CORBA.Policy[] policies = {
rootPoa.create_lifespan_policy(LifespanPolicyValue.PERSISTENT),
bsPolicy
};
// Create myPOA with the right policies
POA myPOA = rootPoa.create_POA( "lilo", rootPoa.the_POAManager(),
policies
);
// Create the account manager object.
AccountManagerImpl managerServant = new AccountManagerImpl();
// Decide on the ID for the servant
byte[] managerId = "BankManager".getBytes();
// Activate the servant with the ID on myPOA
myPOA.activate_object_with_id(managerId, managerServant);
// Activate the POA manager
rootPoa.the_POAManager()Activate();
System.out.println("AccountManager: BankManager is ready.");

For( int i = 0; i < args.length; i++ ) {
if ( args[i].equalsIgnoreCase("-runCoLocated") ) {
if( args[i+1].equalsIgnoreCase("Client") ){
Client.doMain(orb, new String[0]);
} else if( args[i+1].equalsIgnoreCase("TypedClient") ){
TypedClient.doMain(orb, new String[0]);
}
if( args[i+1].equalsIgnoreCase("UntypedClient") ){
UntypedClient.doMain(orb, new String[0]);
}
System.exit(1);
}
}
// Wait for incoming requests
orb.run();
}
}
If a server creates more than one instance of a particular class of object, a set of wrappers will be created for each instance.
Removing typed object wrappers
The Helper class also provides methods for removing a typed object wrapper from a client or server application.
Note
Removing one or more object wrappers from a client will not affect objects of that class that are already bound by the client. Only subsequently bound objects will be affected. Removing object wrappers from a server will not affect object implementations that have already serviced requests. Only subsequently created object implementations will be affected.
Combined use of untyped and typed object wrappers
If you choose to use both typed and untyped object wrappers in your application, all pre_method methods defined for the untyped wrappers will be invoked prior to any typed object wrapper methods defined for an object. Upon return, all typed object wrapper methods defined for the object will be invoked prior to any post_method methods defined for the untyped wrappers.
The sample applications Client.java and Server.java make use of a sophisticated design that allows you to use command-line properties to specify which, if any, typed and untyped object wrappers are to be used.
Command-line arguments for typed wrappers
The typed wrappers may are enabled by specifying the following on the command-line:
1
2
Installs a typed object wrapper that caches the results of the balance method for a client or a server. If no value for sub-property is specified, both the client and server wrappers are installed.
Installs a typed object wrapper that caches the results of the open method for a client or a server. If no value for the sub-property is specified, both the client and server wrappers are installed.
Installs a typed object wrapper that detects unauthorized users passed on the open method for a client or a server. If no value for sub-property is specified, both the client and server wrappers are installed.
Initializer for typed wrappers
The typed wrappers are defined in the BankWrappers package and include a service initializer, BankWrappers/Init.java, as shown in the following code. This initializer will be invoked if you specify -Dvbroker.orb.dynamicLibs=BankWrappers.Init on the command-line when starting the client or server with vbj. Various typed object wrappers can be installed, based on the command-line properties you supply.
package BankWrappers;
import java.util.*;
import com.inprise.vbroker.orb.ORB;
import com.inprise.vbroker.properties.PropertyManager;
import com.inprise.vbroker.interceptor.*;
public class Init implements ServiceLoader {
com.inprise.vbroker.orb.ORB _orb;
public void init(final org.omg.CORBA.ORB orb) {
_orb = (ORB) orb;
PropertyManager pm = _orb.getPropertyManager();
// install my CachingAccountObjectWrapper
String val = pm.getString("CachingAccount", this.toString());
Class c = CachingAccountObjectWrapper.class;
if( !val.equals(this.toString())) {

if( val.equalsIgnoreCase("client") ) {
Bank.AccountHelper.addClientObjectWrapperClass(orb, c);
} else if( val.equalsIgnoreCase("server") ) {
Bank.AccountHelper.addServerObjectWrapperClass(orb, c);
} else {
Bank.AccountHelper.addClientObjectWrapperClass(orb, c);
Bank.AccountHelper.addServerObjectWrapperClass(orb, c);
}
}
// install my CachingAccountManagerObjectWrapper
val = pm.getString("CachingAccountManager", this.toString());
c = CachingAccountManagerObjectWrapper.class;
if( !val.equals(this.toString())) {
if( val.equalsIgnoreCase("client") ){
Bank.AccountManagerHelper.addClientObjectWrapperClass(orb, c);
} else if( val.equalsIgnoreCase("server") ) {
Bank.AccountManagerHelper.addServerObjectWrapperClass(orb, c);
} else {
Bank.AccountManagerHelper.addClientObjectWrapperClass(orb, c);
Bank.AccountManagerHelper.addServerObjectWrapperClass(orb, c);
}
}
// install my CachingAccountManagerObjectWrapper
val = pm.getString("SecureAccountManager",
this.toString());
c = SecureAccountManagerObjectWrapper.class;
if( !val.equals(this.toString())) {
if( val.equalsIgnoreCase("client") ){
Bank.AccountManagerHelper.addClientObjectWrapperClass(orb, c);
} else if( val.equalsIgnoreCase("server") ) {
Bank.AccountManagerHelper.addServerObjectWrapperClass(orb, c);
} else {
Bank.AccountManagerHelper.addClientObjectWrapperClass(orb, c);
Bank.AccountManagerHelper.addServerObjectWrapperClass(orb, c);
}
}
}
public void init_complete(org.omg.CORBA.ORB orb) {}
public void shutdown(org.omg.CORBA.ORB orb) {}
}
Command-line arguments for untyped wrappers
The untyped wrappers may are enabled by specifying the following on the command-line:
1
2
Initializers for untyped wrappers
The untyped wrappers are defined in the UtilityObjectWrappers package and include a service initializer, UtilityObjectWrappers/Init.java, shown below. This initializer will be invoked if you specify -Dvbroker.orb.dynamicLibs=UtilityObjectWrappers.Init on the command-line when starting the client or server with vbj. The Command-line properties for enabling or disabling UtilityObjectWrappers table summarizes the command-line arguments that you can use to install the various untyped object wrappers.
package UtilityObjectWrappers;
import java.util.*;
Import com.inprise.vbroker.orb.ORB;
import com.inprise.vbroker.properties.PropertyManager;
import com.inprise.vbroker.interceptor.*;
Public class
Init implements ServiceLoader {
com.inprise.vbroker.orb.ORB _orb;
public void init(final org.omg.CORBA.ORB orb) {
_orb = (ORB) orb;
PropertyManager PM= _orb.getPropertyManager();
try {
ChainUntypedObjectWrapperFactory factory =
ChainUntypedObjectWrapperFactoryHelper.narrow(
orb.resolve_initial_references("ChainUntypedObjectWrapperFactory"));
// install my Timing ObjectWrapper
String val = pm.getString("Timing", this.toString());
if( !val.equals(this.toString())) {
UntypedObjectWrapperFactory f= new
TimingUntypedObjectWrapperFactory();
if( val.equalsIgnoreCase("client") ){
factory.add(f, Location.CLIENT);
} else if( val.equalsIgnoreCase("server") ) {
factory.add(f, Location.SERVER);
} else {
factory.add(f, Location.BOTH);
}
}

// install my Tracing ObjectWrapper
val = pm.getString("Tracing", this.toString());
if( !val.equals(this.toString())) {
UntypedObjectWrapperFactory f= new TracingUntypedObjectWrapperFactory();
if( val.equalsIgnoreCase("client") ){
factory.add(f, Location.CLIENT);
} else if( val.equalsIgnoreCase("server") ) {
factory.add(f, Location.SERVER);
} else {
factory.add(f, Location.BOTH);
}
}
} catch( org.omg.CORBA.ORBPackage.InvalidName e ) {
return;
}
}
public void init_complete(org.omg.CORBA.ORB orb) {}
public void shutdown(org.omg.CORBA.ORB orb) {}
}
Executing the sample applications
Before executing the sample applications, make sure that an osagent is running on your network. For more information, see “Starting a Smart Agent (osagent)”. You can then execute the server application without any tracing or timing object wrappers by using the following command:
prompt> vbj Server
Note
The server is designed as a co-located application. It implements both the server and a client.
 
From another window, you can execute the client application without any tracing or timing object wrappers to query the balance in a user's account using the following command:
prompt> vbj Client John
You can also execute the following command if you want a default name to be used:
prompt> vbj Client
Turning on timing and tracing object wrappers
To execute the client with untyped timing and tracing object wrappers enabled, use the following command:
prompt> vbj -Dvbroker.orb.dynamicLibs=UtilityObjectWrappers.Init
-DTiming=client\
-DTracing=client Client John
To execute the server with untyped wrappers for timing and tracing enabled, use the following command:
prompt> vbj -Dvbroker.orb.dynamicLibs=UtilityObjectWrappers.Init
-DTiming=server\
-DTracing=server Server
Turning on caching and security object wrappers
To execute the client with typed wrappers for caching and security enabled, use this command:
prompt> vbj -Dvbroker.orb.dynamicLibs=BankWrappers.Init -DCachingAccount=client\
-DCachingAccountManager=client\
-DSecureAccountManager=client
Client John
To execute the server with typed wrappers for caching and security enabled, use the following command:
prompt> vbj -Dvbroker.orb.dynamicLibs=BankWrappers.Init
-DCachingAccount=server \
-DCachingAccountManager=server \
-DSecureAccountManager=server \
Server
Turning on typed and untyped wrappers
To execute the client with all typed and untyped wrappers enabled, use the following command:
prompt> vbj -DOvbroker.orb.dynamicLibs=BankWrappers.Init,
UtilityObjectWrappers.Init \
-DCachingAccount=client \
-DCachingAccountManager=client\
-DSecureAccountManager=client \
-DTiming=client \
-DTracing=client \
Client John
To execute the server with all typed and untyped wrappers enabled, use the following command:
prompt> vbj -Dvbroker.orb.dynamicLibs=BankWrappers.Init,
UtilityObjectWrappers.Init \
-DCachingAccount=server \
-DCachingAccountManager=server\
-DSecureAccountManager=server \
-DTiming=server \
-DTracing=server \
Server
Executing a Co-located client and server
The following command will execute a Co-located server and client with all typed wrappers enabled, the untyped wrapper enabled for just the client, and the untyped tracing wrapper for just the server:
prompt> vbj -Dvbroker.orb.dynamicLibs=BankWrappers.Init,
UtilityObjectWrappers.Init \
-DCachingAccount -DSecureAccountManager \
-DTiming=client -DTracing=server \
Server -runCoLocated Client
Specifying the -runCoLocated command-line option allows you to execute the client and server within the same process.
Executes the Server.java and the Client.java within the same process.
Executes the Server.java and the TypedClient.java within the same process.
Executes the Server.java and the UntypedClient.java within the same process.