Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/******************************************************************************
* Copyright 2009-2018 Exactpro (Exactpro Systems Limited)
*
* 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 com.exactpro.sf.common.codecs;
import java.util.Objects;
import java.util.Queue;
import org.apache.mina.core.buffer.IoBuffer;
import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.AbstractProtocolDecoderOutput;
import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolDecoderOutput;
import org.apache.mina.filter.codec.ProtocolEncoder;
import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.exactpro.sf.common.messages.IMessage;
import com.exactpro.sf.common.messages.IMessageFactory;
import com.exactpro.sf.common.messages.MessageUtil;
import com.exactpro.sf.common.messages.MetadataExtensions;
import com.exactpro.sf.common.messages.MsgMetaData;
import com.exactpro.sf.common.messages.structures.IDictionaryStructure;
import com.exactpro.sf.common.util.EvolutionBatch;
import com.exactpro.sf.common.util.ICommonSettings;
import com.exactpro.sf.common.util.IEvolutionSettings;
import com.exactpro.sf.services.IServiceContext;
import com.exactpro.sf.services.MockProtocolDecoderOutput;
public abstract class AbstractCodec extends CumulativeProtocolDecoder implements ProtocolEncoder {
private static final Logger logger = LoggerFactory.getLogger(AbstractCodec.class);
private boolean evolutionSupport;
private IMessageFactory messageFactory;
public void init(IServiceContext serviceContext, ICommonSettings settings, IMessageFactory msgFactory, IDictionaryStructure dictionary) {
this.messageFactory = Objects.requireNonNull(msgFactory, "'Msg factory' parameter");
if (settings instanceof IEvolutionSettings) {
IEvolutionSettings evolutionSettings = (IEvolutionSettings)settings;
evolutionSupport = evolutionSettings.isEvolutionSupportEnabled();
}
}
protected static boolean doDecodeInternal(@NotNull AbstractCodec codec, IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
return codec.doDecodeInternal(session, in, out);
}
@Override
protected boolean doDecode(IoSession session, IoBuffer in, ProtocolDecoderOutput out) throws Exception {
AbstractProtocolDecoderOutput mockOutput = new MockProtocolDecoderOutput();
boolean dataDecoded = doDecodeInternal(session, in, mockOutput);
if (!dataDecoded) {
return false;
}
Queue