[Search for users]
[Overall Top Noters]
[List of all Conferences]
[Download this site]
Title: | ObjectBroker Desktop Connection |
|
Moderator: | RECV::STORM |
|
Created: | Mon Jan 06 1997 |
Last Modified: | Thu Jun 05 1997 |
Last Successful Update: | Fri Jun 06 1997 |
Number of topics: | 40 |
Total number of notes: | 125 |
35.0. "A Java client example" by SEND::KONKUS () Wed Apr 23 1997 13:14
We've created a simple example Java client application which interacts with
a bridged CORBA server. It's available at the following locations:
via DECnet at:
send::obb$kits:[dtc.examples]javaexample.zip
or anonymous FTP at:
ftp://objwrk.zko.dec.com/ObjectBroker/kits/dtc/examples/javaexample.zip
(Thanks go to Jay Zammit for providing the server!)
Here is the ReadMe.txt file from javaexample.zip. Don't forget the -d
option when unzipping!
CONTENTS
This directory tree contains the following examples:
JaysBank\BankServer\ An ObjectBroker CORBA server that implements
a simple bank with accounts and transactions.
Written in C++.
JaysBank\BankComC\ A C++ COM client for the bank server. This
example demonstrates using the COM bindings
that were generated when the Bank server was
exposed to the desktop.
JaysBank\JavaApp\ A Java client for the CORBA bank server. This
application demonstrates using the COM bindings
from a Java app.
The following sections describe the steps necessary to run these examples
on your system.
BUILDING THE BANK SERVER
The BankServer is pre-built and ready to use. BankServer.mak, a Visual C++
make file, is provided for your convenience if you want to extend or
enhance this example.
CREATING DESKTOP BINDINGS FOR THE BANK SERVER
Before COM, Automation, or Java clients can access the Bank Server, it must
be exposed to the desktop. To create bindings for ObjectBroker objects do
the following:
1. In the Microsoft Explorer, locate the BankServer\Bank.idl file
2. Click the right mouse button on the Bank.idl file. A pop-up menu
appears.
3. Choose Generate Code. The Code Generation window appears.
4. Select the Desktop View page. The directory location and the name of the
OMG IDL file appear in the Interface field on the Desktop View page.
5. Check both the Generate Automation Interface and the Generate Custom
Interface options.
6. Specify an output format for the binding information. Check the Object
Description Language (ODL) file option. The Type Library option is
automatically checked.
7. Enter an output directory location for the ODL file and a location for
its associated type library. (In order for the Java client application
to use the COM view of the ObjectBroker object, the type library needs
to be located in your system's path. OBROKER\BIN is a good place.)
8. Click Generate.
STARTING THE BANK SERVER
Run \JaysBank\BankServer\Debug\BankServer.exe from a command line.
BUILDING THE COM CLIENT
The BankComC application is pre-built (using COM bindings that we generated
on our machine) and is ready to use. BankComC.mak, a Visual C++ make file,
is provided for your convenience if you want to recompile this client using
the actual bindings that you generated or if you want extend or enhance
this example.
RUNNING THE COM CLIENT
The BankComC application can be started from a command line.
CREATING JAVA BINDINGS FOR THE BANK SERVER
As this example was written, Java applications cannot directly instanciate
objects using monikers or class ID information found in the Windows
registry. The supported mechanism involves adding a coclass {} phrase to a
type library with the appropriate class ID values. The easiest way to do
this with generated .odl and .tlb files is to create a new .odl that wraps
the generated file and build a new .tlb. See
\BankServer\CdBank_CheckingAccount.odl for an example. Note that there are
two UUID values in this wrapper .odl file. The Type Library UUID must be
unique. The class UUID must correspond to the OLE view ClassId. (Look it
up from the Windows registry under the CORBA.OLE.<class name> key.)
The CdBank_CheckingAccount.odl and .tlb files in the \BankServer\ directory
should work as provided. However, if you want to make any changes or extend
this example, you will need to edit the .odl file and create a new type
library using the mktyplib utility.
Copy the CdBank_CheckingAccount.tlb file to your path (OBROKER\BIN is
nice), and register it using the regtlib utility like this:
>regtlib CdBank_CheckingAccount.tlb
This creates all the appropriate Windows registry entries so that the Java
type library wizard can locate the type libraries.
Now we're ready to actually create the Java class wrappers for these COM
classes.
If you're running J++ version 1.0, do the following commands from a command
window:
>JavaTLB DiBank_Transaction.tlb
>JavaTLB DiBank_TransactionFactory.tlb
>JavaTLB DiBank_ServerManager.tlb
>JavaTLB DiBank_ServerManagerFactory.tlb
>JavaTLB DiBank_SavingsAccount.tlb
>JavaTLB DiBank_SavingsAccountFactory.tlb
>JavaTLB DiBank_CheckingAccount.tlb
>JavaTLB DiBank_CheckingAccountFactory.tlb
>JavaTLB CdBank_CheckingAccount.tlb
For each type library, the JavaTLB tool creates a directory below the
trusted library directory with the generated classes and interfaces. Once
you have run the JavaTLB tool, you do not need to run JavaTLB again unless
the type library changes.
If you're running J++ version 1.1, select the Java Type Library Wizard from
the J++ Tools menu, and select the following:
[x] CdBank_CheckingAccount
[x] DiBank_CheckingAccount
[x] DiBank_CheckingAccountFactory
[x] DiBank_SavingsAccount
[x] DiBank_SavingsAccountFactory
[x] DiBank_ServerManager
[x] DiBank_ServerManagerFactory
[x] DiBank_Transaction
[x] DiBank_TransactionFactory
The Type Library Wizard creates the appropriate trusted library directories
and populates them with the generated java wrapper classes and interfaces.
BUILDING THE JAVA APP
Open JaysBank\JavaApp\BankJavaApp (JavaAppV10 for J++ v1.0) as a workspace,
select Build\Rebuild All, and execute the resulting application.
PROBLEMS?
This is a new example, and anything could happen. If you need help, please
feel free to contact us via the SEND::ObjectBroker_DTC notes conference, or
via mail at [email protected]
T.R | Title | User | Personal Name | Date | Lines |
---|
35.1 | | SEND::KONKUS | | Wed Apr 23 1997 13:22 | 5 |
| We've done some additional work in this area, including accessing a Java
server from a CORBA client application through the bridge. If you are
interested Java integration and want to extend this work, please let us
know. We'd be happy to share our experiences.
|