I want to share some information between two classes (A and B), which are running in different java programs. Instead of writing a whole communication protocol I want to use
If you pass B as an argument to a method in A and then use that reference to call a method on B I am fairly certain that a reverse connection is established, and I am fairly certain that RMI Registry is created for the JVM where B resides. At some point this got us into a bit of trouble with particularly strict firewall rules. Our code looked a little something like
Web Server
public int uploadFile(FileItem fileItem){
return ApplicationClassLoader
.get(DocumentManager.class)
.attachFile(new RemoteInputStreamImpl(fileItem.getInputStream());
)
}
Application Server
public int attachFile(RemoteInputStream in){
...
byte[] buffer;
while((buffer = in.read(1024)) != null) // Would return null to indicate EOF
// Do some stuff
return documentId;
}