
io.fixprotocol.orchestra.model.quickfix.QuickfixPopulator Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2017-2020 FIX Protocol Ltd
*
* 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 io.fixprotocol.orchestra.model.quickfix;
import java.util.List;
import java.util.function.Function;
import io.fixprotocol._2020.orchestra.repository.BlockAssignmentType;
import io.fixprotocol._2020.orchestra.repository.CodeSetType;
import io.fixprotocol._2020.orchestra.repository.ComponentRefType;
import io.fixprotocol._2020.orchestra.repository.FieldRefType;
import io.fixprotocol._2020.orchestra.repository.GroupRefType;
import io.fixprotocol._2020.orchestra.repository.GroupType;
import io.fixprotocol._2020.orchestra.repository.MessageType;
import io.fixprotocol.orchestra.dsl.antlr.Evaluator;
import io.fixprotocol.orchestra.dsl.antlr.ScoreException;
import io.fixprotocol.orchestra.message.CodeSetScope;
import io.fixprotocol.orchestra.message.Populator;
import io.fixprotocol.orchestra.model.FixValue;
import io.fixprotocol.orchestra.model.ModelException;
import io.fixprotocol.orchestra.model.PathStep;
import io.fixprotocol.orchestra.model.Scope;
import io.fixprotocol.orchestra.model.SymbolResolver;
import quickfix.FieldMap;
import quickfix.Group;
import quickfix.Message;
/**
* @author Don Mendelson
*
*/
public class QuickfixPopulator implements Populator {
private final Evaluator evaluator;
private final RepositoryAccessor repositoryAdapter;
private final SymbolResolver symbolResolver;
private final Function groupFactory;
/**
* Constructor
*
* @param repositoryAdapter repository wrapper
* @param symbolResolver resolves symbols in expressions
* @param groupFactory creates instances of QuickFIX Group
*/
public QuickfixPopulator(RepositoryAccessor repositoryAdapter, SymbolResolver symbolResolver,
Function groupFactory) {
this.repositoryAdapter = repositoryAdapter;
this.symbolResolver = symbolResolver;
evaluator = new Evaluator(symbolResolver);
this.groupFactory = groupFactory;
}
@Override
public void populate(Message inboundMessage, MessageType inboundMessageType,
Message outboundMessage, MessageType outboundMessageType) throws ModelException {
try (
Scope inScope = symbolResolver.nest(new PathStep("in."),
new MessageScope(inboundMessage, inboundMessageType, repositoryAdapter, symbolResolver,
evaluator));
Scope outScope = symbolResolver.nest(new PathStep("out."), new MessageScope(outboundMessage,
outboundMessageType, repositoryAdapter, symbolResolver, evaluator))) {
final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy