Skip to content

Noop message store implementation #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@
<junit.version>4.12</junit.version>
<mainClass/>

<maven-resources-plugin-version>3.0.1</maven-resources-plugin-version>
<maven-compiler-plugin-version>3.5.1</maven-compiler-plugin-version>
<maven-resources-plugin-version>3.0.2</maven-resources-plugin-version>
<maven-compiler-plugin-version>3.6.0</maven-compiler-plugin-version>
<maven-jar-plugin-version>3.0.2</maven-jar-plugin-version>
<maven-surefire-plugin-version>2.19.1</maven-surefire-plugin-version>
<maven-pmd-plugin-version>3.7</maven-pmd-plugin-version>
<maven-source-plugin-version>3.0.1</maven-source-plugin-version>
<maven-javadoc-plugin-version>2.10.4</maven-javadoc-plugin-version>
<maven-shade-plugin-version>2.4.3</maven-shade-plugin-version>
<maven-assembly-plugin-version>2.6</maven-assembly-plugin-version>
<maven-assembly-plugin-version>3.0.0</maven-assembly-plugin-version>
<maven-bundle-plugin-version>3.2.0</maven-bundle-plugin-version>
<maven-gpg-plugin-version>1.6</maven-gpg-plugin-version>
<maven-deploy-plugin-version>2.8.2</maven-deploy-plugin-version>
Expand Down
95 changes: 95 additions & 0 deletions quickfixj-core/src/main/java/quickfix/NoopStore.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
******************************************************************************
* Copyright (c) quickfixengine.org All rights reserved.
*
* This file is part of the QuickFIX FIX Engine
*
* This file may be distributed under the terms of the quickfixengine.org
* license as defined by quickfixengine.org and appearing in the file
* LICENSE included in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* See http://www.quickfixengine.org/LICENSE for licensing information.
*
* Contact ask@quickfixengine.org if any conditions of this licensing
* are not clear to you.
******************************************************************************/

package quickfix;

import org.slf4j.LoggerFactory;

import java.util.Collection;
import java.util.Date;

/**
* No-op message store implementation.
*
* @see quickfix.MemoryStoreFactory
*/
public class NoopStore implements MessageStore {

private final SessionID sessionID;

private Date creationTime = new Date();
private int nextSenderMsgSeqNum = 1;
private int nextTargetMsgSeqNum = 1;

public NoopStore(SessionID sessionID) {
this.sessionID = sessionID;
}

public void get(int startSequence, int endSequence, Collection<String> messages) {
}

public Date getCreationTime() {
return creationTime;
}

public int getNextSenderMsgSeqNum() {
return nextSenderMsgSeqNum;
}

public int getNextTargetMsgSeqNum() {
return nextTargetMsgSeqNum;
}

public void incrNextSenderMsgSeqNum() {
nextSenderMsgSeqNum++;
}

public void incrNextTargetMsgSeqNum() {
nextTargetMsgSeqNum++;
}

public void reset() {
creationTime = new Date();
nextSenderMsgSeqNum = 1;
nextTargetMsgSeqNum = 1;
}

public boolean set(int sequence, String message) {
return true;
}

public void setNextSenderMsgSeqNum(int next) {
nextSenderMsgSeqNum = next;
}

public void setNextTargetMsgSeqNum(int next) {
nextTargetMsgSeqNum = next;
}

public void refresh() {
final String text = "No-op store does not support refresh!";
if (sessionID != null) {
final Session session = Session.lookupSession(sessionID);
session.getLog().onErrorEvent("ERROR: " + text);
} else {
LoggerFactory.getLogger(NoopStore.class).error(text);
}
}
}
34 changes: 34 additions & 0 deletions quickfixj-core/src/main/java/quickfix/NoopStoreFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
******************************************************************************
* Copyright (c) quickfixengine.org All rights reserved.
*
* This file is part of the QuickFIX FIX Engine
*
* This file may be distributed under the terms of the quickfixengine.org
* license as defined by quickfixengine.org and appearing in the file
* LICENSE included in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* See http://www.quickfixengine.org/LICENSE for licensing information.
*
* Contact ask@quickfixengine.org if any conditions of this licensing
* are not clear to you.
******************************************************************************/

package quickfix;

/**
* Creates a no-op message store.
*
* @see MessageStore
*/
public final class NoopStoreFactory implements MessageStoreFactory {

@Override
public MessageStore create(SessionID sessionID) {
return new NoopStore(sessionID);
}
}
31 changes: 31 additions & 0 deletions quickfixj-core/src/test/java/quickfix/NoopStoreTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
******************************************************************************
* Copyright (c) quickfixengine.org All rights reserved.
*
* This file is part of the QuickFIX FIX Engine
*
* This file may be distributed under the terms of the quickfixengine.org
* license as defined by quickfixengine.org and appearing in the file
* LICENSE included in the packaging of this file.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* See http://www.quickfixengine.org/LICENSE for licensing information.
*
* Contact ask@quickfixengine.org if any conditions of this licensing
* are not clear to you.
******************************************************************************/

package quickfix;

public class NoopStoreTest extends AbstractMessageStoreTest {
protected MessageStoreFactory getMessageStoreFactory() {
return new NoopStoreFactory();
}

protected Class<?> getMessageStoreClass() {
return NoopStore.class;
}
}