blob: 5d4e3c8a4d05fc86ec99ac7cda12fa18da648007 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.apache.airavata.mft.core.bufferedImpl;
import org.apache.airavata.mft.core.api.ConnectorChannel;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.channels.Channel;
import java.nio.channels.Channels;
import java.nio.channels.WritableByteChannel;
import java.util.HashMap;
/**
* A class which represents the channel in {@Link SinkConnector}
*/
public class OutChannel implements ConnectorChannel {
private OutputStream outputStream;
private WritableByteChannel writableByteChannel;
private HashMap<String, Object> contextAttributeMap = new HashMap();
public OutChannel(OutputStream outputStream) {
this.outputStream = outputStream;
writableByteChannel = Channels.newChannel(outputStream);
}
@Override
public Channel getChannel() {
return writableByteChannel;
}
@Override
public void closeChannel() throws IOException {
outputStream.close();
}
@Override
public void addChannelAttribute(String key, Object value) {
contextAttributeMap.put(key, value);
}
@Override
public Object getChannelAttribute(String key){
return contextAttributeMap.get(key);
}
}