Java .jar access a factory method with no constructor?


#1

I’m loading some jars, running into a factory class where there is no constructor.

<CFSET ModbusMasterFactory = createObject('java','com.intelligt.modbus.jlibmodbus.master.ModbusMasterFactory',['jlibmodbus-1.2.9.2.jar','jssc-2.8.0.jar'])>

ModbusMasterFactory class looks like this:

class com.intelligt.modbus.jlibmodbus.master.ModbusMasterFactory
methods:
createModbusMasterRTU(com.intelligt.modbus.jlibmodbus.serial.SerialParameters)
createModbusMasterASCII(com.intelligt.modbus.jlibmodbus.serial.SerialParameters)
createModbusMasterTCP(com.intelligt.modbus.jlibmodbus.tcp.TcpParameters)

So I read the docs on classes with no constructor and tried this:

 <CFSET ModbusMasterFactory = createObject('java','com.intelligt.modbus.jlibmodbus.master.ModbusMasterFactory',['jlibmodbus-1.2.9.2.jar','jssc-2.8.0.jar']).createModbusMasterRTU(SerialParameters)>

And I get this error:

No matching Method for createModbusMasterRTU(com.intelligt.modbus.jlibmodbus.serial.SerialParameters) found for com.intelligt.modbus.jlibmodbus.master.ModbusMasterFactory

Any help is appreciated.

Java Class:

package com.intelligt.modbus.jlibmodbus.master;

import com.intelligt.modbus.jlibmodbus.serial.SerialParameters;
import com.intelligt.modbus.jlibmodbus.serial.SerialPortException;
import com.intelligt.modbus.jlibmodbus.tcp.TcpParameters;

// Referenced classes of package com.intelligt.modbus.jlibmodbus.master:
//            ModbusMasterRTU, ModbusMasterASCII, ModbusMasterTCP, ModbusMaster

public final class ModbusMasterFactory {

    private ModbusMasterFactory() {
    }

    public static ModbusMaster createModbusMasterRTU(SerialParameters sp)
        throws SerialPortException {
        return new ModbusMasterRTU(sp);
    }

    public static ModbusMaster createModbusMasterASCII(SerialParameters sp)
        throws SerialPortException {
        return new ModbusMasterASCII(sp);
    }

    public static ModbusMaster createModbusMasterTCP(TcpParameters tcpParameters) {
        return new ModbusMasterTCP(tcpParameters);
    }
}