BEA Logo BEA WebLogic Server Release 6.1

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

  |  

  WebLogic Server Doc Home   |     WebLogic jCOM User Guide   |   Previous Topic   |   Next Topic   |   Contents   |   View as PDF

WebLogic jCOM Tools

 

The following sections describe the most commonly used WebLogic jCOM tools:

 


The regjvm GUI Tool

WebLogic jCOM allows languages supporting COM to access Java objects as though they were COM objects.

To do this you need to register (on the COM client machine) a reference to the JVM in which the Java objects run. The regjvm tool enables you to create and manage all the JVM references on a machine.

Note: The regjvm tool does not overwrite old entries when new entries with identical names are entered. This means that if you ever need to change the hostname or port of the machine with which you wish to communicate, you have to unregister the old entry. You can do this using the command line tool regjvmcmd.exe, or by using the GUI tool regjvm.exe (both can be found in the jCOM\bin directory).

JVM modes

A JVM may be accessed from COM clients using one of three different modes:

DCOM mode

DCOM mode does not require any native code on the Java server side, which means your Java code may be located on a Unix machine or any machine with a Java Virtual Machine installed. When you register the JVM on the Windows client machine you define the name of the server host machine (it may be localhost for local components) and a port number.


 
 

The Java code in the JVM must call com.bea.jcom.Jvm.register("<jvm id>"), where <jvm id> is the id of the JVM as defined in regjvm. The JVM must also be started with the JCOM_DCOM_PORT property set to the port defined in regjvm tool for the specified <jvm id>.

Native mode (out of process)

Native mode currently only works on the local machine. Other than the JVM name no additional parameters are necessary.


 

The JVM must call com.bea.jcom.Jvm.register("<jvm id>"), where <jvm id> is the id of the JVM as defined in regjvm. The JVM must also be started with the JCOM_NATIVE_MODE property set.

Native mode in process

Using native mode in process allows the user to actually load the Java object into the same process as the COM client. Both objects must of course be located on the same machine.


 

The JVM need not call com.bea.jcom.Jvm.register() or be started as an extra process to the client.

The User Interface of the regjvm GUI Tool

When you run the regjvm tool, a dialog is displayed. The dialog is split into two parts:

DCOM Mode Options for the regjvm GUI Tool

Standard Options


 

Advanced Options


 

Native Mode Options for the regjvm GUI Tool

Standard Options


 

There are no standard options for this mode.

Advanced Options


 

Native Mode in Process Options for the regjvm GUI Tool

Standard Options


 

Advanced Options


 
 

 


The regjvmcmd Command Line Tool

regjvmcmd is the command line version of the GUI tool, regjvm, discussed above. To get a summary of its parameters, run regjvmcmd without parameters.

In its simplest form, you specify:

If you no longer need to have the JVM registered, or if you wish to change its registration, you must first un-register it using regjvmcmd /unregister JvmId

 


The java2com Tool

The java2com tool analyzes Java classes (using Java's reflection mechanism), and outputs:

The IDL file has to be compiled using Microsoft's MIDL tool.

To generate the IDL file and the wrappers, start the java2com tool using the command:

java com.bea.java2com.Main 

You can run this tool on any platform. Make sure that the WebLogic jCOM runtime jCOM.jar is in your CLASSPATH environment variable.

The java2com tool displays the following dialog box:


 

The dialog box has the following fields (any changes to the configuration are automatically saved when you exit the dialog box):

  1. Java Classes & Interfaces

    These are the 'root' Java classes and interfaces that you want java2com to analyze. They must be accessible in your CLASSPATH. WebLogic jCOM analyzes these classes, and generates COM IDL definitions and Java DCOM marshalling code which can be used to access the Java class from COM. It then performs the same analysis on any classes or interfaces used in parameters or fields in that class, recursively, until all Java classes and interfaces accessible in this manner have been analyzed.

    Separate the names with spaces. Click on the ... button to display a dialog that lists the classes and lets you add/remove from the list.

  2. Name of Generated IDL File

    This is the name of the COM Interface Definition Language (IDL) file which will be generated. If you specify myjvm, then myjvm.idl will be generated. This name is also used for the name of the type library generated when you compile myjvm.idl using Microsoft's MIDL compiler.

  3. Output Directory

    The directory to which java2com should output the files it generates. The default is the current directory (".").

  4. Dump Analysis

    Displays the classes that the java2com discovers, as it discovers them.

  5. Save Settings/Load Settings

    Click on the Save Settings button to save the current java2com settings.

    When java2com starts, it checks to see if there is a java2com.ser setting file in the current directory. If present, it loads the settings from that file automatically.

  6. Names...

    Clicking the Names button displays the following dialog box:

    When '*' is selected from the class/interfaces names drop-down list, a text box is displayed into which you can type the name of a member (field or class) name. You may specify a corresponding COM name to be used whenever that member name is encountered in any class or interface being generated. If you leave the name blank then that Java member will not have a corresponding member generated in any COM interface.

    When a specific COM class name or interface is selected from the class/interfaces names drop-down list, the set of members in that class or interface is listed below it. You may specify a COM name to be used, and by clicking on Add this Class Name map you map the selected class/interface to the specified COM name. By clicking on Add this Member Name map you may map the selected member to the specified COM name.

  7. Generate button

    Generates the wrappers and IDL file.

For each public Java interface that java2com discovers, it creates a corresponding COM interface definition. If the Java interface name were: com.bea.finance.Bankable, then the generated COM interface would be named ComBeaFinanceBankable, unless you specify a different name using the 'Names ...' dialog.

For each public Java class that java2com discovers, it creates a corresponding COM interface definition. If the Java class name were: com.bea.finance.Account, then the generated COM interface would be named IComBeaFinanceAccount, unless you specify a different name using the 'Names ...' dialog. In addition if the Java class has a public default constructor, then 'java2com' generates a COM class ComBeaFinanceAccount, unless you specify a different name using the 'Names ...' dialog.

If a Java class can generate Java events, then the generated COM class will have source interfaces (COM events) corresponding to the events supported by the Java class.

Compile the generated IDL file using Microsoft's MIDL tool. This ships with Visual C++, and can be downloaded from the MS web site. The command

midl prodServ.idl 

will produce a type library called prodServ.tlb, which can be registered as described in the following section.

 


The regtlb Tool

WebLogic jCOM's regtlb tool registers a type library on a COM Windows client that wishes to access Java objects using COM's early binding mechanism. regtlb takes two parameters. The first is the name of the type library file to be registered. The second is the ID of the JVM in which the COM classes described in the type library are to be found:


 

If the type library was generated from an IDL file that was in turn generated by the WebLogic jCOM java2com tool, then the regtlb command can automatically determine the Java class name corresponding to each COM class in the type library (the COM class descriptions in the type library are of the form:

Java class java.util.Observable (via jCOM))

If the type library was not generated from a java2com generated IDL file, you will be prompted to give the name of the Java class which is to be instantiated for each COM class:


 

This means that when someone attempts to create an instance of Atldll.Apple, WebLogic jCOM will instantiate com.bea.MyAppleClass in the JVM MyJvm. The MyAppleClass class should implement the Java interfaces generated by WebLogic jCOM's java2com tool from atldll.tlb that are implemented by the COM class Atldll.Apple.


 

 

back to top previous page