Skip to content

Commit

Permalink
Changes from FlexTrade
Browse files Browse the repository at this point in the history
  • Loading branch information
philipwhiuk authored and Philip Whitehouse committed Sep 12, 2024
1 parent dce91e6 commit 465d0df
Show file tree
Hide file tree
Showing 115 changed files with 6,354 additions and 2,121 deletions.
26 changes: 25 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,31 @@
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -312,5 +337,4 @@
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

</project>
14 changes: 10 additions & 4 deletions quickfixj-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,16 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.sleepycat</groupId>
<artifactId>je</artifactId>
<version>18.3.12</version>
<optional>true</optional>
<groupId>com.flextrade.jfixture</groupId>
<artifactId>jfixture</artifactId>
<version>2.7.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public String getRemoteIPAddress() {
*/
public void reset() {
logInvocation("reset");
session.reset();
session.reset("Reset requested");
}

/* (non-Javadoc)
Expand Down
8 changes: 8 additions & 0 deletions quickfixj-core/src/main/java/quickfix/AbstractLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ public final void onOutgoing(String message) {

protected abstract void logOutgoing(String message);

@Override
public void onInvalidMessage(String messageString, String failureReason) {
}

@Override
public void onDisconnect(String reason) {
}

public void close() throws IOException {
// default is to do nothing
}
Expand Down
8 changes: 4 additions & 4 deletions quickfixj-core/src/main/java/quickfix/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public interface Application {
* @param message QuickFIX message
* @param sessionId QuickFIX session ID
*/
void toAdmin(Message message, SessionID sessionId);
void toAdmin(IMessage message, SessionID sessionId);

/**
* This callback notifies you when an administrative message is sent from a
Expand All @@ -78,7 +78,7 @@ public interface Application {
* @throws IncorrectTagValue
* @throws RejectLogon causes a logon reject
*/
void fromAdmin(Message message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat,
void fromAdmin(IMessage message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat,
IncorrectTagValue, RejectLogon;

/**
Expand All @@ -97,7 +97,7 @@ void fromAdmin(Message message, SessionID sessionId) throws FieldNotFound, Incor
* @param sessionId QuickFIX session ID
* @throws DoNotSend This exception aborts message transmission
*/
void toApp(Message message, SessionID sessionId) throws DoNotSend;
void toApp(IMessage message, SessionID sessionId) throws DoNotSend;

/**
* This callback receives messages for the application. This is one of the
Expand All @@ -121,6 +121,6 @@ void fromAdmin(Message message, SessionID sessionId) throws FieldNotFound, Incor
* @throws IncorrectTagValue
* @throws UnsupportedMessageType
*/
void fromApp(Message message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat,
void fromApp(IMessage message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat,
IncorrectTagValue, UnsupportedMessageType;
}
8 changes: 4 additions & 4 deletions quickfixj-core/src/main/java/quickfix/ApplicationAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ public class ApplicationAdapter implements Application {
/* (non-Javadoc)
* @see quickfix.Application#fromAdmin(quickfix.Message, quickfix.SessionID)
*/
public void fromAdmin(Message message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon {
public void fromAdmin(IMessage message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon {
// EMPTY
}

/* (non-Javadoc)
* @see quickfix.Application#fromApp(quickfix.Message, quickfix.SessionID)
*/
public void fromApp(Message message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType {
public void fromApp(IMessage message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType {
// EMPTY
}

Expand Down Expand Up @@ -62,14 +62,14 @@ public void onLogout(SessionID sessionId) {
/* (non-Javadoc)
* @see quickfix.Application#toAdmin(quickfix.Message, quickfix.SessionID)
*/
public void toAdmin(Message message, SessionID sessionId) {
public void toAdmin(IMessage message, SessionID sessionId) {
// EMPTY
}

/* (non-Javadoc)
* @see quickfix.Application#toApp(quickfix.Message, quickfix.SessionID)
*/
public void toApp(Message message, SessionID sessionId) throws DoNotSend {
public void toApp(IMessage message, SessionID sessionId) throws DoNotSend {
// EMPTY
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ public class ApplicationFunctionalAdapter implements Application {
private final List<Consumer<SessionID>> onLogonListeners = new CopyOnWriteArrayList<>();
private final List<Consumer<SessionID>> onLogoutListeners = new CopyOnWriteArrayList<>();

private final List<BiConsumer<Message, SessionID>> toAdminListeners = new CopyOnWriteArrayList<>();
private final List<BiConsumer<IMessage, SessionID>> toAdminListeners = new CopyOnWriteArrayList<>();
private final ConcurrentMap<Class, List<BiConsumer>> toAdminTypeSafeListeners = new ConcurrentHashMap<>();

private final List<FromAdminListener<Message>> fromAdminListeners = new CopyOnWriteArrayList<>();
private final List<FromAdminListener<IMessage>> fromAdminListeners = new CopyOnWriteArrayList<>();
private final ConcurrentMap<Class, List<FromAdminListener>> fromAdminTypeSafeListeners = new ConcurrentHashMap<>();

private final List<ToAppListener<Message>> toAppListeners = new CopyOnWriteArrayList<>();
private final List<ToAppListener<IMessage>> toAppListeners = new CopyOnWriteArrayList<>();
private final ConcurrentMap<Class, List<ToAppListener>> toAppTypeSafeListeners = new ConcurrentHashMap<>();

private final List<FromAppListener<Message>> fromAppListeners = new CopyOnWriteArrayList<>();
private final List<FromAppListener<IMessage>> fromAppListeners = new CopyOnWriteArrayList<>();
private final ConcurrentMap<Class, List<FromAppListener>> fromAppTypeSafeListeners = new ConcurrentHashMap<>();

/**
Expand Down Expand Up @@ -99,7 +99,7 @@ public void removeOnLogoutListener(Consumer<SessionID> onLogoutListener) {
*
* @param toAdminListener the BiConsumer of Session for toAdmin operation.
*/
public void addToAdminListener(BiConsumer<Message, SessionID> toAdminListener) {
public void addToAdminListener(BiConsumer<IMessage, SessionID> toAdminListener) {
toAdminListeners.add(toAdminListener);
}

Expand All @@ -109,7 +109,7 @@ public void addToAdminListener(BiConsumer<Message, SessionID> toAdminListener) {
* @param clazz the specific Message class the listener expects
* @param toAdminListener the BiConsumer of Session for toAdmin operation.
*/
public <T extends Message> void addToAdminListener(Class<T> clazz, BiConsumer<T, SessionID> toAdminListener) {
public <T extends IMessage> void addToAdminListener(Class<T> clazz, BiConsumer<T, SessionID> toAdminListener) {
getList(toAdminTypeSafeListeners, clazz)
.add(toAdminListener);
}
Expand All @@ -119,7 +119,7 @@ public <T extends Message> void addToAdminListener(Class<T> clazz, BiConsumer<T,
*
* @param toAdminListener the BiConsumer of Session for toAdmin operation.
*/
public <T extends Message> void removeToAdminListener(BiConsumer<T, SessionID> toAdminListener) {
public <T extends IMessage> void removeToAdminListener(BiConsumer<T, SessionID> toAdminListener) {
toAdminListeners.remove(toAdminListener);
toAdminTypeSafeListeners
.values()
Expand All @@ -131,7 +131,7 @@ public <T extends Message> void removeToAdminListener(BiConsumer<T, SessionID> t
*
* @param fromAdminListener the listener of fromAdmin operation.
*/
public void addFromAdminListener(FromAdminListener<Message> fromAdminListener) {
public void addFromAdminListener(FromAdminListener<IMessage> fromAdminListener) {
fromAdminListeners.add(fromAdminListener);
}

Expand Down Expand Up @@ -163,7 +163,7 @@ public <T extends Message> void removeFromAdminListener(FromAdminListener<T> fro
*
* @param toAppListener the listener of fromAdmin operation.
*/
public void addToAppListener(ToAppListener<Message> toAppListener) {
public void addToAppListener(ToAppListener<IMessage> toAppListener) {
toAppListeners.add(toAppListener);
}

Expand Down Expand Up @@ -195,7 +195,7 @@ public <T extends Message> void removeToAppListener(ToAppListener<T> toAppListen
*
* @param fromAppListener the listener of fromApp operation.
*/
public void addFromAppListener(FromAppListener<Message> fromAppListener) {
public void addFromAppListener(FromAppListener<IMessage> fromAppListener) {
fromAppListeners.add(fromAppListener);
}

Expand Down Expand Up @@ -238,15 +238,15 @@ public void onLogout(SessionID sessionId) {
}

@Override
public void toAdmin(Message message, SessionID sessionId) {
public void toAdmin(IMessage message, SessionID sessionId) {
toAdminListeners.forEach(c -> c.accept(message, sessionId));
getList(toAdminTypeSafeListeners, message.getClass())
.forEach(c -> c.accept(message, sessionId));
}

@Override
public void fromAdmin(Message message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon {
for (FromAdminListener<Message> listener : fromAdminListeners) {
public void fromAdmin(IMessage message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, RejectLogon {
for (FromAdminListener<IMessage> listener : fromAdminListeners) {
listener.accept(message, sessionId);
}

Expand All @@ -257,8 +257,8 @@ public void fromAdmin(Message message, SessionID sessionId) throws FieldNotFound
}

@Override
public void toApp(Message message, SessionID sessionId) throws DoNotSend {
for (ToAppListener<Message> listener : toAppListeners) {
public void toApp(IMessage message, SessionID sessionId) throws DoNotSend {
for (ToAppListener<IMessage> listener : toAppListeners) {
listener.accept(message, sessionId);
}

Expand All @@ -268,8 +268,8 @@ public void toApp(Message message, SessionID sessionId) throws DoNotSend {
}

@Override
public void fromApp(Message message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType {
for (FromAppListener<Message> listener : fromAppListeners) {
public void fromApp(IMessage message, SessionID sessionId) throws FieldNotFound, IncorrectDataFormat, IncorrectTagValue, UnsupportedMessageType {
for (FromAppListener<IMessage> listener : fromAppListeners) {
listener.accept(message, sessionId);
}

Expand Down
8 changes: 8 additions & 0 deletions quickfixj-core/src/main/java/quickfix/CachedFileStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,14 @@ public Date getCreationTime() throws IOException {
return cache.getCreationTime();
}

/*
* (non-Javadoc)
* @see quickfix.MessageStore#getCreationTimeCalendar()
*/
public Calendar getCreationTimeCalendar() throws IOException {
return cache.getCreationTimeCalendar();
}

private void initializeSequenceNumbers() throws IOException {
sequenceNumberFile.seek(0);
if (sequenceNumberFile.length() > 0) {
Expand Down
51 changes: 39 additions & 12 deletions quickfixj-core/src/main/java/quickfix/CompositeLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,59 +36,86 @@ public CompositeLog(Log[] logs) {
this.logs = logs;
}

@Override
public void clear() {
for (Log log : logs) {
try {
log.clear();
} catch (Throwable e) {
handleError(e);
} catch (Exception e) {
handleException(e);
}
}
}

private void handleError(Throwable e) {
private void handleException(Exception e) {
if (rethrowException) {
throw new RuntimeException(e);
}
defaultLog.error(e.getMessage() + ", continuing", e);
}

@Override
public void onIncoming(String message) {
for (Log log : logs) {
try {
log.onIncoming(message);
} catch (Throwable e) {
handleError(e);
} catch (Exception e) {
handleException(e);
}
}
}

@Override
public void onOutgoing(String message) {
for (Log log : logs) {
try {
log.onOutgoing(message);
} catch (Throwable e) {
} catch (Exception e) {
defaultLog.error(e.getMessage() + ", continuing", e);
}
}
}

@Override
public void onEvent(String text) {
for (Log log : logs) {
try {
log.onEvent(text);
} catch (Throwable e) {
handleError(e);
} catch (Exception e) {
handleException(e);
}
}
}

public void onErrorEvent(String text) {
@Override
public void onErrorEvent(String category, String text) {
for (Log log : logs) {
try {
log.onErrorEvent(text);
} catch (Throwable e) {
handleError(e);
log.onErrorEvent(category, text);
} catch (Exception e) {
handleException(e);
}
}
}

@Override
public void onInvalidMessage(String messageString, String failureReason) {
for (Log log : logs) {
try {
log.onInvalidMessage(messageString, failureReason);
} catch (Exception e) {
handleException(e);
}
}
}

@Override
public void onDisconnect(String reason) {
for (Log log : logs) {
try {
log.onDisconnect(reason);
} catch (Exception e) {
handleException(e);
}
}
}
Expand Down
Loading

0 comments on commit 465d0df

Please sign in to comment.