Sample Interceptor Example
This directory contains the sample interceptor example. The sample
interceptor example adds basic tracing to the Bank
example through the interceptor API. 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 factories for the ClientInterceptor and ServerInterceptor.
- Add interceptor factories (or interceptors themselves) to the ORB's
chaining interceptor
Directory Contents
Used from the Bank sample
- Bank.idl
IDL interface for the 'Bank' object.
- Server.java
Server. Creates an instance of the Bank 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
open() to open a bank account. It then invokes the balance()
on the account object reference obtained to query the balance.
Running the sample interceptor example
To run the example, read the instructions
at the interceptor directory. You will have to switch your current working directory
to the interceptor directory before running the interceptor example.
Here is the sample output from the server
Installing Sample Interceptors
BindINT: bind
BindINT: exception_occurred
AccountManager object is ready.
ServINT: locate
ServINT: locate_forwarded
ServINT: receive_request
ServINT: prepare_reply
ServINT: send_reply
ServINT: request_completed
ServINT: shutdown
Here is the sample output from the client
Installing Sample Interceptors
BindINT: bind
BindINT: bind_succeeded
ClntINT: prepare_request
ClntINT: send_request
ClntINT: send_request_succeeded
ClntINT: receive_reply
The balance in Jack B. Quick's account is $6.27.
Return to the Interceptor Examples Page.