Intersystems Caché with Java Gateway - Pass parameter as java.io.FileInputStream

若如初见. 提交于 2019-12-25 14:10:47

问题


In my project I'm using a integration of Intersystems Caché with Java by a Java Gateway, it's basically maps JARs and create a class proxies in Caché to access Java classes into the JAR.

A class in Java has a parameter of type FileInputStream , my question is how I should send this parameter Caché proxie ? What type of data in Caché represent the FileInputStream in Java?

Regards,

Lucas Boeing Scarduelli


回答1:


When you create proxy for that java, should be created cache-class for FileInputStream too.

simple java class, with FileInputStream as a type for an argument in function

package org.daimor;

import java.io.FileInputStream;
import java.io.IOException;

public class test {

    public long sizeStream(FileInputStream stream)
    {
        try {
            return stream.getChannel().size();
        } catch (IOException ex)
        {
            return -1;
        }
    }
}

then I created projection for this jar file in Caché Studio. And wrote a code

Set gateway = ##class(%Net.Remote.Gateway).%New()
Do gateway.%Connect("127.0.0.1", 55555)

Set file = ##class(java.io.FileInputStream).%New(gateway, "c:\test.txt")
Set javaObj=##class(org.daimor.test).%New(gateway)
Set size=javaObj.sizeStream(file)

so, it works well.



来源:https://stackoverflow.com/questions/32789169/intersystems-cach%c3%a9-with-java-gateway-pass-parameter-as-java-io-fileinputstream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!