org.fabric3.fabric.container.channel.ChannelConnectionImpl Maven / Gradle / Ivy
The newest version!
/*
* Fabric3
* Copyright (c) 2009-2015 Metaform Systems
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.fabric3.fabric.container.channel;
import java.util.Optional;
import java.util.function.Supplier;
import org.fabric3.spi.container.channel.ChannelConnection;
import org.fabric3.spi.container.channel.EventStream;
import org.fabric3.spi.util.Cast;
import org.fabric3.spi.util.Closeable;
/**
* Default implementation of a channel connection.
*/
public class ChannelConnectionImpl implements ChannelConnection {
private String topic;
private int sequence;
private EventStream stream;
private Closeable closeable;
private Optional> directConnection = Optional.empty();
public ChannelConnectionImpl(EventStream stream, String topic, int sequence) {
this.stream = stream;
this.topic = topic;
this.sequence = sequence;
}
public ChannelConnectionImpl(Supplier> directConnection, String topic, int sequence) {
this.directConnection = Optional.of(directConnection);
this.topic = topic;
this.sequence = sequence;
}
public int getSequence() {
return sequence;
}
public EventStream getEventStream() {
return stream;
}
public Optional> getDirectConnection() {
return Cast.cast(directConnection);
}
public Closeable getCloseable() {
return closeable;
}
public void setCloseable(Closeable closeable) {
this.closeable = closeable;
}
public String getTopic() {
return topic;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy