Skip to content

Commit

Permalink
#28 fix javadocs, update declared exceptions, update quickfix dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
kpavlov committed Jan 21, 2017
1 parent 8265e87 commit cb831ae
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import fixio.fixprotocol.FixMessage;
import fixio.fixprotocol.FixMessageBuilder;
import fixio.validator.BusinessRejectException;
import fixio.validator.FixMessageValidator;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
Expand All @@ -41,16 +42,14 @@ public CompositeFixApplicationAdapter(List<FixMessageValidator> validators, List
}

@Override
public void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) throws Exception {
public void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) throws BusinessRejectException {
assert (msg != null) : "Message can't be null";
LOGGER.info("Received : {}", msg);

//Validate
if (validators != null) {
for (FixMessageValidator validator : validators) {
validator.validate(ctx, msg);
}
}

//Business handler
if (handlers != null) {
Expand All @@ -71,7 +70,7 @@ public void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> ou
}

@Override
public void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder msg) throws Exception {
public void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder msg) {
for (FixMessageHandler handler : handlers) {
handler.beforeSendMessage(ctx, msg);
}
Expand Down
12 changes: 8 additions & 4 deletions core/src/main/java/fixio/handlers/FixApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import fixio.events.LogoutEvent;
import fixio.fixprotocol.FixMessage;
import fixio.fixprotocol.FixMessageBuilder;
import fixio.validator.BusinessRejectException;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;

Expand Down Expand Up @@ -48,14 +49,17 @@ public interface FixApplication extends ChannelHandler {
* @param ctx current {@link ChannelHandlerContext}
* @param msg a {@link FixMessage} to handle
* @param out a {@link List} where decoded messages should be added
*
* @throws BusinessRejectException when message can't be accepted
* @throws InterruptedException if interrupted while processing a message
*/
void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) throws Exception;
void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out)
throws BusinessRejectException, InterruptedException;

/**
* Invoked before {@link FixMessageBuilder} is sent.
*
* @param ctx current {@link ChannelHandlerContext}
* @param ctx current {@link ChannelHandlerContext}
* @param messageBuilder a message builder
*/
void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder) throws Exception;
void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder messageBuilder);
}
14 changes: 10 additions & 4 deletions core/src/main/java/fixio/handlers/FixApplicationAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import fixio.events.LogoutEvent;
import fixio.fixprotocol.FixMessage;
import fixio.fixprotocol.FixMessageBuilder;
import fixio.validator.BusinessRejectException;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;
Expand Down Expand Up @@ -57,16 +58,21 @@ public void onLogout(ChannelHandlerContext ctx, LogoutEvent msg) {
}

@Override
public void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) throws Exception {
public void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) throws BusinessRejectException, InterruptedException {
}

@Override
public void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder msg) throws Exception {
public void beforeSendMessage(ChannelHandlerContext ctx, FixMessageBuilder msg) {
}

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
LOGGER.error("Uncaught application exception.", cause);
ctx.close().sync();
try {
ctx.close().sync();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException("Interrupted while closing channel", e);
}
}
}
2 changes: 1 addition & 1 deletion core/src/test/java/fixio/FixConversationIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void testBusinessMessage() throws InterruptedException {
private static class ServerLogicHandler extends FixApplicationAdapter {

@Override
public void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) throws Exception {
public void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) {
if (MessageTypes.USER_REQUEST.equals(msg.getMessageType())) {
conversation.add(msg);
ctx.writeAndFlush(createUserStatusReport());
Expand Down
30 changes: 10 additions & 20 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<artifactId>examples</artifactId>

<properties>
<quickfix.version>1.5.3</quickfix.version>
<quickfix.version>1.6.3</quickfix.version>
</properties>

<dependencies>
Expand All @@ -44,33 +44,23 @@
</dependency>

<dependency>
<groupId>quickfixj</groupId>
<groupId>org.quickfixj</groupId>
<artifactId>quickfixj-all</artifactId>
<version>${quickfix.version}</version>
</dependency>
<dependency>
<groupId>quickfixj</groupId>
<artifactId>quickfixj-msg-fix44</artifactId>
<groupId>org.quickfixj</groupId>
<artifactId>quickfixj-messages-fix44</artifactId>
<version>${quickfix.version}</version>
</dependency>

<dependency>
<groupId>org.apache.mina</groupId>
<artifactId>mina-core</artifactId>
<version>1.1.0</version>
<scope>runtime</scope>
</dependency>
<!--<dependency>-->
<!--<groupId>org.apache.mina</groupId>-->
<!--<artifactId>mina-core</artifactId>-->
<!--<version>1.1.0</version>-->
<!--<scope>runtime</scope>-->
<!--</dependency>-->

</dependencies>

<repositories>
<repository>
<id>MarketceteraRepo</id>
<url>http://repo.marketcetera.org/maven</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
package fixio.examples.priceclient;

import fixio.events.LogonEvent;
import fixio.fixprotocol.*;
import fixio.fixprotocol.FieldType;
import fixio.fixprotocol.FixMessage;
import fixio.fixprotocol.FixMessageBuilder;
import fixio.fixprotocol.FixMessageBuilderImpl;
import fixio.fixprotocol.Group;
import fixio.fixprotocol.MessageTypes;
import fixio.handlers.FixApplicationAdapter;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
Expand All @@ -41,7 +46,7 @@ public void onLogon(ChannelHandlerContext ctx, LogonEvent msg) {
}

@Override
public void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) throws Exception {
public void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) {
assert (msg != null) : "Message can't be null";
switch (msg.getMessageType()) {
case MessageTypes.QUOTE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void onLogout(ChannelHandlerContext ctx, LogoutEvent msg) {
}

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
stopStreaming(ctx);
super.exceptionCaught(ctx, cause);
}
Expand All @@ -77,7 +77,7 @@ private void stopStreaming(ChannelHandlerContext ctx) {
}

@Override
public void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) throws Exception {
public void onMessage(ChannelHandlerContext ctx, FixMessage msg, List<Object> out) {
String reqId;
final String messageType = msg.getMessageType();
switch (messageType) {
Expand Down

0 comments on commit cb831ae

Please sign in to comment.