The primary
reference that I used is COM and DCOM;
Microsoft's Vision for Distributed Objects by
Roger Sessions. The second resource
was the Microsoft Developer Studio Help files.
In order for our ActiveX controls to invoke
methods on our Java server, we need a common
method of communication. The means for this
communication is COM - which is the Microsoft
component model. COM is a shell that one wraps around components,
and that defines how communication is passed between clients
and component objects. In effect, we will put a
COM wrapper around the Java code we write which will allow non
Java code such as Microsoft Visual Basic and ActiveX to interact
with the Java code.
The following is the process which is used to convert a Java class
to a COM component:
- Write the Java code so that it can be defined by the IDL (Interface
Definition Language). Any data that is to pass between the Java Code and
the COM interface must be compatible. For the type equivalents between
Java and COM, see COM/Java IDL.
Sample Java Code
- Create the Type Library. An IDL file is intended to be read by humans.
The Type Library is actually used by the computer and software such as
Visual Basic. The tool used to generate the Type Library from an IDL
File is the midl compiler.
IDL Sample
- Register the COM classes. For the Java/COM classes to be used, they
must be registered in the system registry. This is where COM will look
when trying to find these classes. The tool used for registering classes
is javareg.
- Register the COM classes. For the Java/COM classes to be used, they
must be registered in the system registry. This is where COM will look
when trying to find these classes. The tool used for registering classes
is javareg.
- This sounds rather complicated and it is! Fortunately, Microsoft seems to
be accepting Java as a good idea. The latest version of MS J++ does the
above steps automatically. One simply indicates that a class is to be a
COM component and the compiler automatically generates the Type Library and
registers the COM object in the system registry. Unfortunately, the latest
version of J++ is not yet commercial - basically in BETA testing - and also
you must purchase the software! Unless you are lucky enough to work for
a software company with a subscription to the Microsoft Developers Library! It may be
possible to obtain the individual tools mentioned above in the Microsoft Java
Software Development Kit which can be downloaded for free. See our reference links
for a link to the MS site.
- And finally, the latest version of MS J++ will also automatically
create the dll which can be used by the Microsoft Transaction Server.
|