问题
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