/** The logger. */
private final Logger logger = Logger.getLogger(getClass().getName());
- /** The format of the source. */
- private Format format;
+ /** The source. */
+ private Source source;
/** The input stream that will hold the converted source. */
private PipedInputStream pipedInputStream;
@Override
public Format format() {
- return format;
+ return source.format();
}
@Override
public void connect(Source source) throws ConnectException {
Preconditions.checkNotNull(source, "source must not be null");
- format = source.format();
+ this.source = source;
try {
- final Process process = Runtime.getRuntime().exec(Iterables.toArray(ImmutableList.<String>builder().add(binary(format)).addAll(parameters(format)).build(), String.class));
+ final Process process = Runtime.getRuntime().exec(Iterables.toArray(ImmutableList.<String>builder().add(binary(source.format())).addAll(parameters(source.format())).build(), String.class));
final InputStream processOutput = process.getInputStream();
final OutputStream processInput = process.getOutputStream();
final InputStream processError = process.getErrorStream();
/** The connection. */
private Connection connection;
- /** The format. */
- private Format format;
-
@Inject
public MultiSourceFilter(EventBus eventBus) {
this.eventBus = eventBus;
@Override
public Format format() {
- return format;
+ synchronized (syncObject) {
+ return connection.source.format();
+ }
}
@Override
@Override
public void connect(Source source) throws ConnectException {
checkNotNull(source, "source must not be null");
- if (format != null) {
- checkArgument(format.equals(source.format()), "source’s format must equal this sink’s format");
- } else {
- format = source.format();
+ if ((connection != null) && (connection.source != null)) {
+ checkArgument(connection.source.format().equals(source.format()), "source’s format must equal this sink’s format");
}
if (connection == null) {
private final int rate;
/** The source’s format. */
- private Format format;
+ private Source source;
/** The input stream to read from. */
private PipedInputStream pipedInputStream = new PipedInputStream();
@Override
public Format format() {
- return format;
+ return source.format();
}
@Override
public void connect(Source source) throws ConnectException {
Preconditions.checkNotNull(source, "source must not be null");
- format = source.format();
+ this.source = source;
final long start = System.currentTimeMillis();
try {
pipedInputStream = new PipedInputStream();