IMarshal Sample – MBV Code

These classes are located in \Samples\Com\IMarshal\Sample\Marshal.

Note   To use this sample, it is recommended that you have Microsoft® Visual C++® version 5.0 or higher installed.

Description
Key Project Files
Technologies Demonstrated

Description

These classes are generic utilities for marshaling any Java or Java/COM object, either from a class factory or when used as parameters in COM interface methods. As marshaling by value of Java objects essentially involves serializing the Java object and reconstructing it on the client side, much of the work required for marshaling by value can be delegated to the java.io.ObjectInputStream and java.io.ObjectOutputStream classes. 

A generic marshal-by-value mechanism is possible for two reasons:

The MarshalLib class contains a registerProxy method that registers the generic proxy in the current process by calling CoRegisterClassObject and CoRegisterPSClsid. There is no need to add any registry settings for the proxies used to marshal COM objects by value. The ByValue class implements IMarshal and acts both as the surrogate for marshaling the Java and Java/COM objects, and as the proxy that reconstructs them.

Key Project Files

MarshalLib.java

The marshaling utility class. This class contains the registerProxy method that adds a class factory for the proxy used to unmarshal Java and Java/COM marshal-by-value objects.

ByValue.java

A Java/COM object that implements IMarshal.java and serves as the surrogate for marshaling Java and Java/COM objects, as well as the proxy for reconstructing them.

Technologies Demonstrated

J/Direct

COM

These classes show how to:

© 1999 Microsoft Corporation. All rights reserved. Terms of use.