Supporting Tools for jCOM

The jCOM bi-directional software comes with tools that developers can use to generate the intermediate software components the jCOM bridge requires to communicate and perform the translation. Take a look at these tools, which will help you understand how the software pieces enable the jCOM bridge to perform bi-directional communication with COM components.

com2java

The com2java tool, shown in Figure 20.1, reads information from a type library of COM classes or interfaces. After interpreting the information from the type library, the com2java utility generates Java classes that contain the necessary functionality to enable Java applications and components deployed in WebLogic Server to access the COM components as if they were Java classes. The generated Java classes actually act as a proxy for COM components. The type libraries used by the com2java tool are typically generated using either Visual C++ or Visual Basic, the two language tools used to develop COM components.

Figure 20.1. Screen shot of the com2java tool.

graphics/20fig01.jpg

The translation functionality provided by the com2java tool is not restricted to server-side COM components. Visual components such as ActiveX controls can also be accessed using the com2java tool.

The com2java tool generates two kinds of files for a COM interface, defined in the type library file:

  • Interface file This a Java file containing the Java interface equivalent to the COM interface defined in the type library. For example, for a COM component with the interface name ISAMSInterface, the Java interface corresponding to ISAMSInterface is generated in a file named ISAMSInterface.java.

  • Proxy file Apart from the interface file, the tool also generates a Java class that contains the actual functionality to enable access to the COM component. This Java class is stored in a file with the same name as the interface (generated in the above step) but with the additional "Proxy" suffix in the name. For example, for the COM component's interface ISAMSInterface, the ISAMSInterfaceProxy.java file is generated with the actual COM object accessing functionality.

The com2java tool supports the processing of the following types in the type library:

  • COM interfaces The com2java tool supports the processing of vtable (early binding) and IDispatch (late binding) interfaces. As seen earlier, for the COM interfaces, the tool generates a Java interface file and a Java proxy class that implements the interface.

  • COM classes A Java class that acts as a proxy to the actual COM class is generated by the com2java tool when it processes a COM class in the type library.

  • Enumerations Enumerations in a type library get mapped to a Java interface with constants for each element in the enumeration.

The com2java tool is located in the WebLogic Server's bin directory. There is a non-GUI command-line version also available named com2javacmd.

java2com

COM clients, such as Visual Basic clients, may want to access Java objects or EJB components deployed in WebLogic Server. The java2com tool helps in generating an IDL file that can be used by the COM component to generate the client-side classes needed to access Java objects and components deployed in WebLogic Server.

The java2com tool works on the Java classes to analyze their structure using reflection technique and generates an IDL file and Java wrapper classes, as you'll learn next.

IDL File for the COM Component

The java2com tool generates a COM interface for each Java interface that it encounters during processing. For example, for an interface named com.sams.learnweblogic7.MySAMSHomeInterface, the tool generates a COM interface named ComSamsLearnweblogic7MySAMSHomeInterface (the name can be overridden with any name that you specify in the generation process).

For public Java classes, as well, the tool generates COM interfaces that correspond to the definition of each public Java class. As an example, for the public bean implementation class of an EJB named com.sams.learnweblogic7.MySAMSBeanImpl, the COM interface generated will be IComSamsLearnweblogic7MyBeanImpl (the name can be similarly changed).

All these interfaces are consolidated and written in the final generated file, for example, mysams.idl. The structure of the IDL file is for use only by COM components. The mysams.idl file should then be compiled using the tools provided with Visual C++ to generate the required type library file. Finally, you would need to register this type library file along with the COM client application by using the regtlb tool. You will learn about using regtlb later in this section.

Java Wrapper Classes

The Java wrapper classes are specific to the Java object that will be accessed by a COM component. These wrapper classes are required by the jCOM bridge software to perform the actual marshalling, that is, translation from a COM component request to an RMI IIOP request used internally by Java objects and EJB components deployed in WebLogic Server.

The java2com batch file is located in the WebLogic Server's bin directory. The command used to invoke the tool is

 java com.bea.jcom.Main  

regjvm

The regjvm tool that is provided as part of the jCOM bridge software is used to register the information of the Java Virtual Machine (JVM) of the WebLogic Server when you need to establish communication between a COM client and Java objects deployed on WebLogic Server. The regjvm GUI tool is used to define the mode of communication. Normally, you would select the DCOM Pure Java mode of communication and supply the WebLogic Server host name and port number. This information should be saved after providing a logical name for the JVM id. This logical name, or JVM id, will be used by the regtlb utility to register a type library in the Windows registry, along with the JVM id. A command-line version called regjvmcmd is also available.

The regjvm (or regjvmcmd) file is located in the WebLogic Server's bin directory. The command used to invoke the tool is

 regjvm  

or

 regjvmcmd  

regtlb

The final utility that you will be looking at is the regtlb utility. The regtlb utility is the final step involved when establishing a static, or early binding, communication between a COM client and Java objects deployed on WebLogic Server. The regtlb utility is used to register the type library generated after compiling a COM-compliant IDL file. The regtlb takes the type library and the JVM id (generated using the regjvm or regjvmcmd utilities) and registers it with the COM client.

The regtlb batch file is located in the WebLogic Server's bin directory. The command used to invoke the tool is

 regtlb  

Now you will look at how the communication between WebLogic Server and COM takes place using jCOM bridge software and the tools that you learned about earlier.



Sams Teach Yourself BEA WebLogic Server 7. 0 in 21 Days
Sams Teach Yourself BEA WebLogic Server 7.0 in 21 Days
ISBN: 0672324334
EAN: 2147483647
Year: 2002
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net