...
Code Block | ||
---|---|---|
| ||
@Override public void processInOpen() throws IOException { if (!preload) { final File file = new File(filename); try { in = new FileInputStream(file); fireOnConnect(); } catch (Exception e) { fireOnDisconnect(); throw e; } } else { fis = new FileInputStream(filename); FileChannel channel = fis.getChannel(); long size = channel.size(); double x = size / (double) Integer.MAX_VALUE; int n = (int) Math.ceil(x); ByteBuffer buffers[] = new ByteBuffer[n]; for (int i = 0; i < n; i++) { buffers[i] = ByteBuffer.allocateDirect(Integer.MAX_VALUE); channel.read(buffers[i]); buffers[i].rewind(); } in = createInputStream(buffers); fireOnConnect(); } } @Override public void processInClose() throws IOException { super.processInClose(); if (fis != null) { fis.close(); } } @Override public void processOutOpen() throws IOException { final File file = new File(filename); try { out = new FileOutputStream(file, append); fireOnConnect(); } catch (Exception e) { fireOnDisconnect(); throw e; } } @Override public void processOutClose() throws IOException { fireOnDisconnect(); out.flush(); out.close(); } |
A TransportHandler can provide different exchange pattern. The handler must deliver the pattern when calling the following method:
Code Block | ||
---|---|---|
| ||
public ITransportExchangePattern getExchangePattern(); |
Currently, the following values are available:
InOnly
RobustInOnly
InOut
InOptionalOut
OutOnly
RobustOutOnly
OutIn
OutOptionalIn
Generic Pull
After the connection is inialized, the framework tries to retrieve data from the TransportHandler. To be generic, we decided to use an InputStream for sources and an OutputStream for sinks. So the following methods need to be overwritten (Remark: It its not necessary to implement both methods, if the TransportHandler e.g. should only be used for sources):
...
Code Block | ||
---|---|---|
| ||
@Override public InputStream getInputStream() { return in; } @Override public OutputStream getOutputStream() { return out; } |
In some cases, sources deliver not an endless data stream. For such cases the method
Code Block | ||
---|---|---|
| ||
public boolean isDone(); |
can be overwrittten.
Source-Generic Push
Sink-Generic Pull
Sink-Generic Push
...