Skip to content

Commit fe683ee

Browse files
committed
Merge pull request #87 from guidomedina/noop-message-store-implementation
Noop message store implementation (cherry picked from commit 2a77d99)
1 parent 02eaacf commit fe683ee

File tree

4 files changed

+163
-3
lines changed

4 files changed

+163
-3
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@
7373
<junit.version>4.12</junit.version>
7474
<mainClass/>
7575

76-
<maven-resources-plugin-version>3.0.1</maven-resources-plugin-version>
77-
<maven-compiler-plugin-version>3.5.1</maven-compiler-plugin-version>
76+
<maven-resources-plugin-version>3.0.2</maven-resources-plugin-version>
77+
<maven-compiler-plugin-version>3.6.0</maven-compiler-plugin-version>
7878
<maven-jar-plugin-version>3.0.2</maven-jar-plugin-version>
7979
<maven-surefire-plugin-version>2.19.1</maven-surefire-plugin-version>
8080
<maven-pmd-plugin-version>3.7</maven-pmd-plugin-version>
8181
<maven-source-plugin-version>3.0.1</maven-source-plugin-version>
8282
<maven-javadoc-plugin-version>2.10.4</maven-javadoc-plugin-version>
8383
<maven-shade-plugin-version>2.4.3</maven-shade-plugin-version>
84-
<maven-assembly-plugin-version>2.6</maven-assembly-plugin-version>
84+
<maven-assembly-plugin-version>3.0.0</maven-assembly-plugin-version>
8585
<maven-bundle-plugin-version>3.2.0</maven-bundle-plugin-version>
8686
<maven-gpg-plugin-version>1.6</maven-gpg-plugin-version>
8787
<maven-deploy-plugin-version>2.8.2</maven-deploy-plugin-version>
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
******************************************************************************
3+
* Copyright (c) quickfixengine.org All rights reserved.
4+
*
5+
* This file is part of the QuickFIX FIX Engine
6+
*
7+
* This file may be distributed under the terms of the quickfixengine.org
8+
* license as defined by quickfixengine.org and appearing in the file
9+
* LICENSE included in the packaging of this file.
10+
*
11+
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
12+
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
13+
* PARTICULAR PURPOSE.
14+
*
15+
* See http://www.quickfixengine.org/LICENSE for licensing information.
16+
*
17+
* Contact ask@quickfixengine.org if any conditions of this licensing
18+
* are not clear to you.
19+
******************************************************************************/
20+
21+
package quickfix;
22+
23+
import org.slf4j.LoggerFactory;
24+
25+
import java.util.Collection;
26+
import java.util.Date;
27+
28+
/**
29+
* No-op message store implementation.
30+
*
31+
* @see quickfix.MemoryStoreFactory
32+
*/
33+
public class NoopStore implements MessageStore {
34+
35+
private final SessionID sessionID;
36+
37+
private Date creationTime = new Date();
38+
private int nextSenderMsgSeqNum = 1;
39+
private int nextTargetMsgSeqNum = 1;
40+
41+
public NoopStore(SessionID sessionID) {
42+
this.sessionID = sessionID;
43+
}
44+
45+
public void get(int startSequence, int endSequence, Collection<String> messages) {
46+
}
47+
48+
public Date getCreationTime() {
49+
return creationTime;
50+
}
51+
52+
public int getNextSenderMsgSeqNum() {
53+
return nextSenderMsgSeqNum;
54+
}
55+
56+
public int getNextTargetMsgSeqNum() {
57+
return nextTargetMsgSeqNum;
58+
}
59+
60+
public void incrNextSenderMsgSeqNum() {
61+
nextSenderMsgSeqNum++;
62+
}
63+
64+
public void incrNextTargetMsgSeqNum() {
65+
nextTargetMsgSeqNum++;
66+
}
67+
68+
public void reset() {
69+
creationTime = new Date();
70+
nextSenderMsgSeqNum = 1;
71+
nextTargetMsgSeqNum = 1;
72+
}
73+
74+
public boolean set(int sequence, String message) {
75+
return true;
76+
}
77+
78+
public void setNextSenderMsgSeqNum(int next) {
79+
nextSenderMsgSeqNum = next;
80+
}
81+
82+
public void setNextTargetMsgSeqNum(int next) {
83+
nextTargetMsgSeqNum = next;
84+
}
85+
86+
public void refresh() {
87+
final String text = "No-op store does not support refresh!";
88+
if (sessionID != null) {
89+
final Session session = Session.lookupSession(sessionID);
90+
session.getLog().onErrorEvent("ERROR: " + text);
91+
} else {
92+
LoggerFactory.getLogger(NoopStore.class).error(text);
93+
}
94+
}
95+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
******************************************************************************
3+
* Copyright (c) quickfixengine.org All rights reserved.
4+
*
5+
* This file is part of the QuickFIX FIX Engine
6+
*
7+
* This file may be distributed under the terms of the quickfixengine.org
8+
* license as defined by quickfixengine.org and appearing in the file
9+
* LICENSE included in the packaging of this file.
10+
*
11+
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
12+
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
13+
* PARTICULAR PURPOSE.
14+
*
15+
* See http://www.quickfixengine.org/LICENSE for licensing information.
16+
*
17+
* Contact ask@quickfixengine.org if any conditions of this licensing
18+
* are not clear to you.
19+
******************************************************************************/
20+
21+
package quickfix;
22+
23+
/**
24+
* Creates a no-op message store.
25+
*
26+
* @see MessageStore
27+
*/
28+
public final class NoopStoreFactory implements MessageStoreFactory {
29+
30+
@Override
31+
public MessageStore create(SessionID sessionID) {
32+
return new NoopStore(sessionID);
33+
}
34+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
******************************************************************************
3+
* Copyright (c) quickfixengine.org All rights reserved.
4+
*
5+
* This file is part of the QuickFIX FIX Engine
6+
*
7+
* This file may be distributed under the terms of the quickfixengine.org
8+
* license as defined by quickfixengine.org and appearing in the file
9+
* LICENSE included in the packaging of this file.
10+
*
11+
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
12+
* THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A
13+
* PARTICULAR PURPOSE.
14+
*
15+
* See http://www.quickfixengine.org/LICENSE for licensing information.
16+
*
17+
* Contact ask@quickfixengine.org if any conditions of this licensing
18+
* are not clear to you.
19+
******************************************************************************/
20+
21+
package quickfix;
22+
23+
public class NoopStoreTest extends AbstractMessageStoreTest {
24+
protected MessageStoreFactory getMessageStoreFactory() {
25+
return new NoopStoreFactory();
26+
}
27+
28+
protected Class<?> getMessageStoreClass() {
29+
return NoopStore.class;
30+
}
31+
}

0 commit comments

Comments
 (0)