The Timer Interceptor example
This directory contains the timer interceptor example. The timer
interceptor example demonstrates how to use Closure class to pass data between interceptors.
The code from the simple Bank example
discussed earlier has not been modified, illustrating how the code for the
interceptors can easily be added to existing applications.
This example illustrates how to:
-
Implement a simple ClientInterceptor, ServerInterceptor, and BindInterceptor
-
Implement a factories for the ClientInterceptor and ServerInterceptor.
-
Use the initializers to install the interceptors when VisiBroker is
initialized
-
Add interceptor factories (or interceptors themselves) to the ORB's chaining
interceptor
The timer example shows how to use the org.omg.CORBA.Closure class to pass data
between interceptor points.
Directory Contents
-
Init.java
Sample code for standard initialization for a interceptor package.
It shows how to install interceptors and interceptor factories
.
-
TimerInterceptor.java
Super class for all the interceptors in this sample. It has some common code shared
by the sample interceptors.
-
TimerClientInterceptor.java
A sample client interceptor, which intercepts communication at client side.
It also shows how to use Closure to pass information between interceptor calls.
-
TimerServerinterceptor.java
A sample client interceptor factory, which creates client interceptors.
It also shows how to use Closure to pass information between interceptor calls.
-
TimerClientInterceptorFactory.java
A sample client interceptor factory, which creates client interceptors.
-
TimerServerInterceptorFactory.java
A sample server interceptor factory, which creates server interceptors.
-
TimerData.java
Used by interceptors to pass time information between interceptor calls.
-
TwoTimerData.java
Used by interceptors to pass multiple time information between interceptor calls.
-
Bank.idl
IDL interface for the 'Bank' object.
-
Server.java
Bank Server. Creates an instance of the AccountManager and calls org.omg.CORBA.BOA.impl_is_ready() to make this object available to client programs. The Bank server implementation implements two methods: open, which opens a bank account, and balance, which returns the balance in a person's account whose name is provided as input. A random number is generated and returned as the balance.
-
Client.java
This is the Bank Client. It binds to an AccountManager object and invokes the open() to open a bank account. It then invokes the balance() on the account object reference obtained to query the balance.
Building this example
To build this example, cd .. to the interceptor directory (one level above the current directory) and type make all(vbmake on Windows). You will have to change your current working directory to the interceptor directory to run the timer example.
Compilation Errors and Warnings
You may see the following kind of compilation errors when you compile this example using either JDK1.0.2 or JDK1.1.1:
prompt>javac timer/Init.java
./timer/TimerBindInterceptor.java:5: Package
com.visigenic.vbroker.interceptor not found in import.
import com.visigenic.vbroker.interceptor.*;
^
The above error occurs because the javac compiler in JDK1.0.2 and JDK1.1.1 cannot locate packages imported from JAR files. The solution to this problem is to either:
- Unjar the vbj30.jar file found in the VisiBroker for Java 3.0 installation/lib directory using the following command:
prompt>jar xvf vbj30.jar
- Modify the example: delete the import statment and explicitly prefix each occurrence of classes from the imported package with the complete package name.
- Upgrade to JDK1.1.2 or higher
Running the timer interceptor example
To run the example, read the instructions at the interceptor directory.
Here is the sample output from the server
Installing Timer Interceptors
AccountManager object is ready.
locate: 40 ms
balance: (process time) - 70 ms
balance: (prepare response) - 0 ms
balance: (send time) - 0 ms
balance: (total call) - 70 ms
Here is the sample output from the client
Installing Timer Interceptors
bind: 2 s, 503 ms
balance: (prepare time) - 70 ms
balance: (send time) - 0 ms
balance: (receive time) - 390 ms
balance: (total call) - 460 ms
The balance in Jack B. Quick's account is $94.89.
Return to the Interceptor Examples Page.