HOME  |  ORDER SOFTWARE | OTHER DOWNLOADS | COM BRIDGE DOCUMENTATION


ComBridge
Java Client
This is BETA software, it is a partial implementation of the full native C++ version of ComBridge

Introduction

ComBridge allows Windows COM/DCOM/COM+ objects to be called from Unix operating systems. The ComBridge system is fully documented here. This Java Client is a BETA version and is subset of the full C++ ComBridge system.
 
Java ComBrige Client - BETA Version - tar format Download
Java ComBrige Client - BETA Version - SXAzip format Download

The Java Client includes a set of ComBridge classes and a sample program, Proj_1.java,  that uses them. The main difference between the C++ version and the Java version is that only simple data types can be passed an received, i.e. the following COM types are not (yet) supported in the Java Client...

VARIANT, SAFEARRAY, DATE, CURRENCY, LPDISPATCH

A further difference is the implementation of pointers. COM Object frequently return variables to the caller by reference, this is not possible in Java. The way ComBridge gets round this is to create 'ptr' classes which are passed into ComBridge whenever a pointer is required, the 'ptr' classes just have one member, which is the variable being 'pointer to', in this way you can pass variables into java methods and have the method change the value of the variable.

A further difference is, whenever a COM object expects a long integer, you should pass in a Java Integer (not a Java long).


Java ComBridge Classes

public class ComBridge
public boolean Connect(String host, int port)
public boolean Disconnect()
public class IDispatchBridge
public IDispatchBridge(ComBridge connection)
public int Create(String clsID)
public int Release()
public int PrepareMethod(int dispID)
public int PushArg(int value)
public int PushArg(short value)
public int PushArg(double value)
public int PushArg(String value)
public int PushArg(intptr value)
public int PushArg(shortptr value)
public int PushArg(doubleptr value)
public int PushArg(strptr value)
public int PushArg(int value)
public int PushArg(short value)
public int PushArg(double value)
public int Invoke()
public int Invoke(intptr  returnValue)
public int Invoke(shortptr  returnValue)
public int Invoke(doubleptr  returnValue)
public int Invoke(strptr  returnValue)
public int GetProperty(intptr  returnValue)
public int GetProperty(shortptr  returnValue)
public int GetProperty(doubleptr  returnValue)
public int GetProperty(strptr  returnValue)
public class doubleptr
public double m_d;
public class intptr
public int m_l;
public class shortptr
public short m_i;
public class shortptr
public short m_i;

Example Code


This code-extract can be found in Proj_1.java on the downloadable archives. The code calls methods on the standard ComBridge test object distributed with the ComBridge server.

The following code calls a method that adds 2 (32bit)  integeres togeather

// COM ODL Method description: [id(1)] long Add2(long arg1, long arg2);

ComBridge cli = new ComBridge();

if( !cli.Connect("win32Host", -1) )
{
    System.out.println("faild to connect");
    if( cli.GetErrno() == 1 )
        System.out.println("This PC does not have permission to access the Server");
    if( cli.GetErrno() == 99 )
        System.out.println("This Server is not correctly licensed");
    return;
}

IDispatchBridge disp = new IDispatchBridge(cli);

System.out.println("create test object....");

int hr = disp.Create("ComBridgeTest");
if( hr != 0 )
{
    System.out.println("Create Error " + hr);
    return;
}

System.out.println("created ... about to call Add2 method...");

hr = disp.PrepareMethod(1);
if( hr != 0 )
{
    System.out.println("PrepareMethod(1) ERROR " + hr);
    return;
}

hr = disp.PushArg(10);
if( hr != 0 )
{
    System.out.println("PushArg(10) ERROR <ComBridgeTest> " + hr);
    return;
}

hr = disp.PushArg(32L);
if( hr != 0 )
{
    System.out.println("PushArg(32) ERROR <ComBridgeTest> " + hr);
    return;
}

intptr l = new intptr();
hr = disp.Invoke(l);
if( hr != 0 )
{
    System.out.println("Invoke(1) ERROR <ComBridgeTest> " + hr);
    return;
}

System.out.println("Add2 RETURN %d <<expect 42>>" + l.m_l);


Home | FixGateway | AFI/J | SimpleGrid | SBpayroll | SXAzip | InstallScript | DiskUsage/DiskClean | Virtual Desktop Manager | ComBridge | Demos | Purchase