You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
(7) |
Dec
(18) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(20) |
Feb
(7) |
Mar
|
Apr
(8) |
May
(9) |
Jun
(7) |
Jul
(23) |
Aug
(3) |
Sep
|
Oct
(16) |
Nov
|
Dec
(3) |
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(6) |
Jun
(8) |
Jul
|
Aug
|
Sep
|
Oct
(5) |
Nov
(2) |
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(1) |
Oct
(30) |
Nov
|
Dec
|
2012 |
Jan
(4) |
Feb
(2) |
Mar
(1) |
Apr
(23) |
May
(4) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(7) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <ope...@li...> - 2011-10-20 15:22:53
|
Revision: 233 http://openfast.svn.sourceforge.net/openfast/?rev=233&view=rev Author: jacob_northey Date: 2011-10-20 15:22:46 +0000 (Thu, 20 Oct 2011) Log Message: ----------- [FAST-37] Fixed exponent in DecimalValue(BigDecimal) constructor Modified Paths: -------------- trunk/src/main/java/org/openfast/DecimalValue.java trunk/src/test/java/org/openfast/DecimalValueTest.java Modified: trunk/src/main/java/org/openfast/DecimalValue.java =================================================================== --- trunk/src/main/java/org/openfast/DecimalValue.java 2011-06-16 19:52:05 UTC (rev 232) +++ trunk/src/main/java/org/openfast/DecimalValue.java 2011-10-20 15:22:46 UTC (rev 233) @@ -59,7 +59,7 @@ public DecimalValue(BigDecimal bigDecimal) { this.mantissa = bigDecimal.unscaledValue().longValue(); - this.exponent = bigDecimal.scale(); + this.exponent = -1 * bigDecimal.scale(); } @Override Modified: trunk/src/test/java/org/openfast/DecimalValueTest.java =================================================================== --- trunk/src/test/java/org/openfast/DecimalValueTest.java 2011-06-16 19:52:05 UTC (rev 232) +++ trunk/src/test/java/org/openfast/DecimalValueTest.java 2011-10-20 15:22:46 UTC (rev 233) @@ -23,7 +23,6 @@ import java.math.BigDecimal; import java.math.BigInteger; - import org.openfast.error.FastConstants; import org.openfast.error.FastException; import org.openfast.test.OpenFastTestCase; @@ -33,11 +32,15 @@ assertEquals(new BigDecimal(BigInteger.valueOf(241), -5), new DecimalValue(241, 5).toBigDecimal()); assertEquals(new BigDecimal(BigInteger.valueOf(15), 4), new DecimalValue(15, -4).toBigDecimal()); } - + + public void testBigDecimalConstructor() { + assertEquals("1.2345", new DecimalValue(new BigDecimal("1.2345")).toString()); + } + public void testToDouble() { assertEquals(3.3, new DecimalValue(33, -1).toDouble(), 0.000000000001); } - + public void testMaxValue() { DecimalValue max = new DecimalValue(Long.MAX_VALUE, 63); assertEquals(new BigDecimal(new BigInteger(String.valueOf(Long.MAX_VALUE)), -63), max.toBigDecimal()); @@ -51,8 +54,8 @@ value = new DecimalValue(942755, -2); assertEquals(BigDecimal.valueOf(9427.55), value.toBigDecimal()); } - + public void testToByte() { assertEquals(100, d(100.0).toByte()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2011-09-15 06:07:27
|
HI, I am new to FIX Open Fast stuff. I am using Visual studio .Net. I have added Open FAST library to my application. I have create Template like this <tt <template name="MDIncRefresh_97" id="97" dictionary="97"> - - < string name="ApplVerID" id="1128"> <constant value="9" /> </string> - <string name="MessageType" id="35"> <constant value="X" /> </string> - <string name="SenderCompID" id="49"> <constant value="CME" /> </string> <uInt32 name="MsgSeqNum" id="34" /> <uInt64 name="SendingTime" id="52" /> - <string name="PosDupFlag" id="43" presence="optional"> <default /> </string> <uInt32 name="TradeDate" id="75" /> - <sequence name="MDEntries"> <length name="NoMDEntries" id="268" /> - <uInt32 name="MDUpdateAction" id="279"> <copy value="0" /> </uInt32> - <uInt32 name="SecurityIDSource" id="22"> <constant value="8" /> </uInt32> - <uInt32 name="SecurityID" id="48"> <copy /> </uInt32> - <uInt32 name="RptSeq" id="83"> <increment /> </uInt32> - <string name="MDEntryType" id="269"> <copy value="B" /> </string> - <decimal name="MDEntryPx" id="270" presence="optional"> - <exponent> <default value="0" /> </exponent> - <mantissa> <delta /> </mantissa> </decimal> - <int32 name="MDEntrySize" id="271" presence="optional"> <delta /> </int32> - <uInt32 name="MDEntryTime" id="273"> <copy /> </uInt32> <uInt32 name="OpenCloseSettleFlag" id="286" presence="optional" /> - <uInt32 name="SettlDate" id="64" presence="optional"> <default /> </uInt32> - <string name="FixingBracket" id="5790" presence="optional"> <copy /> </string> </sequence> </template> So I want to test my application encode and decode for a FIX Message. I need to pass parameter here. public FastEncoder(Context context) { _context = context; } what parameter should I pass here ?Please can anyone explain me. Thanks, Karthik. |
From: <ope...@li...> - 2011-06-16 19:52:11
|
Revision: 232 http://openfast.svn.sourceforge.net/openfast/?rev=232&view=rev Author: jacob_northey Date: 2011-06-16 19:52:05 +0000 (Thu, 16 Jun 2011) Log Message: ----------- Fixed message copy bug Modified Paths: -------------- trunk/src/main/java/org/openfast/Message.java Modified: trunk/src/main/java/org/openfast/Message.java =================================================================== --- trunk/src/main/java/org/openfast/Message.java 2010-11-19 14:53:25 UTC (rev 231) +++ trunk/src/main/java/org/openfast/Message.java 2011-06-16 19:52:05 UTC (rev 232) @@ -76,6 +76,6 @@ for (int i = 0; i < copies.length; i++) { copies[i] = values[i].copy(); } - return new Message(template, this.values); + return new Message(template, copies); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-11-19 14:53:31
|
Revision: 231 http://openfast.svn.sourceforge.net/openfast/?rev=231&view=rev Author: jacob_northey Date: 2010-11-19 14:53:25 +0000 (Fri, 19 Nov 2010) Log Message: ----------- [FAST-31] Fixed encoding of Unicode strings that contain exactly 127 bytes Modified Paths: -------------- trunk/pom.xml trunk/src/main/java/org/openfast/session/multicast/MulticastInputStream.java trunk/src/main/java/org/openfast/template/type/codec/NullableByteVector.java trunk/src/test/java/org/openfast/template/type/codec/NullableUnicodeStringTest.java Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-11-08 17:11:34 UTC (rev 230) +++ trunk/pom.xml 2010-11-19 14:53:25 UTC (rev 231) @@ -230,21 +230,21 @@ <id>sourceforge.net</id> <name>Sourceforge.net Repository</name> <url> - scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/release + scp://shell.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/release </url> </repository> <snapshotRepository> <id>sourceforge.net</id> <name>Sourceforge.net Snapshot Repository</name> <url> - scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/snapshot + scp://shell.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/snapshot </url> </snapshotRepository> <site> <id>sourceforge.net</id> <name>Sourceforge.net OpenFAST Web Site</name> <url> - scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/ + scp://shell.sourceforge.net/home/groups/o/op/openfast/htdocs/ </url> </site> </distributionManagement> Modified: trunk/src/main/java/org/openfast/session/multicast/MulticastInputStream.java =================================================================== --- trunk/src/main/java/org/openfast/session/multicast/MulticastInputStream.java 2010-11-08 17:11:34 UTC (rev 230) +++ trunk/src/main/java/org/openfast/session/multicast/MulticastInputStream.java 2010-11-19 14:53:25 UTC (rev 231) @@ -27,20 +27,21 @@ import java.nio.ByteBuffer; public class MulticastInputStream extends InputStream { - private static final int BUFFER_SIZE = 256 * 1024; - private MulticastSocket socket; - private ByteBuffer buffer; + private static final int BUFFER_SIZE = 64 * 1024; + private final MulticastSocket socket; + private final ByteBuffer buffer; public MulticastInputStream(MulticastSocket socket) { this(socket, BUFFER_SIZE); } - + public MulticastInputStream(MulticastSocket socket, int bufferSize) { this.socket = socket; this.buffer = ByteBuffer.allocate(bufferSize); buffer.flip(); } + @Override public int read() throws IOException { if (socket.isClosed()) return -1; if (!buffer.hasRemaining()) { @@ -50,6 +51,6 @@ buffer.flip(); buffer.limit(packet.getLength()); } - return (int)(buffer.get() & 0xFF); + return (buffer.get() & 0xFF); } } Modified: trunk/src/main/java/org/openfast/template/type/codec/NullableByteVector.java =================================================================== --- trunk/src/main/java/org/openfast/template/type/codec/NullableByteVector.java 2010-11-08 17:11:34 UTC (rev 230) +++ trunk/src/main/java/org/openfast/template/type/codec/NullableByteVector.java 2010-11-19 14:53:25 UTC (rev 231) @@ -65,9 +65,9 @@ if (value.isNull()) return TypeCodec.NULLABLE_UNSIGNED_INTEGER.encodeValue(ScalarValue.NULL); ByteVectorValue byteVectorValue = (ByteVectorValue) value; - int lengthSize = IntegerCodec.getUnsignedIntegerSize(byteVectorValue.value.length); + byte[] length = TypeCodec.NULLABLE_UNSIGNED_INTEGER.encode(new IntegerValue(byteVectorValue.value.length)); + int lengthSize = length.length; byte[] encoding = new byte[byteVectorValue.value.length + lengthSize]; - byte[] length = TypeCodec.NULLABLE_UNSIGNED_INTEGER.encode(new IntegerValue(byteVectorValue.value.length)); System.arraycopy(length, 0, encoding, 0, lengthSize); System.arraycopy(byteVectorValue.value, 0, encoding, lengthSize, byteVectorValue.value.length); return encoding; Modified: trunk/src/test/java/org/openfast/template/type/codec/NullableUnicodeStringTest.java =================================================================== --- trunk/src/test/java/org/openfast/template/type/codec/NullableUnicodeStringTest.java 2010-11-08 17:11:34 UTC (rev 230) +++ trunk/src/test/java/org/openfast/template/type/codec/NullableUnicodeStringTest.java 2010-11-19 14:53:25 UTC (rev 231) @@ -1,15 +1,29 @@ package org.openfast.template.type.codec; -import org.openfast.template.type.codec.TypeCodec; +import java.io.ByteArrayInputStream; +import java.util.Arrays; +import org.openfast.ScalarValue; +import org.openfast.StringValue; import org.openfast.test.OpenFastTestCase; public class NullableUnicodeStringTest extends OpenFastTestCase { + public void testEncodeDecode() throws Exception { + assertEncodeDecode(string("Yo"), "10000011 01011001 01101111", TypeCodec.NULLABLE_UNICODE); + assertEncodeDecode(string("\u00f1"), "10000011 11000011 10110001", TypeCodec.NULLABLE_UNICODE); + assertEncodeDecode(string("A\u00ea\u00f1\u00fcC"), + "10001001 01000001 11000011 10101010 11000011 10110001 11000011 10111100 01000011", + TypeCodec.NULLABLE_UNICODE); + assertEncodeDecode(null, "10000000", TypeCodec.NULLABLE_UNICODE); + } - public void testEncodeDecode() throws Exception { - assertEncodeDecode(string("Yo"), "10000011 01011001 01101111", TypeCodec.NULLABLE_UNICODE); - assertEncodeDecode(string("\u00f1"), "10000011 11000011 10110001", TypeCodec.NULLABLE_UNICODE); - assertEncodeDecode(string("A\u00ea\u00f1\u00fcC"), "10001001 01000001 11000011 10101010 11000011 10110001 11000011 10111100 01000011", TypeCodec.NULLABLE_UNICODE); - assertEncodeDecode(null, "10000000", TypeCodec.NULLABLE_UNICODE); - } - + public void testEncode127ByteString() { + TypeCodec codec = new NullableUnicodeString(); + byte[] b = new byte[127]; + Arrays.fill(b, (byte)'1'); + String expected = new String(b); + byte[] bytes = codec.encode(new StringValue(expected)); + final ScalarValue value = codec.decode(new ByteArrayInputStream(bytes)); + String actual = value.toString(); + assertEquals(expected, actual); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-11-08 17:11:41
|
Revision: 230 http://openfast.svn.sourceforge.net/openfast/?rev=230&view=rev Author: gatny Date: 2010-11-08 17:11:34 +0000 (Mon, 08 Nov 2010) Log Message: ----------- Added CmeMessageBlockWriter, which writes MsgSeqNum into the first four bytes of the CME preamble. Currently, it always writes a Channel Sub ID (the fifth byte) of zero. A slight change to the writeBlockLength message signature was required to accommodate the CmeMessageBlockWriter. The CmeMessageBlockReader will now actually read the CME preamble instead of just skipping it. The producer and consumer examples now take a 'variant' argument (-z) which causes them to enable exchange-specific behavior. Currently, '-z CME' is the only supported variant. Modified Paths: -------------- trunk/src/main/java/org/openfast/MessageBlockReader.java trunk/src/main/java/org/openfast/MessageBlockWriter.java trunk/src/main/java/org/openfast/MessageOutputStream.java trunk/src/main/java/org/openfast/examples/OpenFastExample.java trunk/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java trunk/src/main/java/org/openfast/examples/consumer/Main.java trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java trunk/src/main/java/org/openfast/examples/producer/Main.java trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java trunk/src/main/java/org/openfast/impl/CmeMessageBlockReader.java trunk/src/main/java/org/openfast/session/multicast/MulticastOutputStream.java trunk/src/test/java/org/openfast/session/multicast/MulticastOutputStreamTest.java Added Paths: ----------- trunk/src/main/java/org/openfast/examples/MessageBlockReaderFactory.java trunk/src/main/java/org/openfast/examples/MessageBlockWriterFactory.java trunk/src/main/java/org/openfast/impl/CmeConstants.java trunk/src/main/java/org/openfast/impl/CmeMessageBlockWriter.java trunk/src/test/java/org/openfast/impl/ trunk/src/test/java/org/openfast/impl/CmeMessageBlockReaderWriterTest.java Modified: trunk/src/main/java/org/openfast/MessageBlockReader.java =================================================================== --- trunk/src/main/java/org/openfast/MessageBlockReader.java 2010-10-27 21:02:35 UTC (rev 229) +++ trunk/src/main/java/org/openfast/MessageBlockReader.java 2010-11-08 17:11:34 UTC (rev 230) @@ -28,7 +28,12 @@ return true; } - public void messageRead(InputStream in, Message message) {} + public void messageRead(InputStream in, Message message) { } + + @Override + public String toString() { + return "(null block reader)"; + } }; boolean readBlock(InputStream in); Modified: trunk/src/main/java/org/openfast/MessageBlockWriter.java =================================================================== --- trunk/src/main/java/org/openfast/MessageBlockWriter.java 2010-10-27 21:02:35 UTC (rev 229) +++ trunk/src/main/java/org/openfast/MessageBlockWriter.java 2010-11-08 17:11:34 UTC (rev 230) @@ -1,12 +1,14 @@ package org.openfast; +import java.io.IOException; import java.io.OutputStream; public interface MessageBlockWriter { MessageBlockWriter NULL = new MessageBlockWriter() { - public void writeBlockLength(OutputStream out, byte[] data) { - }}; + public void writeBlockLength(OutputStream out, Message message, byte[] encodedMessage) throws IOException { + } + }; - void writeBlockLength(OutputStream out, byte[] data); + void writeBlockLength(OutputStream out, Message message, byte[] encodedMessage) throws IOException; } Modified: trunk/src/main/java/org/openfast/MessageOutputStream.java =================================================================== --- trunk/src/main/java/org/openfast/MessageOutputStream.java 2010-10-27 21:02:35 UTC (rev 229) +++ trunk/src/main/java/org/openfast/MessageOutputStream.java 2010-11-08 17:11:34 UTC (rev 230) @@ -61,7 +61,7 @@ if ((data == null) || (data.length == 0)) { return; } - blockWriter.writeBlockLength(out, data); + blockWriter.writeBlockLength(out, message, data); out.write(data); if (flush) out.flush(); Added: trunk/src/main/java/org/openfast/examples/MessageBlockReaderFactory.java =================================================================== --- trunk/src/main/java/org/openfast/examples/MessageBlockReaderFactory.java (rev 0) +++ trunk/src/main/java/org/openfast/examples/MessageBlockReaderFactory.java 2010-11-08 17:11:34 UTC (rev 230) @@ -0,0 +1,54 @@ +package org.openfast.examples; + +import java.io.InputStream; +import java.io.IOException; +import org.openfast.Message; +import org.openfast.MessageBlockReader; +import org.openfast.examples.OpenFastExample.Variant; +import org.openfast.impl.*; + +public class MessageBlockReaderFactory { + final Variant variant; + final int offset; + + public MessageBlockReaderFactory() { + this(Variant.DEFAULT, 0); + } + + public MessageBlockReaderFactory(final Variant variant, final int offset) { + this.variant = variant; + this.offset = offset; + } + + public MessageBlockReader create() { + switch(variant) { + case CME: + return new CmeMessageBlockReader(); + + case DEFAULT: + default: + return createDefault(); + } + } + + MessageBlockReader createDefault() { + if(offset <= 0) + return MessageBlockReader.NULL; + + return new MessageBlockReader() { + public void messageRead(InputStream in, Message message) { } + public boolean readBlock(InputStream in) { + try { + in.skip(offset); + return true; + } catch (IOException e) { + e.printStackTrace(); + return false; + } + } + @Override public String toString() { + return "(default block reader, offset=" + offset + ")"; + } + }; + } +} Added: trunk/src/main/java/org/openfast/examples/MessageBlockWriterFactory.java =================================================================== --- trunk/src/main/java/org/openfast/examples/MessageBlockWriterFactory.java (rev 0) +++ trunk/src/main/java/org/openfast/examples/MessageBlockWriterFactory.java 2010-11-08 17:11:34 UTC (rev 230) @@ -0,0 +1,49 @@ +package org.openfast.examples; + +import java.io.OutputStream; +import java.io.IOException; +import org.openfast.Message; +import org.openfast.MessageBlockWriter; +import org.openfast.examples.OpenFastExample.Variant; +import org.openfast.impl.*; + +public class MessageBlockWriterFactory { + final Variant variant; + final int offset; + + public MessageBlockWriterFactory() { + this(Variant.DEFAULT, 0); + } + + public MessageBlockWriterFactory(final Variant variant, final int offset) { + this.variant = variant; + this.offset = offset; + } + + public MessageBlockWriter create() { + switch(variant) { + case CME: + return new CmeMessageBlockWriter(); + + case DEFAULT: + default: + return createDefault(); + } + } + + MessageBlockWriter createDefault() { + if(offset <= 0) + return MessageBlockWriter.NULL; + + return new MessageBlockWriter() { + final byte[] PREAMBLE = new byte[offset]; + public void writeBlockLength(OutputStream out, Message message, byte[] data) throws IOException { + try { + out.write(PREAMBLE); + } + catch(final IOException e) { + } + } + }; + } +} Modified: trunk/src/main/java/org/openfast/examples/OpenFastExample.java =================================================================== --- trunk/src/main/java/org/openfast/examples/OpenFastExample.java 2010-10-27 21:02:35 UTC (rev 229) +++ trunk/src/main/java/org/openfast/examples/OpenFastExample.java 2010-11-08 17:11:34 UTC (rev 230) @@ -22,9 +22,13 @@ protected static final String XML_DATA_FILE = "xml"; protected static final String READ_OFFSET = "readOffset"; protected static final String WRITE_OFFSET = "writeOffset"; + protected static final String VARIANT = "variant"; protected static final String READ_OFFSET_DESCRIPTION = "The number of leading bytes that should be discarded when reading each message."; protected static final String WRITE_OFFSET_DESCRIPTION = "The number of leading bytes that should be appended as padding when sending each message."; + protected static final String VARIANT_DESCRIPTION = "Enable exchange-specific behavior. Valid values: CME"; + public enum Variant { DEFAULT, CME } + protected static CommandLine parseCommandLine(String name, String[] args, Options options) { try { BasicParser parser = new BasicParser(); @@ -56,4 +60,21 @@ File file = new File(cl.getOptionValue(option)); return file; } + + protected static Variant getVariant(CommandLine cl) { + Assert.assertTrue(cl.hasOption(VARIANT), "The required parameter \"" + VARIANT + "\" is missing."); + String optarg = cl.getOptionValue(VARIANT); + try { + return getVariant(optarg); + } + catch(final RuntimeException e) { + System.err.println("Invalid " + VARIANT + " argument: " + optarg); + System.exit(1); + } + return null; + } + + protected static Variant getVariant(String value) { + return Enum.valueOf(Variant.class, value); + } } Modified: trunk/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java =================================================================== --- trunk/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java 2010-10-27 21:02:35 UTC (rev 229) +++ trunk/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java 2010-11-08 17:11:34 UTC (rev 230) @@ -6,6 +6,8 @@ import java.io.IOException; import org.openfast.Context; import org.openfast.Message; +import org.openfast.MessageInputStream; +import org.openfast.MessageBlockReader; import org.openfast.error.FastException; import org.openfast.codec.FastDecoder; import org.openfast.session.Connection; @@ -13,17 +15,18 @@ import org.openfast.session.FastConnectionException; import org.openfast.template.TemplateRegistry; import org.openfast.template.loader.XMLMessageTemplateLoader; +import org.openfast.examples.MessageBlockReaderFactory; public class FastMessageConsumer { private final Endpoint endpoint; private final TemplateRegistry templateRegistry; - private final int readOffset; + protected final MessageBlockReaderFactory messageBlockReaderFactory; public FastMessageConsumer(Endpoint endpoint, File templatesFile) { - this(endpoint, templatesFile, 0); + this(endpoint, templatesFile, new MessageBlockReaderFactory()); } - public FastMessageConsumer(Endpoint endpoint, File templatesFile, int readOffset) { + public FastMessageConsumer(Endpoint endpoint, File templatesFile, MessageBlockReaderFactory messageBlockReaderFactory) { this.endpoint = endpoint; XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader(); loader.setLoadTemplateIdFromAuxId(true); @@ -33,23 +36,25 @@ throw new RuntimeException(e.getMessage(), e); } this.templateRegistry = loader.getTemplateRegistry(); - this.readOffset = readOffset; + this.messageBlockReaderFactory = messageBlockReaderFactory; } public void start() throws FastConnectionException, IOException { final Connection connection = endpoint.connect(); Context context = new Context(); context.setTemplateRegistry(templateRegistry); - FastDecoder decoder = new FastDecoder(context, connection.getInputStream()); - Runtime.getRuntime().addShutdownHook(new Thread() { + MessageInputStream msgInStream = new MessageInputStream(connection.getInputStream(), context); + MessageBlockReader msgBlockReader = messageBlockReaderFactory.create(); + msgInStream.setBlockReader(msgBlockReader); + Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { connection.close(); } }); while (true) { try { - Message message = decoder.readMessage(readOffset); - System.out.println(message.toString()); + Message message = msgInStream.readMessage(); + System.out.println(msgBlockReader.toString() + ' ' + message.toString()); } catch(final FastException e) { System.err.println(e.getMessage()); Modified: trunk/src/main/java/org/openfast/examples/consumer/Main.java =================================================================== --- trunk/src/main/java/org/openfast/examples/consumer/Main.java 2010-10-27 21:02:35 UTC (rev 229) +++ trunk/src/main/java/org/openfast/examples/consumer/Main.java 2010-11-08 17:11:34 UTC (rev 230) @@ -6,6 +6,7 @@ import org.apache.commons.cli.Options; import org.openfast.examples.Assert; import org.openfast.examples.OpenFastExample; +import org.openfast.examples.MessageBlockReaderFactory; import org.openfast.session.Endpoint; import org.openfast.session.FastConnectionException; import org.openfast.session.multicast.MulticastEndpoint; @@ -24,6 +25,7 @@ options.addOption("e", ERROR, false, "Show stacktrace information"); options.addOption("t", MESSAGE_TEMPLATE_FILE, true, "Message template definition file"); options.addOption("j", READ_OFFSET, true, READ_OFFSET_DESCRIPTION); + options.addOption("z", VARIANT, true, VARIANT_DESCRIPTION); } /** @@ -62,7 +64,9 @@ final int readOffset = cl.hasOption(READ_OFFSET) ? getInteger(cl, READ_OFFSET) : 0; - FastMessageConsumer consumer = new FastMessageConsumer(endpoint, templatesFile, readOffset); + final Variant variant = cl.hasOption(VARIANT) ? getVariant(cl) : Variant.DEFAULT; + final MessageBlockReaderFactory msgBlockReaderFactory = new MessageBlockReaderFactory(variant, readOffset); + FastMessageConsumer consumer = new FastMessageConsumer(endpoint, templatesFile, msgBlockReaderFactory); try { consumer.start(); Modified: trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2010-10-27 21:02:35 UTC (rev 229) +++ trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2010-11-08 17:11:34 UTC (rev 230) @@ -20,6 +20,7 @@ import org.openfast.session.FastConnectionException; import org.openfast.template.TemplateRegistry; import org.openfast.template.loader.XMLMessageTemplateLoader; +import org.openfast.examples.MessageBlockWriterFactory; public class FastMessageProducer implements ConnectionListener { protected final Endpoint endpoint; @@ -27,13 +28,13 @@ protected Thread acceptThread; protected List connections = new ArrayList(); protected XmlCompressedMessageConverter converter = new XmlCompressedMessageConverter(); - protected final int writeOffset; + protected final MessageBlockWriterFactory messageBlockWriterFactory; public FastMessageProducer(Endpoint endpoint, File templatesFile) { - this(endpoint, templatesFile, 0); + this(endpoint, templatesFile, new MessageBlockWriterFactory()); } - public FastMessageProducer(Endpoint endpoint, File templatesFile, int writeOffset) { + public FastMessageProducer(Endpoint endpoint, File templatesFile, MessageBlockWriterFactory messageBlockWriterFactory) { Global.setErrorHandler(ErrorHandler.NULL); this.endpoint = endpoint; XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader(); @@ -45,25 +46,9 @@ } this.templateRegistry = loader.getTemplateRegistry(); this.converter.setTemplateRegistry(this.templateRegistry); - this.writeOffset = writeOffset; + this.messageBlockWriterFactory = messageBlockWriterFactory; } - public static MessageBlockWriter createMessageBlockWriter(final int offset) { - if(offset <= 0) - return MessageBlockWriter.NULL; - - return new MessageBlockWriter() { - final byte[] PREAMBLE = new byte[offset]; - public void writeBlockLength(OutputStream out, byte[] data) { - try { - out.write(PREAMBLE); - } - catch(final IOException e) { - } - } - }; - } - public void encode(File xmlDataFile) throws FastConnectionException, IOException { encode(new FileInputStream(xmlDataFile), true); } @@ -125,7 +110,7 @@ context.setTemplateRegistry(templateRegistry); try { MessageOutputStream out = new MessageOutputStream(connection.getOutputStream(), context); - out.setBlockWriter(createMessageBlockWriter(writeOffset)); + out.setBlockWriter(messageBlockWriterFactory.create()); connections.add(out); } catch (IOException e) { e.printStackTrace(); Modified: trunk/src/main/java/org/openfast/examples/producer/Main.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/Main.java 2010-10-27 21:02:35 UTC (rev 229) +++ trunk/src/main/java/org/openfast/examples/producer/Main.java 2010-11-08 17:11:34 UTC (rev 230) @@ -6,6 +6,7 @@ import org.apache.commons.cli.Options; import org.openfast.examples.Assert; import org.openfast.examples.OpenFastExample; +import org.openfast.examples.MessageBlockWriterFactory; import org.openfast.session.FastConnectionException; import org.openfast.session.Endpoint; import org.openfast.session.tcp.TcpEndpoint; @@ -24,6 +25,7 @@ options.addOption("t", MESSAGE_TEMPLATE_FILE, true, "Message template definition file"); options.addOption("x", XML_DATA_FILE, true, "The XML data to convert to FAST"); options.addOption("k", WRITE_OFFSET, true, WRITE_OFFSET_DESCRIPTION); + options.addOption("z", VARIANT, true, VARIANT_DESCRIPTION); } public static boolean isMulticast(CommandLine cl) { @@ -74,9 +76,12 @@ try { final int writeOffset = cl.hasOption(WRITE_OFFSET) ? getInteger(cl, WRITE_OFFSET) : 0; + final Variant variant = cl.hasOption(VARIANT) ? getVariant(cl) : Variant.DEFAULT; + final MessageBlockWriterFactory msgBlockWriterFactory = new MessageBlockWriterFactory(variant, writeOffset); + FastMessageProducer producer = isMulticast(cl) - ? new MulticastFastMessageProducer(endpoint, templatesFile, writeOffset) - : new FastMessageProducer(endpoint, templatesFile, writeOffset); + ? new MulticastFastMessageProducer(endpoint, templatesFile, msgBlockWriterFactory) + : new FastMessageProducer(endpoint, templatesFile, msgBlockWriterFactory); producer.start(); producer.encode(xmlDataFile); Modified: trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java 2010-10-27 21:02:35 UTC (rev 229) +++ trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java 2010-11-08 17:11:34 UTC (rev 230) @@ -13,21 +13,22 @@ import org.openfast.session.FastConnectionException; import org.openfast.template.TemplateRegistry; import org.openfast.template.loader.XMLMessageTemplateLoader; +import org.openfast.examples.MessageBlockWriterFactory; public class MulticastFastMessageProducer extends FastMessageProducer { private MessageOutputStream out; public MulticastFastMessageProducer(Endpoint endpoint, File templatesFile) throws IOException, FastConnectionException { - this(endpoint, templatesFile, 0); + this(endpoint, templatesFile, new MessageBlockWriterFactory()); } - public MulticastFastMessageProducer(Endpoint endpoint, File templatesFile, int writeOffset) throws IOException, FastConnectionException { - super(endpoint, templatesFile, writeOffset); + public MulticastFastMessageProducer(Endpoint endpoint, File templatesFile, MessageBlockWriterFactory messageBlockWriterFactory) throws IOException, FastConnectionException { + super(endpoint, templatesFile, messageBlockWriterFactory); Context context = new Context(); context.setErrorHandler(ErrorHandler.NULL); context.setTemplateRegistry(templateRegistry); out = new MessageOutputStream(endpoint.connect().getOutputStream(), context); - out.setBlockWriter(FastMessageProducer.createMessageBlockWriter(writeOffset)); + out.setBlockWriter(messageBlockWriterFactory.create()); } protected void publish(List messages, List msgOutputStreams) { Added: trunk/src/main/java/org/openfast/impl/CmeConstants.java =================================================================== --- trunk/src/main/java/org/openfast/impl/CmeConstants.java (rev 0) +++ trunk/src/main/java/org/openfast/impl/CmeConstants.java 2010-11-08 17:11:34 UTC (rev 230) @@ -0,0 +1,7 @@ +package org.openfast.impl; + +public class CmeConstants { + final static int PREAMBLE_LEN = 5; + final static long PREAMBLE_SEQ_NUM_MAX = 4294967295L; + final static short PREAMBLE_SUB_ID_MAX = 127; +} Modified: trunk/src/main/java/org/openfast/impl/CmeMessageBlockReader.java =================================================================== --- trunk/src/main/java/org/openfast/impl/CmeMessageBlockReader.java 2010-10-27 21:02:35 UTC (rev 229) +++ trunk/src/main/java/org/openfast/impl/CmeMessageBlockReader.java 2010-11-08 17:11:34 UTC (rev 230) @@ -6,19 +6,49 @@ import org.openfast.MessageBlockReader; public class CmeMessageBlockReader implements MessageBlockReader { - public void messageRead(InputStream in, Message message) { - } + byte[] data = new byte[CmeConstants.PREAMBLE_LEN]; + int[] convertedBytes = new int[CmeConstants.PREAMBLE_LEN]; + long lastSeqNum; + int lastSubId; - public boolean readBlock(InputStream in) { - try { - in.read(); - in.read(); - in.read(); - in.read(); - in.read(); - return true; - } catch (IOException e) { - return false; - } - } + public void messageRead(InputStream in, Message message) { + } + + public boolean readBlock(InputStream in) { + try { + if(in.read(data) == -1) + return false; + readBlock(data); + return true; + } + catch(final IOException e) { + return false; + } + } + + void readBlock(byte[] data) { + convertedBytes[0] = (0x000000FF & ((int)data[0])); + convertedBytes[1] = (0x000000FF & ((int)data[1])); + convertedBytes[2] = (0x000000FF & ((int)data[2])); + convertedBytes[3] = (0x000000FF & ((int)data[3])); + lastSeqNum = ((long)(convertedBytes[0] << 24 + | convertedBytes[1] << 16 + | convertedBytes[2] << 8 + | convertedBytes[3])) & 0xFFFFFFFFL; + + lastSubId = data[4]; + } + + public long getLastSeqNum() { + return lastSeqNum; + } + + public long getLastSubId() { + return lastSubId; + } + + @Override + public String toString() { + return "(" + lastSeqNum + "|" + lastSubId + ")"; + } } Added: trunk/src/main/java/org/openfast/impl/CmeMessageBlockWriter.java =================================================================== --- trunk/src/main/java/org/openfast/impl/CmeMessageBlockWriter.java (rev 0) +++ trunk/src/main/java/org/openfast/impl/CmeMessageBlockWriter.java 2010-11-08 17:11:34 UTC (rev 230) @@ -0,0 +1,31 @@ +package org.openfast.impl; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.DataOutputStream; +import org.openfast.Message; +import org.openfast.MessageBlockWriter; + +/** + * Write the CME preamble. The sub-channel identifier (the fifth byte) is always (int)0. + */ +public class CmeMessageBlockWriter implements MessageBlockWriter { + byte[] data = new byte[CmeConstants.PREAMBLE_LEN]; + + /** Note: the CME Channel Sub ID (the fifth byte of the preamble) will always be zero. */ + public void writeBlockLength(OutputStream out, Message message, byte[] encodedMessage) throws IOException { + out.write(writeBlockLength(data, message.getLong("MsgSeqNum"), 0)); + } + + /** Write seqNum and subId to data and return data. */ + final static byte[] writeBlockLength(byte[] data, final long seqNum, final int subId) { + data[0] = (byte)((seqNum & 0xFF000000L) >> 24); + data[1] = (byte)((seqNum & 0x00FF0000L) >> 16); + data[2] = (byte)((seqNum & 0x0000FF00L) >> 8); + data[3] = (byte)(seqNum & 0x000000FFL); + data[4] = (byte)subId; + return data; + } + +} Modified: trunk/src/main/java/org/openfast/session/multicast/MulticastOutputStream.java =================================================================== --- trunk/src/main/java/org/openfast/session/multicast/MulticastOutputStream.java 2010-10-27 21:02:35 UTC (rev 229) +++ trunk/src/main/java/org/openfast/session/multicast/MulticastOutputStream.java 2010-11-08 17:11:34 UTC (rev 230) @@ -68,6 +68,6 @@ } public void write(int b) { - throw new UnsupportedOperationException(); + writeBuffer.put((byte)b); } } Added: trunk/src/test/java/org/openfast/impl/CmeMessageBlockReaderWriterTest.java =================================================================== --- trunk/src/test/java/org/openfast/impl/CmeMessageBlockReaderWriterTest.java (rev 0) +++ trunk/src/test/java/org/openfast/impl/CmeMessageBlockReaderWriterTest.java 2010-11-08 17:11:34 UTC (rev 230) @@ -0,0 +1,90 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.1 (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.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +License for the specific language governing rights and limitations +under the License. + +The Original Code is OpenFAST. + +The Initial Developer of the Original Code is The LaSalle Technology +Group, LLC. Portions created by The LaSalle Technology Group, LLC +are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. + +Contributor(s): Jacob Northey <ja...@la...> + Craig Otis <co...@la...> +*/ + + +package org.openfast.impl; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Deque; +import java.util.LinkedList; +import junit.framework.TestCase; + +public class CmeMessageBlockReaderWriterTest extends TestCase { + CmeMessageBlockReader reader; + byte[] data; + + void writeAndThenRead(final long seqNum, final int subId) { + CmeMessageBlockWriter.writeBlockLength(data, seqNum, subId); + reader.readBlock(data); + } + + public void setUp() { + reader = new CmeMessageBlockReader(); + data = new byte[CmeConstants.PREAMBLE_LEN]; + } + + public void testReadWrite() { + long seqNum; + int subId; + + seqNum = 1294967294L; + subId = 13; + writeAndThenRead(seqNum, subId); + assertEquals(seqNum, reader.getLastSeqNum()); + assertEquals(subId, reader.getLastSubId()); + + seqNum = 2147483648L; + subId = 111; + writeAndThenRead(seqNum, subId); + assertEquals(seqNum, reader.getLastSeqNum()); + assertEquals(subId, reader.getLastSubId()); + + seqNum = 1073741824L; + subId = 42; + writeAndThenRead(seqNum, subId); + assertEquals(seqNum, reader.getLastSeqNum()); + assertEquals(subId, reader.getLastSubId()); + } + + public void testReadWriteZeroes() { + writeAndThenRead(0, 0); + assertEquals(0, reader.getLastSeqNum()); + assertEquals(0, reader.getLastSubId()); + } + + public void testReadWriteMaxValidValues() { + final long seqNum = CmeConstants.PREAMBLE_SEQ_NUM_MAX; + final int subId = CmeConstants.PREAMBLE_SUB_ID_MAX; + writeAndThenRead(seqNum, subId); + assertTrue(reader.getLastSeqNum() == seqNum); + assertTrue(reader.getLastSubId() == subId); + } + + public void testReadWriteOverflow() { + final long seqNum = CmeConstants.PREAMBLE_SEQ_NUM_MAX + 1; + final int subId = CmeConstants.PREAMBLE_SUB_ID_MAX + 1; + writeAndThenRead(seqNum, subId); + assertTrue(reader.getLastSeqNum() != seqNum); + assertTrue(reader.getLastSubId() != subId); + } +} + Modified: trunk/src/test/java/org/openfast/session/multicast/MulticastOutputStreamTest.java =================================================================== --- trunk/src/test/java/org/openfast/session/multicast/MulticastOutputStreamTest.java 2010-10-27 21:02:35 UTC (rev 229) +++ trunk/src/test/java/org/openfast/session/multicast/MulticastOutputStreamTest.java 2010-11-08 17:11:34 UTC (rev 230) @@ -100,13 +100,23 @@ assertPacketEquals(MESSAGE_C, (DatagramPacket)socket.packetsSent.removeFirst()); } - public void testWriteSingleByteNotSupported() { - try { - multicastOutputStream.write('X'); - fail("Expected write of single byte to cause exception, but none was thrown."); - } - catch(final UnsupportedOperationException e) { - } - } + public void testWriteSingleByte() { + for(byte b : MESSAGE_C) + multicastOutputStream.write(b); + multicastOutputStream.flush(); + + for(byte b : MESSAGE_B) + multicastOutputStream.write(b); + multicastOutputStream.flush(); + + for(byte b : MESSAGE_A) + multicastOutputStream.write(b); + multicastOutputStream.flush(); + + System.out.println(socket); + assertPacketEquals(MESSAGE_C, (DatagramPacket)socket.packetsSent.removeFirst()); + assertPacketEquals(MESSAGE_B, (DatagramPacket)socket.packetsSent.removeFirst()); + assertPacketEquals(MESSAGE_A, (DatagramPacket)socket.packetsSent.removeFirst()); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-10-27 21:02:41
|
Revision: 229 http://openfast.svn.sourceforge.net/openfast/?rev=229&view=rev Author: gatny Date: 2010-10-27 21:02:35 +0000 (Wed, 27 Oct 2010) Log Message: ----------- Allow specifying a write offset in the producer example (e.g. to mimic CME). The MulticastOutputStream now sends the datagram when you call flush() instead of when you call write(). Modified Paths: -------------- trunk/src/main/java/org/openfast/examples/OpenFastExample.java trunk/src/main/java/org/openfast/examples/consumer/Main.java trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java trunk/src/main/java/org/openfast/examples/producer/Main.java trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java trunk/src/main/java/org/openfast/session/multicast/MulticastOutputStream.java trunk/src/test/java/org/openfast/session/multicast/MulticastOutputStreamTest.java Modified: trunk/src/main/java/org/openfast/examples/OpenFastExample.java =================================================================== --- trunk/src/main/java/org/openfast/examples/OpenFastExample.java 2010-10-26 19:00:22 UTC (rev 228) +++ trunk/src/main/java/org/openfast/examples/OpenFastExample.java 2010-10-27 21:02:35 UTC (rev 229) @@ -21,7 +21,9 @@ protected static final String FAST_DATA_FILE = "data"; protected static final String XML_DATA_FILE = "xml"; protected static final String READ_OFFSET = "readOffset"; + protected static final String WRITE_OFFSET = "writeOffset"; protected static final String READ_OFFSET_DESCRIPTION = "The number of leading bytes that should be discarded when reading each message."; + protected static final String WRITE_OFFSET_DESCRIPTION = "The number of leading bytes that should be appended as padding when sending each message."; protected static CommandLine parseCommandLine(String name, String[] args, Options options) { try { Modified: trunk/src/main/java/org/openfast/examples/consumer/Main.java =================================================================== --- trunk/src/main/java/org/openfast/examples/consumer/Main.java 2010-10-26 19:00:22 UTC (rev 228) +++ trunk/src/main/java/org/openfast/examples/consumer/Main.java 2010-10-27 21:02:35 UTC (rev 229) @@ -23,7 +23,7 @@ options.addOption("i", INTERFACE, true, "The ip address of the network interface to use"); options.addOption("e", ERROR, false, "Show stacktrace information"); options.addOption("t", MESSAGE_TEMPLATE_FILE, true, "Message template definition file"); - options.addOption("j", READ_OFFSET, true, "The number of leading bytes that should be discarded when reading each message."); + options.addOption("j", READ_OFFSET, true, READ_OFFSET_DESCRIPTION); } /** Modified: trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2010-10-26 19:00:22 UTC (rev 228) +++ trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2010-10-27 21:02:35 UTC (rev 229) @@ -2,6 +2,7 @@ import java.io.File; import java.io.InputStream; +import java.io.OutputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; @@ -10,6 +11,7 @@ import org.openfast.Context; import org.openfast.Global; import org.openfast.Message; +import org.openfast.MessageBlockWriter; import org.openfast.MessageOutputStream; import org.openfast.error.ErrorHandler; import org.openfast.session.Connection; @@ -25,8 +27,13 @@ protected Thread acceptThread; protected List connections = new ArrayList(); protected XmlCompressedMessageConverter converter = new XmlCompressedMessageConverter(); + protected final int writeOffset; public FastMessageProducer(Endpoint endpoint, File templatesFile) { + this(endpoint, templatesFile, 0); + } + + public FastMessageProducer(Endpoint endpoint, File templatesFile, int writeOffset) { Global.setErrorHandler(ErrorHandler.NULL); this.endpoint = endpoint; XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader(); @@ -38,8 +45,25 @@ } this.templateRegistry = loader.getTemplateRegistry(); this.converter.setTemplateRegistry(this.templateRegistry); - } + this.writeOffset = writeOffset; + } + public static MessageBlockWriter createMessageBlockWriter(final int offset) { + if(offset <= 0) + return MessageBlockWriter.NULL; + + return new MessageBlockWriter() { + final byte[] PREAMBLE = new byte[offset]; + public void writeBlockLength(OutputStream out, byte[] data) { + try { + out.write(PREAMBLE); + } + catch(final IOException e) { + } + } + }; + } + public void encode(File xmlDataFile) throws FastConnectionException, IOException { encode(new FileInputStream(xmlDataFile), true); } @@ -101,7 +125,8 @@ context.setTemplateRegistry(templateRegistry); try { MessageOutputStream out = new MessageOutputStream(connection.getOutputStream(), context); - connections.add(out); + out.setBlockWriter(createMessageBlockWriter(writeOffset)); + connections.add(out); } catch (IOException e) { e.printStackTrace(); } Modified: trunk/src/main/java/org/openfast/examples/producer/Main.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/Main.java 2010-10-26 19:00:22 UTC (rev 228) +++ trunk/src/main/java/org/openfast/examples/producer/Main.java 2010-10-27 21:02:35 UTC (rev 229) @@ -23,6 +23,7 @@ options.addOption("e", ERROR, false, "Show stacktrace information"); options.addOption("t", MESSAGE_TEMPLATE_FILE, true, "Message template definition file"); options.addOption("x", XML_DATA_FILE, true, "The XML data to convert to FAST"); + options.addOption("k", WRITE_OFFSET, true, WRITE_OFFSET_DESCRIPTION); } public static boolean isMulticast(CommandLine cl) { @@ -72,9 +73,10 @@ } try { - FastMessageProducer producer = isMulticast(cl) - ? new MulticastFastMessageProducer(endpoint, templatesFile) - : new FastMessageProducer(endpoint, templatesFile); + final int writeOffset = cl.hasOption(WRITE_OFFSET) ? getInteger(cl, WRITE_OFFSET) : 0; + FastMessageProducer producer = isMulticast(cl) + ? new MulticastFastMessageProducer(endpoint, templatesFile, writeOffset) + : new FastMessageProducer(endpoint, templatesFile, writeOffset); producer.start(); producer.encode(xmlDataFile); Modified: trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java 2010-10-26 19:00:22 UTC (rev 228) +++ trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java 2010-10-27 21:02:35 UTC (rev 229) @@ -5,6 +5,7 @@ import java.util.List; import org.openfast.Context; import org.openfast.Message; +import org.openfast.MessageBlockWriter; import org.openfast.MessageOutputStream; import org.openfast.error.ErrorHandler; import org.openfast.session.Connection; @@ -17,19 +18,24 @@ private MessageOutputStream out; public MulticastFastMessageProducer(Endpoint endpoint, File templatesFile) throws IOException, FastConnectionException { - super(endpoint, templatesFile); + this(endpoint, templatesFile, 0); + } + + public MulticastFastMessageProducer(Endpoint endpoint, File templatesFile, int writeOffset) throws IOException, FastConnectionException { + super(endpoint, templatesFile, writeOffset); Context context = new Context(); context.setErrorHandler(ErrorHandler.NULL); context.setTemplateRegistry(templateRegistry); out = new MessageOutputStream(endpoint.connect().getOutputStream(), context); - } + out.setBlockWriter(FastMessageProducer.createMessageBlockWriter(writeOffset)); + } protected void publish(List messages, List msgOutputStreams) { if(out == null) { return; } for(int i = 0; i < messages.size(); ++i) { - out.writeMessage((Message)messages.get(i)); + out.writeMessage((Message)messages.get(i), true); } out.reset(); } Modified: trunk/src/main/java/org/openfast/session/multicast/MulticastOutputStream.java =================================================================== --- trunk/src/main/java/org/openfast/session/multicast/MulticastOutputStream.java 2010-10-26 19:00:22 UTC (rev 228) +++ trunk/src/main/java/org/openfast/session/multicast/MulticastOutputStream.java 2010-10-27 21:02:35 UTC (rev 229) @@ -22,33 +22,46 @@ import java.io.IOException; import java.io.OutputStream; +import java.nio.ByteBuffer; import java.net.DatagramPacket; import java.net.InetAddress; import java.net.MulticastSocket; public class MulticastOutputStream extends OutputStream { + public final static int BUFFER_SIZE = 2048; private MulticastSocket socket; private InetAddress group; private int port; - private DatagramPacket datagramPacket; + private byte[] packetBuffer; + private ByteBuffer writeBuffer; public MulticastOutputStream(MulticastSocket socket, int port, InetAddress group) { this.socket = socket; this.group = group; this.port = port; + packetBuffer = new byte[BUFFER_SIZE]; + writeBuffer = ByteBuffer.allocate(BUFFER_SIZE); + writeBuffer.clear(); } - - public void write(byte[] b, int off, int len) { - if(off != 0 || len != b.length) - throw new UnsupportedOperationException(); - try { - socket.send(new DatagramPacket(b, len, group, port)); - } - catch(final IOException e) { - e.printStackTrace(); - } - } + public void flush() { + writeBuffer.flip(); + if(writeBuffer.hasRemaining()) { + try { + byte[] data = new byte[writeBuffer.remaining()]; + writeBuffer.get(data); + socket.send(new DatagramPacket(data, data.length, group, port)); + } + catch(final IOException e) { + e.printStackTrace(); + } + } + writeBuffer.clear(); + } + + public void write(byte[] b, int off, int len) { + writeBuffer.put(b, off, len); + } public void write(byte[] b) { write(b, 0, b.length); Modified: trunk/src/test/java/org/openfast/session/multicast/MulticastOutputStreamTest.java =================================================================== --- trunk/src/test/java/org/openfast/session/multicast/MulticastOutputStreamTest.java 2010-10-26 19:00:22 UTC (rev 228) +++ trunk/src/test/java/org/openfast/session/multicast/MulticastOutputStreamTest.java 2010-10-27 21:02:35 UTC (rev 229) @@ -48,13 +48,24 @@ } public void send(DatagramPacket packet) throws IOException { - packetsSent.push(packet); + packetsSent.addLast(packet); } + + public String toString() { + StringBuffer msg = new StringBuffer("\nPackets Sent {"); + for(Object ix: packetsSent) { + final DatagramPacket packet = (DatagramPacket)ix; + msg.append("\n ").append(new String(Arrays.copyOf(packet.getData(), packet.getLength()))); + } + msg.append("\n}"); + return msg.toString(); + } } - public static void assertPacketEquals(byte[] expected, DatagramPacket actual) { - final String msg = "Expected '" + new String(expected) + "', but was '" + new String(actual.getData()) + "'"; - assertTrue(msg, Arrays.equals(expected, actual.getData())); + public void assertPacketEquals(byte[] expected, DatagramPacket actual) { + final byte[] actualData = Arrays.copyOf(actual.getData(), actual.getLength()); + final String msg = "Expected '" + new String(expected) + "', but was '" + new String(actualData) + "'"; + assertTrue(msg, Arrays.equals(expected, actualData)); } public void setUp() throws Exception { @@ -64,15 +75,31 @@ multicastOutputStream = new MulticastOutputStream(socket, port, group); } - public void testWrite() { + public void testYouMustCallFlushToCauseDatagramToBeSent() { multicastOutputStream.write(MESSAGE_A); - multicastOutputStream.write(MESSAGE_B); - multicastOutputStream.write(MESSAGE_C); - assertPacketEquals(MESSAGE_A, (DatagramPacket)socket.packetsSent.removeLast()); - assertPacketEquals(MESSAGE_B, (DatagramPacket)socket.packetsSent.removeLast()); - assertPacketEquals(MESSAGE_C, (DatagramPacket)socket.packetsSent.removeLast()); + assertEquals(0, socket.packetsSent.size()); + multicastOutputStream.flush(); + + System.out.println(socket); + assertPacketEquals(MESSAGE_A, (DatagramPacket)socket.packetsSent.removeFirst()); } + public void testWrite() { + multicastOutputStream.write(MESSAGE_A); + multicastOutputStream.flush(); + + multicastOutputStream.write(MESSAGE_B); + multicastOutputStream.flush(); + + multicastOutputStream.write(MESSAGE_C); + multicastOutputStream.flush(); + + System.out.println(socket); + assertPacketEquals(MESSAGE_A, (DatagramPacket)socket.packetsSent.removeFirst()); + assertPacketEquals(MESSAGE_B, (DatagramPacket)socket.packetsSent.removeFirst()); + assertPacketEquals(MESSAGE_C, (DatagramPacket)socket.packetsSent.removeFirst()); + } + public void testWriteSingleByteNotSupported() { try { multicastOutputStream.write('X'); @@ -81,32 +108,5 @@ catch(final UnsupportedOperationException e) { } } - - public void testWriteOffsetMustEqualZeroAndLengthMustEqualDataLength() throws UnsupportedOperationException { - multicastOutputStream.write(MESSAGE_A, 0, MESSAGE_A.length); // offset and length OK - multicastOutputStream.write(MESSAGE_B, 0, MESSAGE_B.length); // offset and length OK - multicastOutputStream.write(MESSAGE_C, 0, MESSAGE_C.length); // offset and length OK - - try { - multicastOutputStream.write(MESSAGE_A, 1, MESSAGE_A.length); - fail("Expected illegal offset to cause exception, but none was thrown."); - } - catch(final UnsupportedOperationException e) { - } - - try { - multicastOutputStream.write(MESSAGE_A, 0, MESSAGE_A.length - 1); - fail("Expected illegal length to cause exception, but none was thrown."); - } - catch(final UnsupportedOperationException e) { - } - - try { - multicastOutputStream.write(MESSAGE_A, 0, MESSAGE_A.length + 1); - fail("Expected illegal length to cause exception, but none was thrown."); - } - catch(final UnsupportedOperationException e) { - } - } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-10-26 19:00:30
|
Revision: 228 http://openfast.svn.sourceforge.net/openfast/?rev=228&view=rev Author: gatny Date: 2010-10-26 19:00:22 +0000 (Tue, 26 Oct 2010) Log Message: ----------- allow single shot instead of looping forever Modified Paths: -------------- trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java Modified: trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2010-10-26 17:07:12 UTC (rev 227) +++ trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2010-10-26 19:00:22 UTC (rev 228) @@ -41,12 +41,19 @@ } public void encode(File xmlDataFile) throws FastConnectionException, IOException { - encode(new FileInputStream(xmlDataFile)); + encode(new FileInputStream(xmlDataFile), true); } public void encode(InputStream xmlData) throws FastConnectionException, IOException { + encode(xmlData, true); + } + + public void encode(InputStream xmlData, boolean loopForever) throws FastConnectionException, IOException { List messages = converter.parse(xmlData); - while (true) { + if(messages == null) + throw new IllegalArgumentException("The XML data stream contains no FAST messages!"); + + do { publish(messages, connections); try { Thread.sleep(1000); @@ -54,6 +61,7 @@ catch (InterruptedException e) { } } + while(loopForever); } protected void publish(List messages, List msgOutputStreams) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-10-26 17:07:20
|
Revision: 227 http://openfast.svn.sourceforge.net/openfast/?rev=227&view=rev Author: gatny Date: 2010-10-26 17:07:12 +0000 (Tue, 26 Oct 2010) Log Message: ----------- allow encoding from an InputStream Modified Paths: -------------- trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java Modified: trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2010-10-25 20:40:11 UTC (rev 226) +++ trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2010-10-26 17:07:12 UTC (rev 227) @@ -1,6 +1,7 @@ package org.openfast.examples.producer; import java.io.File; +import java.io.InputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; @@ -40,7 +41,11 @@ } public void encode(File xmlDataFile) throws FastConnectionException, IOException { - List messages = converter.parse(new FileInputStream(xmlDataFile)); + encode(new FileInputStream(xmlDataFile)); + } + + public void encode(InputStream xmlData) throws FastConnectionException, IOException { + List messages = converter.parse(xmlData); while (true) { publish(messages, connections); try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-10-25 20:40:18
|
Revision: 226 http://openfast.svn.sourceforge.net/openfast/?rev=226&view=rev Author: gatny Date: 2010-10-25 20:40:11 +0000 (Mon, 25 Oct 2010) Log Message: ----------- Sending via multicast is now supported, and the producer example has been updated accordingly. Added MulticastOutputStream in keeping with the current Connection interface. It sends a datagram on every write. Modified Paths: -------------- trunk/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java trunk/src/main/java/org/openfast/examples/consumer/Main.java trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java trunk/src/main/java/org/openfast/examples/producer/Main.java trunk/src/main/java/org/openfast/session/multicast/MulticastConnection.java trunk/src/main/java/org/openfast/session/multicast/MulticastEndpoint.java Added Paths: ----------- trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java trunk/src/main/java/org/openfast/session/multicast/MulticastClientEndpoint.java trunk/src/main/java/org/openfast/session/multicast/MulticastOutputStream.java trunk/src/main/java/org/openfast/session/multicast/MulticastServerEndpoint.java trunk/src/test/java/org/openfast/session/multicast/ trunk/src/test/java/org/openfast/session/multicast/MulticastOutputStreamTest.java Modified: trunk/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java =================================================================== --- trunk/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java 2010-10-21 20:05:45 UTC (rev 225) +++ trunk/src/main/java/org/openfast/examples/consumer/FastMessageConsumer.java 2010-10-25 20:40:11 UTC (rev 226) @@ -6,6 +6,7 @@ import java.io.IOException; import org.openfast.Context; import org.openfast.Message; +import org.openfast.error.FastException; import org.openfast.codec.FastDecoder; import org.openfast.session.Connection; import org.openfast.session.Endpoint; @@ -46,8 +47,13 @@ } }); while (true) { - Message message = decoder.readMessage(readOffset); - System.out.println(message.toString()); + try { + Message message = decoder.readMessage(readOffset); + System.out.println(message.toString()); + } + catch(final FastException e) { + System.err.println(e.getMessage()); + } } } } Modified: trunk/src/main/java/org/openfast/examples/consumer/Main.java =================================================================== --- trunk/src/main/java/org/openfast/examples/consumer/Main.java 2010-10-21 20:05:45 UTC (rev 225) +++ trunk/src/main/java/org/openfast/examples/consumer/Main.java 2010-10-25 20:40:11 UTC (rev 226) @@ -9,6 +9,7 @@ import org.openfast.session.Endpoint; import org.openfast.session.FastConnectionException; import org.openfast.session.multicast.MulticastEndpoint; +import org.openfast.session.multicast.MulticastClientEndpoint; import org.openfast.session.tcp.TcpEndpoint; public class Main extends OpenFastExample { @@ -44,7 +45,7 @@ if (cl.hasOption(PROTOCOL)) { if ("udp".equals(cl.getOptionValue(PROTOCOL))) { - endpoint = new MulticastEndpoint(port, host, ifaddr); + endpoint = new MulticastClientEndpoint(port, host, ifaddr); } } if (endpoint == null) { Modified: trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2010-10-21 20:05:45 UTC (rev 225) +++ trunk/src/main/java/org/openfast/examples/producer/FastMessageProducer.java 2010-10-25 20:40:11 UTC (rev 226) @@ -19,10 +19,11 @@ import org.openfast.template.loader.XMLMessageTemplateLoader; public class FastMessageProducer implements ConnectionListener { - private final Endpoint endpoint; - private final TemplateRegistry templateRegistry; - private Thread acceptThread; - private List connections = new ArrayList(); + protected final Endpoint endpoint; + protected final TemplateRegistry templateRegistry; + protected Thread acceptThread; + protected List connections = new ArrayList(); + protected XmlCompressedMessageConverter converter = new XmlCompressedMessageConverter(); public FastMessageProducer(Endpoint endpoint, File templatesFile) { Global.setErrorHandler(ErrorHandler.NULL); @@ -35,27 +36,31 @@ throw new RuntimeException(e.getMessage(), e); } this.templateRegistry = loader.getTemplateRegistry(); + this.converter.setTemplateRegistry(this.templateRegistry); } public void encode(File xmlDataFile) throws FastConnectionException, IOException { - XmlCompressedMessageConverter converter = new XmlCompressedMessageConverter(); - converter.setTemplateRegistry(templateRegistry); List messages = converter.parse(new FileInputStream(xmlDataFile)); while (true) { - for (int i=0; i<messages.size(); i++) { - Message message = (Message) messages.get(i); - for (int j=0; j<connections.size(); j++) { - MessageOutputStream out = (MessageOutputStream) connections.get(j); - out.writeMessage(message); - } - } + publish(messages, connections); try { Thread.sleep(1000); - } catch (InterruptedException e) { } + catch (InterruptedException e) { + } } } + protected void publish(List messages, List msgOutputStreams) { + for (int i = 0; i < messages.size(); ++i) { + Message message = (Message) messages.get(i); + for (int j = 0; j < msgOutputStreams.size(); ++j) { + MessageOutputStream out = (MessageOutputStream)msgOutputStreams.get(j); + out.writeMessage(message); + } + } + } + public void start() { System.out.println("Listening on " + endpoint); if (acceptThread != null) return; Modified: trunk/src/main/java/org/openfast/examples/producer/Main.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/Main.java 2010-10-21 20:05:45 UTC (rev 225) +++ trunk/src/main/java/org/openfast/examples/producer/Main.java 2010-10-25 20:40:11 UTC (rev 226) @@ -6,21 +6,33 @@ import org.apache.commons.cli.Options; import org.openfast.examples.Assert; import org.openfast.examples.OpenFastExample; +import org.openfast.session.FastConnectionException; import org.openfast.session.Endpoint; -import org.openfast.session.FastConnectionException; import org.openfast.session.tcp.TcpEndpoint; +import org.openfast.session.multicast.MulticastServerEndpoint; public class Main extends OpenFastExample { private static Options options = new Options(); static { options.addOption("?", HELP, false, "Displays this message"); + options.addOption("r", PROTOCOL, true, "Protocol [tcp|udp] defaults to tcp"); options.addOption("p", PORT, true, "Port to serve data on"); - options.addOption("h", HOST, true, "The host name of the server"); + options.addOption("h", HOST, true, "The host name of the server (or group name for multicast)"); + options.addOption("i", INTERFACE, true, "The ip address of the network interface to use"); options.addOption("e", ERROR, false, "Show stacktrace information"); options.addOption("t", MESSAGE_TEMPLATE_FILE, true, "Message template definition file"); options.addOption("x", XML_DATA_FILE, true, "The XML data to convert to FAST"); } + + public static boolean isMulticast(CommandLine cl) { + if (cl.hasOption(PROTOCOL)) { + if ("udp".equals(cl.getOptionValue(PROTOCOL))) { + return true; + } + } + return false; + } /** * @param args @@ -38,8 +50,14 @@ Assert.assertTrue(cl.hasOption(PORT), "The required parameter \"" + PORT + "\" is missing."); int port = getInteger(cl, PORT); String host = cl.hasOption(HOST) ? cl.getOptionValue(HOST) : "localhost"; + String ifaddr = cl.hasOption(INTERFACE) ? cl.getOptionValue(INTERFACE) : null; - endpoint = new TcpEndpoint(host, port); + if(isMulticast(cl)) { + endpoint = new MulticastServerEndpoint(port, host, ifaddr); + } + if (endpoint == null) { + endpoint = new TcpEndpoint(host, port); + } templatesFile = getFile(cl, MESSAGE_TEMPLATE_FILE); xmlDataFile = getFile(cl, XML_DATA_FILE); Assert.assertTrue(templatesFile.exists(), "The template definition file \"" + templatesFile.getAbsolutePath() + "\" does not exist."); @@ -52,8 +70,12 @@ System.out.println(e.getMessage()); displayHelp("consumer", options); } - FastMessageProducer producer = new FastMessageProducer(endpoint, templatesFile); + try { + FastMessageProducer producer = isMulticast(cl) + ? new MulticastFastMessageProducer(endpoint, templatesFile) + : new FastMessageProducer(endpoint, templatesFile); + producer.start(); producer.encode(xmlDataFile); producer.stop(); Added: trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java (rev 0) +++ trunk/src/main/java/org/openfast/examples/producer/MulticastFastMessageProducer.java 2010-10-25 20:40:11 UTC (rev 226) @@ -0,0 +1,43 @@ +package org.openfast.examples.producer; + +import java.io.File; +import java.io.IOException; +import java.util.List; +import org.openfast.Context; +import org.openfast.Message; +import org.openfast.MessageOutputStream; +import org.openfast.error.ErrorHandler; +import org.openfast.session.Connection; +import org.openfast.session.Endpoint; +import org.openfast.session.FastConnectionException; +import org.openfast.template.TemplateRegistry; +import org.openfast.template.loader.XMLMessageTemplateLoader; + +public class MulticastFastMessageProducer extends FastMessageProducer { + private MessageOutputStream out; + + public MulticastFastMessageProducer(Endpoint endpoint, File templatesFile) throws IOException, FastConnectionException { + super(endpoint, templatesFile); + Context context = new Context(); + context.setErrorHandler(ErrorHandler.NULL); + context.setTemplateRegistry(templateRegistry); + out = new MessageOutputStream(endpoint.connect().getOutputStream(), context); + } + + protected void publish(List messages, List msgOutputStreams) { + if(out == null) { + return; + } + for(int i = 0; i < messages.size(); ++i) { + out.writeMessage((Message)messages.get(i)); + } + out.reset(); + } + + public void start() { + System.out.println("Publishing on " + endpoint); + } + + public void onConnect(Connection connection) { } +} + Added: trunk/src/main/java/org/openfast/session/multicast/MulticastClientEndpoint.java =================================================================== --- trunk/src/main/java/org/openfast/session/multicast/MulticastClientEndpoint.java (rev 0) +++ trunk/src/main/java/org/openfast/session/multicast/MulticastClientEndpoint.java 2010-10-25 20:40:11 UTC (rev 226) @@ -0,0 +1,60 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.1 (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.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +License for the specific language governing rights and limitations +under the License. + +The Original Code is OpenFAST. + +The Initial Developer of the Original Code is The LaSalle Technology +Group, LLC. Portions created by The LaSalle Technology Group, LLC +are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. + +Contributor(s): Jacob Northey <ja...@la...> + Craig Otis <co...@la...> + */ +package org.openfast.session.multicast; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.MulticastSocket; +import java.net.SocketException; + +import org.openfast.session.Connection; +import org.openfast.session.ConnectionListener; +import org.openfast.session.Endpoint; +import org.openfast.session.FastConnectionException; + +public class MulticastClientEndpoint extends MulticastEndpoint { + public MulticastClientEndpoint(int port, String group) { + super(port, group); + } + + public MulticastClientEndpoint(int port, String group, String ifaddr) { + super(port, group, ifaddr); + } + + public Connection connect() throws FastConnectionException { + try { + MulticastSocket socket = createSocket(); + InetAddress groupAddress = InetAddress.getByName(group); + socket.joinGroup(groupAddress); + return new MulticastConnection(socket, port, groupAddress); + } + catch(final IOException e) { + throw new FastConnectionException(e); + } + } + + public void accept() throws FastConnectionException { + throw new UnsupportedOperationException(); + } + public void setConnectionListener(ConnectionListener listener) { + throw new UnsupportedOperationException(); + } +} Modified: trunk/src/main/java/org/openfast/session/multicast/MulticastConnection.java =================================================================== --- trunk/src/main/java/org/openfast/session/multicast/MulticastConnection.java 2010-10-21 20:05:45 UTC (rev 225) +++ trunk/src/main/java/org/openfast/session/multicast/MulticastConnection.java 2010-10-25 20:40:11 UTC (rev 226) @@ -29,11 +29,14 @@ import org.openfast.session.Connection; public class MulticastConnection implements Connection { - private MulticastSocket socket; - private InetAddress group; + protected MulticastOutputStream outputStream; + protected MulticastSocket socket; + protected int port; + protected InetAddress group; - public MulticastConnection(MulticastSocket socket, InetAddress group) { + public MulticastConnection(MulticastSocket socket, int port, InetAddress group) { this.socket = socket; + this.port = port; this.group = group; } @@ -41,8 +44,9 @@ try { socket.leaveGroup(group); socket.close(); - } catch (IOException e) { } + catch (IOException e) { + } } public InputStream getInputStream() throws IOException { @@ -50,6 +54,8 @@ } public OutputStream getOutputStream() throws IOException { - throw new UnsupportedOperationException("Multicast sending not currently supported."); + if(outputStream == null) + outputStream = new MulticastOutputStream(socket, port, group); + return outputStream; } } Modified: trunk/src/main/java/org/openfast/session/multicast/MulticastEndpoint.java =================================================================== --- trunk/src/main/java/org/openfast/session/multicast/MulticastEndpoint.java 2010-10-21 20:05:45 UTC (rev 225) +++ trunk/src/main/java/org/openfast/session/multicast/MulticastEndpoint.java 2010-10-25 20:40:11 UTC (rev 226) @@ -30,24 +30,22 @@ import org.openfast.session.Endpoint; import org.openfast.session.FastConnectionException; -public class MulticastEndpoint implements Endpoint { - private int port; - private String group; - private String ifaddr; +public abstract class MulticastEndpoint implements Endpoint { + protected int port; + protected String group; + protected String ifaddr; + public MulticastEndpoint(int port, String group) { + this(port, group, null); + } + + public MulticastEndpoint(int port, String group, String ifaddr) { this.port = port; this.group = group; - this.ifaddr = null; - } - public MulticastEndpoint(int port, String group, String ifaddr) { - this(port, group); this.ifaddr = ifaddr; } - public void accept() throws FastConnectionException { - throw new UnsupportedOperationException(); - } - public void close() {} - public Connection connect() throws FastConnectionException { + + protected MulticastSocket createSocket() throws FastConnectionException { try { MulticastSocket socket = new MulticastSocket(port); if (ifaddr != null) { @@ -57,14 +55,23 @@ throw new FastConnectionException(e); } } - InetAddress groupAddress = InetAddress.getByName(group); - socket.joinGroup(groupAddress); - return new MulticastConnection(socket, groupAddress); + return socket; } catch (IOException e) { throw new FastConnectionException(e); } } - public void setConnectionListener(ConnectionListener listener) { - throw new UnsupportedOperationException(); + + public String toString() { + return new StringBuilder(getClass().getName()) + .append("[").append("group=").append(group) + .append(",").append("port=").append(port) + .append(",").append("ifaddr=").append(ifaddr) + .append("]") + .toString(); } + + public abstract Connection connect() throws FastConnectionException; + public void accept() throws FastConnectionException { } + public void setConnectionListener(ConnectionListener listener) { } + public void close() {} } Added: trunk/src/main/java/org/openfast/session/multicast/MulticastOutputStream.java =================================================================== --- trunk/src/main/java/org/openfast/session/multicast/MulticastOutputStream.java (rev 0) +++ trunk/src/main/java/org/openfast/session/multicast/MulticastOutputStream.java 2010-10-25 20:40:11 UTC (rev 226) @@ -0,0 +1,60 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.1 (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.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +License for the specific language governing rights and limitations +under the License. + +The Original Code is OpenFAST. + +The Initial Developer of the Original Code is The LaSalle Technology +Group, LLC. Portions created by The LaSalle Technology Group, LLC +are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. + +Contributor(s): Jacob Northey <ja...@la...> + Craig Otis <co...@la...> + */ +package org.openfast.session.multicast; + +import java.io.IOException; +import java.io.OutputStream; +import java.net.DatagramPacket; +import java.net.InetAddress; +import java.net.MulticastSocket; + +public class MulticastOutputStream extends OutputStream { + private MulticastSocket socket; + private InetAddress group; + private int port; + private DatagramPacket datagramPacket; + + public MulticastOutputStream(MulticastSocket socket, int port, InetAddress group) { + this.socket = socket; + this.group = group; + this.port = port; + } + + public void write(byte[] b, int off, int len) { + if(off != 0 || len != b.length) + throw new UnsupportedOperationException(); + + try { + socket.send(new DatagramPacket(b, len, group, port)); + } + catch(final IOException e) { + e.printStackTrace(); + } + } + + public void write(byte[] b) { + write(b, 0, b.length); + } + + public void write(int b) { + throw new UnsupportedOperationException(); + } +} Added: trunk/src/main/java/org/openfast/session/multicast/MulticastServerEndpoint.java =================================================================== --- trunk/src/main/java/org/openfast/session/multicast/MulticastServerEndpoint.java (rev 0) +++ trunk/src/main/java/org/openfast/session/multicast/MulticastServerEndpoint.java 2010-10-25 20:40:11 UTC (rev 226) @@ -0,0 +1,49 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.1 (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.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +License for the specific language governing rights and limitations +under the License. + +The Original Code is OpenFAST. + +The Initial Developer of the Original Code is The LaSalle Technology +Group, LLC. Portions created by The LaSalle Technology Group, LLC +are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. + +Contributor(s): Jacob Northey <ja...@la...> + Craig Otis <co...@la...> + */ +package org.openfast.session.multicast; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.MulticastSocket; +import java.net.SocketException; + +import org.openfast.session.Connection; +import org.openfast.session.ConnectionListener; +import org.openfast.session.FastConnectionException; + +public class MulticastServerEndpoint extends MulticastEndpoint { + public MulticastServerEndpoint(int port, String group) { + super(port, group); + } + + public MulticastServerEndpoint(int port, String group, String ifaddr) { + super(port, group, ifaddr); + } + + public Connection connect() throws FastConnectionException { + try { + return new MulticastConnection(createSocket(), port, InetAddress.getByName(group)); + } + catch(final IOException e) { + throw new FastConnectionException(e); + } + } +} Added: trunk/src/test/java/org/openfast/session/multicast/MulticastOutputStreamTest.java =================================================================== --- trunk/src/test/java/org/openfast/session/multicast/MulticastOutputStreamTest.java (rev 0) +++ trunk/src/test/java/org/openfast/session/multicast/MulticastOutputStreamTest.java 2010-10-25 20:40:11 UTC (rev 226) @@ -0,0 +1,112 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.1 (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.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +License for the specific language governing rights and limitations +under the License. + +The Original Code is OpenFAST. + +The Initial Developer of the Original Code is The LaSalle Technology +Group, LLC. Portions created by The LaSalle Technology Group, LLC +are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. + +Contributor(s): Jacob Northey <ja...@la...> + Craig Otis <co...@la...> +*/ + + +package org.openfast.session.multicast; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.DatagramPacket; +import java.net.MulticastSocket; +import java.util.Arrays; +import java.util.Deque; +import java.util.LinkedList; +import junit.framework.TestCase; + +public class MulticastOutputStreamTest extends TestCase { + final static byte[] MESSAGE_A = "MESSAGE_A".getBytes(); + final static byte[] MESSAGE_B = "MESSAGE_B".getBytes(); + final static byte[] MESSAGE_C = "MESSAGE_C".getBytes(); + int port; + InetAddress group; + MockMulticastSocket socket; + MulticastOutputStream multicastOutputStream; + + public class MockMulticastSocket extends MulticastSocket { + public Deque packetsSent = new LinkedList(); + + public MockMulticastSocket(int port) throws IOException { + super(port); + } + + public void send(DatagramPacket packet) throws IOException { + packetsSent.push(packet); + } + } + + public static void assertPacketEquals(byte[] expected, DatagramPacket actual) { + final String msg = "Expected '" + new String(expected) + "', but was '" + new String(actual.getData()) + "'"; + assertTrue(msg, Arrays.equals(expected, actual.getData())); + } + + public void setUp() throws Exception { + port = 4242; + group = InetAddress.getByName("230.0.0.1"); + socket = new MockMulticastSocket(port); + multicastOutputStream = new MulticastOutputStream(socket, port, group); + } + + public void testWrite() { + multicastOutputStream.write(MESSAGE_A); + multicastOutputStream.write(MESSAGE_B); + multicastOutputStream.write(MESSAGE_C); + assertPacketEquals(MESSAGE_A, (DatagramPacket)socket.packetsSent.removeLast()); + assertPacketEquals(MESSAGE_B, (DatagramPacket)socket.packetsSent.removeLast()); + assertPacketEquals(MESSAGE_C, (DatagramPacket)socket.packetsSent.removeLast()); + } + + public void testWriteSingleByteNotSupported() { + try { + multicastOutputStream.write('X'); + fail("Expected write of single byte to cause exception, but none was thrown."); + } + catch(final UnsupportedOperationException e) { + } + } + + public void testWriteOffsetMustEqualZeroAndLengthMustEqualDataLength() throws UnsupportedOperationException { + multicastOutputStream.write(MESSAGE_A, 0, MESSAGE_A.length); // offset and length OK + multicastOutputStream.write(MESSAGE_B, 0, MESSAGE_B.length); // offset and length OK + multicastOutputStream.write(MESSAGE_C, 0, MESSAGE_C.length); // offset and length OK + + try { + multicastOutputStream.write(MESSAGE_A, 1, MESSAGE_A.length); + fail("Expected illegal offset to cause exception, but none was thrown."); + } + catch(final UnsupportedOperationException e) { + } + + try { + multicastOutputStream.write(MESSAGE_A, 0, MESSAGE_A.length - 1); + fail("Expected illegal length to cause exception, but none was thrown."); + } + catch(final UnsupportedOperationException e) { + } + + try { + multicastOutputStream.write(MESSAGE_A, 0, MESSAGE_A.length + 1); + fail("Expected illegal length to cause exception, but none was thrown."); + } + catch(final UnsupportedOperationException e) { + } + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-10-21 20:05:51
|
Revision: 225 http://openfast.svn.sourceforge.net/openfast/?rev=225&view=rev Author: gatny Date: 2010-10-21 20:05:45 +0000 (Thu, 21 Oct 2010) Log Message: ----------- Fixed NPE exception in XmlCompressedMessageConverter: unknown fields are now skipped with a warning. Fixed classpath in the producer.sh script. The producer and consumer can now be run together using the templates and data files from the FPL resources dir. Modified Paths: -------------- trunk/src/assembly/binary.xml trunk/src/main/java/org/openfast/examples/producer/XmlCompressedMessageConverter.java trunk/src/main/resources/producer.sh Modified: trunk/src/assembly/binary.xml =================================================================== --- trunk/src/assembly/binary.xml 2010-10-20 17:12:24 UTC (rev 224) +++ trunk/src/assembly/binary.xml 2010-10-21 20:05:45 UTC (rev 225) @@ -29,6 +29,14 @@ <fileMode>0755</fileMode> </fileSet> <fileSet> + <directory>src/test/resources/FPL</directory> + <outputDirectory>bin</outputDirectory> + <includes> + <include>FASTTestTemplate.xml</include> + <include>data.xml</include> + </includes> + </fileSet> + <fileSet> <directory>/</directory> <outputDirectory></outputDirectory> <includes> @@ -61,4 +69,4 @@ <outputDirectory>lib</outputDirectory> </dependencySet> </dependencySets> -</assembly> \ No newline at end of file +</assembly> Modified: trunk/src/main/java/org/openfast/examples/producer/XmlCompressedMessageConverter.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/XmlCompressedMessageConverter.java 2010-10-20 17:12:24 UTC (rev 224) +++ trunk/src/main/java/org/openfast/examples/producer/XmlCompressedMessageConverter.java 2010-10-21 20:05:45 UTC (rev 225) @@ -112,19 +112,25 @@ while (reader.hasMoreChildren()) { reader.moveDown(); Field field = group.getField(reader.getNodeName()); - FieldValue value = null; - if (field instanceof Group) { - Group currentGroup = (Group) field; - value = currentGroup.createValue(null); - parseGroup(reader, currentGroup, (GroupValue) value); - } else if (field instanceof Sequence) { - Sequence currentSequence = (Sequence) field; - value = currentSequence.createValue(null); - parseSequence(reader, currentSequence, (SequenceValue) value); - } else { - value = field.createValue(reader.getValue()); + if(field != null) + { + FieldValue value = null; + if (field instanceof Group) { + Group currentGroup = (Group) field; + value = currentGroup.createValue(null); + parseGroup(reader, currentGroup, (GroupValue) value); + } else if (field instanceof Sequence) { + Sequence currentSequence = (Sequence) field; + value = currentSequence.createValue(null); + parseSequence(reader, currentSequence, (SequenceValue) value); + } else { + value = field.createValue(reader.getValue()); + } + groupValue.setFieldValue(field, value); } - groupValue.setFieldValue(field, value); + else { + System.err.println("Warning: skipping unexpected field '" + reader.getNodeName() + "'"); + } reader.moveUp(); } } Modified: trunk/src/main/resources/producer.sh =================================================================== --- trunk/src/main/resources/producer.sh 2010-10-20 17:12:24 UTC (rev 224) +++ trunk/src/main/resources/producer.sh 2010-10-21 20:05:45 UTC (rev 225) @@ -1,19 +1,23 @@ #!/bin/sh if [ ! $JAVA_HOME ]; then -echo "Please set the JAVA_HOME environment variable to point to a valid Java install location." -exit 1 + echo "Please set the JAVA_HOME environment variable to point to a valid Java install location." + exit 1 fi if [ ! -f $JAVA_HOME/bin/java ]; then -echo "Please set the JAVA_HOME environment variable to point to a valid Java install location." -exit 1 + echo "Please set the JAVA_HOME environment variable to point to a valid Java install location." + exit 1 fi OPENFAST_HOME=$( cd -P -- "$(dirname -- "$0")" && pwd -P)/.. JAVA="$JAVA_HOME/bin/java" -CLASSPATH=$OPENFAST_HOME/lib/commons-cli-1.1.jar:$OPENFAST_HOME/${project.artifactId}-${project.version}.jar +CLASSPATH=$OPENFAST_HOME/${project.artifactId}-${project.version}.jar +for JAR in $OPENFAST_HOME/lib/*.jar; do + CLASSPATH=${JAR}:${CLASSPATH} +done + MAIN=org.openfast.examples.producer.Main $JAVA $JAVA_OPTS -classpath $CLASSPATH $MAIN $* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-06-15 22:17:37
|
Revision: 221 http://openfast.svn.sourceforge.net/openfast/?rev=221&view=rev Author: jacob_northey Date: 2010-06-15 22:17:31 +0000 (Tue, 15 Jun 2010) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-06-15 22:17:23 UTC (rev 220) +++ trunk/pom.xml 2010-06-15 22:17:31 UTC (rev 221) @@ -3,7 +3,7 @@ <groupId>org.openfast</groupId> <artifactId>openfast</artifactId> <packaging>jar</packaging> - <version>1.0.2</version> + <version>1.0.3-SNAPSHOT</version> <organization> <name>The LaSalle Technology Group, LLC</name> @@ -71,9 +71,9 @@ </issueManagement> <scm> - <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.2</connection> - <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.2</developerConnection> - <url>http://openfast.svn.sourceforge.net/viewvc/openfast/tags/openfast-1.0.2</url> + <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.1</connection> + <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.1</developerConnection> + <url>http://openfast.svn.sourceforge.net/viewvc/openfast/tags/openfast-1.0.1</url> </scm> <mailingLists> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-06-15 22:17:31
|
Revision: 220 http://openfast.svn.sourceforge.net/openfast/?rev=220&view=rev Author: jacob_northey Date: 2010-06-15 22:17:23 +0000 (Tue, 15 Jun 2010) Log Message: ----------- [maven-release-plugin] copy for tag openfast-1.0.2 Added Paths: ----------- tags/openfast-1.0.2/ tags/openfast-1.0.2/pom.xml Removed Paths: ------------- tags/openfast-1.0.2/pom.xml Deleted: tags/openfast-1.0.2/pom.xml =================================================================== --- trunk/pom.xml 2010-06-15 00:18:25 UTC (rev 218) +++ tags/openfast-1.0.2/pom.xml 2010-06-15 22:17:23 UTC (rev 220) @@ -1,251 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.openfast</groupId> - <artifactId>openfast</artifactId> - <packaging>jar</packaging> - <version>1.1.0-SNAPSHOT</version> - - <organization> - <name>The LaSalle Technology Group, LLC</name> - <url>http://www.lasalletech.com</url> - </organization> - - <name>OpenFAST</name> - - <description> - OpenFAST is a 100% Java implementation of the FAST Protocol. - </description> - - <developers> - <developer> - <name>Jacob Northey</name> - <organization>Lasalletech</organization> - <organizationUrl> - http://www.lasalletech.com/ - </organizationUrl> - <roles> - <role>architect</role> - <role>developer</role> - </roles> - <timezone>-5</timezone> - </developer> - <developer> - <name>Craig Otis</name> - <organization>Lasalletech</organization> - <organizationUrl> - http://www.lasalletech.com/ - </organizationUrl> - <roles> - <role>developer</role> - </roles> - <timezone>-5</timezone> - </developer> - </developers> - - <contributors> - <contributor> - <name>Stefan Schwendiman</name> - <organization>Swiss Exchange</organization> - <organizationUrl>http://www.swx.com</organizationUrl> - <roles> - <role>tester</role> - </roles> - <timezone>+1</timezone> - </contributor> - </contributors> - - <licenses> - <license> - <name>Mozilla Public License Version 1.1</name> - <url>http://www.mozilla.org/MPL/MPL-1.1.html</url> - <distribution>repo</distribution> - </license> - </licenses> - - <url>http://www.openfast.org</url> - <inceptionYear>2006</inceptionYear> - - <issueManagement> - <system>jira</system> - <url>http://www.quickfixj.org/jira/browse/FAST</url> - </issueManagement> - - <scm> - <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.1</connection> - <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.1</developerConnection> - <url>http://openfast.svn.sourceforge.net/viewvc/openfast/tags/openfast-1.0.1</url> - </scm> - - <mailingLists> - <mailingList> - <name>OpenFAST Users Mailing List</name> - <subscribe> - http://lists.sourceforge.net/mailman/listinfo/openfast-user - </subscribe> - <unsubscribe> - http://lists.sourceforge.net/mailman/listinfo/openfast-user - </unsubscribe> - <archive> - https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-user - </archive> - <post>ope...@li...</post> - </mailingList> - <mailingList> - <name>OpenFAST Commits Mailing List</name> - <subscribe> - http://lists.sourceforge.net/mailman/listinfo/openfast-commit - </subscribe> - <unsubscribe> - http://lists.sourceforge.net/mailman/listinfo/openfast-commit - </unsubscribe> - <archive> - https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-commit - </archive> - <post>ope...@li...</post> - </mailingList> - <mailingList> - <name>OpenFAST Announcements Mailing List</name> - <subscribe> - http://lists.sourceforge.net/mailman/listinfo/openfast-announce - </subscribe> - <unsubscribe> - http://lists.sourceforge.net/mailman/listinfo/openfast-announce - </unsubscribe> - <archive> - https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-announce - </archive> - <post>ope...@li...</post> - </mailingList> - </mailingLists> - - <build> - <resources> - <resource> - <directory>src/main/resources</directory> - <excludes> - <exclude>**/*.bat</exclude> - <exclude>**/*.sh</exclude> - </excludes> - </resource> - <resource> - <directory>src/main/java</directory> - <excludes> - <exclude>**/*.java</exclude> - </excludes> - </resource> - </resources> - - <extensions> - <extension> - <groupId>org.apache.maven.wagon</groupId> - <artifactId>wagon-ssh</artifactId> - <version>1.0-beta-2</version> - </extension> - </extensions> - - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <source>1.5</source> - <target>1.5</target> - </configuration> - </plugin> - <plugin> - <artifactId>maven-release-plugin</artifactId> - <configuration> - <tagBase> - https://openfast.svn.sourceforge.net/svnroot/openfast/tags - </tagBase> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <executions> - <execution> - <id>attach-sources</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <executions> - <execution> - <id>attach-javadocs</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <descriptors> - <descriptor>src/assembly/source.xml</descriptor> - <descriptor>src/assembly/binary.xml</descriptor> - </descriptors> - </configuration> - <executions> - <execution> - <id>make-assembly</id> - <phase>deploy</phase> - <goals> - <goal>attached</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>commons-cli</groupId> - <artifactId>commons-cli</artifactId> - <version>1.1</version> - <optional>true</optional> - </dependency> - <dependency> - <groupId>com.thoughtworks.xstream</groupId> - <artifactId>xstream</artifactId> - <version>1.3</version> - <optional>true</optional> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.2</version> - <scope>test</scope> - </dependency> - </dependencies> - - <distributionManagement> - <repository> - <id>sourceforge.net</id> - <name>Sourceforge.net Repository</name> - <url> - scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/release - </url> - </repository> - <snapshotRepository> - <id>sourceforge.net</id> - <name>Sourceforge.net Snapshot Repository</name> - <url> - scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/snapshot - </url> - </snapshotRepository> - <site> - <id>sourceforge.net</id> - <name>Sourceforge.net OpenFAST Web Site</name> - <url> - scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/ - </url> - </site> - </distributionManagement> -</project> \ No newline at end of file Copied: tags/openfast-1.0.2/pom.xml (from rev 219, trunk/pom.xml) =================================================================== --- tags/openfast-1.0.2/pom.xml (rev 0) +++ tags/openfast-1.0.2/pom.xml 2010-06-15 22:17:23 UTC (rev 220) @@ -0,0 +1,251 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openfast</groupId> + <artifactId>openfast</artifactId> + <packaging>jar</packaging> + <version>1.0.2</version> + + <organization> + <name>The LaSalle Technology Group, LLC</name> + <url>http://www.lasalletech.com</url> + </organization> + + <name>OpenFAST</name> + + <description> + OpenFAST is a 100% Java implementation of the FAST Protocol. + </description> + + <developers> + <developer> + <name>Jacob Northey</name> + <organization>Lasalletech</organization> + <organizationUrl> + http://www.lasalletech.com/ + </organizationUrl> + <roles> + <role>architect</role> + <role>developer</role> + </roles> + <timezone>-5</timezone> + </developer> + <developer> + <name>Craig Otis</name> + <organization>Lasalletech</organization> + <organizationUrl> + http://www.lasalletech.com/ + </organizationUrl> + <roles> + <role>developer</role> + </roles> + <timezone>-5</timezone> + </developer> + </developers> + + <contributors> + <contributor> + <name>Stefan Schwendiman</name> + <organization>Swiss Exchange</organization> + <organizationUrl>http://www.swx.com</organizationUrl> + <roles> + <role>tester</role> + </roles> + <timezone>+1</timezone> + </contributor> + </contributors> + + <licenses> + <license> + <name>Mozilla Public License Version 1.1</name> + <url>http://www.mozilla.org/MPL/MPL-1.1.html</url> + <distribution>repo</distribution> + </license> + </licenses> + + <url>http://www.openfast.org</url> + <inceptionYear>2006</inceptionYear> + + <issueManagement> + <system>jira</system> + <url>http://www.quickfixj.org/jira/browse/FAST</url> + </issueManagement> + + <scm> + <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.2</connection> + <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.2</developerConnection> + <url>http://openfast.svn.sourceforge.net/viewvc/openfast/tags/openfast-1.0.2</url> + </scm> + + <mailingLists> + <mailingList> + <name>OpenFAST Users Mailing List</name> + <subscribe> + http://lists.sourceforge.net/mailman/listinfo/openfast-user + </subscribe> + <unsubscribe> + http://lists.sourceforge.net/mailman/listinfo/openfast-user + </unsubscribe> + <archive> + https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-user + </archive> + <post>ope...@li...</post> + </mailingList> + <mailingList> + <name>OpenFAST Commits Mailing List</name> + <subscribe> + http://lists.sourceforge.net/mailman/listinfo/openfast-commit + </subscribe> + <unsubscribe> + http://lists.sourceforge.net/mailman/listinfo/openfast-commit + </unsubscribe> + <archive> + https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-commit + </archive> + <post>ope...@li...</post> + </mailingList> + <mailingList> + <name>OpenFAST Announcements Mailing List</name> + <subscribe> + http://lists.sourceforge.net/mailman/listinfo/openfast-announce + </subscribe> + <unsubscribe> + http://lists.sourceforge.net/mailman/listinfo/openfast-announce + </unsubscribe> + <archive> + https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-announce + </archive> + <post>ope...@li...</post> + </mailingList> + </mailingLists> + + <build> + <resources> + <resource> + <directory>src/main/resources</directory> + <excludes> + <exclude>**/*.bat</exclude> + <exclude>**/*.sh</exclude> + </excludes> + </resource> + <resource> + <directory>src/main/java</directory> + <excludes> + <exclude>**/*.java</exclude> + </excludes> + </resource> + </resources> + + <extensions> + <extension> + <groupId>org.apache.maven.wagon</groupId> + <artifactId>wagon-ssh</artifactId> + <version>1.0-beta-2</version> + </extension> + </extensions> + + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + <plugin> + <artifactId>maven-release-plugin</artifactId> + <configuration> + <tagBase> + https://openfast.svn.sourceforge.net/svnroot/openfast/tags + </tagBase> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <executions> + <execution> + <id>attach-javadocs</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <descriptors> + <descriptor>src/assembly/source.xml</descriptor> + <descriptor>src/assembly/binary.xml</descriptor> + </descriptors> + </configuration> + <executions> + <execution> + <id>make-assembly</id> + <phase>deploy</phase> + <goals> + <goal>attached</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>commons-cli</groupId> + <artifactId>commons-cli</artifactId> + <version>1.1</version> + <optional>true</optional> + </dependency> + <dependency> + <groupId>com.thoughtworks.xstream</groupId> + <artifactId>xstream</artifactId> + <version>1.3</version> + <optional>true</optional> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.2</version> + <scope>test</scope> + </dependency> + </dependencies> + + <distributionManagement> + <repository> + <id>sourceforge.net</id> + <name>Sourceforge.net Repository</name> + <url> + scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/release + </url> + </repository> + <snapshotRepository> + <id>sourceforge.net</id> + <name>Sourceforge.net Snapshot Repository</name> + <url> + scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/snapshot + </url> + </snapshotRepository> + <site> + <id>sourceforge.net</id> + <name>Sourceforge.net OpenFAST Web Site</name> + <url> + scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/ + </url> + </site> + </distributionManagement> +</project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-06-15 22:17:10
|
Revision: 219 http://openfast.svn.sourceforge.net/openfast/?rev=219&view=rev Author: jacob_northey Date: 2010-06-15 22:17:04 +0000 (Tue, 15 Jun 2010) Log Message: ----------- Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-06-15 00:18:25 UTC (rev 218) +++ trunk/pom.xml 2010-06-15 22:17:04 UTC (rev 219) @@ -3,7 +3,7 @@ <groupId>org.openfast</groupId> <artifactId>openfast</artifactId> <packaging>jar</packaging> - <version>1.1.0-SNAPSHOT</version> + <version>1.0.2</version> <organization> <name>The LaSalle Technology Group, LLC</name> @@ -71,9 +71,9 @@ </issueManagement> <scm> - <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.1</connection> - <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.1</developerConnection> - <url>http://openfast.svn.sourceforge.net/viewvc/openfast/tags/openfast-1.0.1</url> + <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.2</connection> + <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.2</developerConnection> + <url>http://openfast.svn.sourceforge.net/viewvc/openfast/tags/openfast-1.0.2</url> </scm> <mailingLists> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-06-15 00:18:32
|
Revision: 218 http://openfast.svn.sourceforge.net/openfast/?rev=218&view=rev Author: littleodie914 Date: 2010-06-15 00:18:25 +0000 (Tue, 15 Jun 2010) Log Message: ----------- Added an additional constructor to FastClient that allows the SessionListener to be provided. Updated Session to notify the SessionListener when the Session stops listening for incoming Messages. Modified Paths: -------------- trunk/src/main/java/org/openfast/session/FastClient.java trunk/src/main/java/org/openfast/session/Session.java Modified: trunk/src/main/java/org/openfast/session/FastClient.java =================================================================== --- trunk/src/main/java/org/openfast/session/FastClient.java 2010-06-04 01:36:42 UTC (rev 217) +++ trunk/src/main/java/org/openfast/session/FastClient.java 2010-06-15 00:18:25 UTC (rev 218) @@ -38,6 +38,11 @@ this.endpoint = endpoint; } + public FastClient(String clientName, SessionProtocol sessionProtocol, Endpoint endpoint, SessionListener sessionListener) { + this(clientName, sessionProtocol, endpoint); + this.sessionListener = sessionListener; + } + public void setInboundTemplateRegistry(TemplateRegistry registry) { this.inboundRegistry = registry; } Modified: trunk/src/main/java/org/openfast/session/Session.java =================================================================== --- trunk/src/main/java/org/openfast/session/Session.java 2010-06-04 01:36:42 UTC (rev 217) +++ trunk/src/main/java/org/openfast/session/Session.java 2010-06-15 00:18:25 UTC (rev 218) @@ -146,6 +146,9 @@ if (message == null) { listening = false; + if (sessionListener != null) { + sessionListener.onClose(); + } break; } if (protocol.isProtocolMessage(message)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-06-04 01:36:48
|
Revision: 217 http://openfast.svn.sourceforge.net/openfast/?rev=217&view=rev Author: jacob_northey Date: 2010-06-04 01:36:42 +0000 (Fri, 04 Jun 2010) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-06-04 01:36:39 UTC (rev 216) +++ trunk/pom.xml 2010-06-04 01:36:42 UTC (rev 217) @@ -3,7 +3,7 @@ <groupId>org.openfast</groupId> <artifactId>openfast</artifactId> <packaging>jar</packaging> - <version>1.0.1</version> + <version>1.1.0-SNAPSHOT</version> <organization> <name>The LaSalle Technology Group, LLC</name> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-06-04 01:36:45
|
Revision: 216 http://openfast.svn.sourceforge.net/openfast/?rev=216&view=rev Author: jacob_northey Date: 2010-06-04 01:36:39 +0000 (Fri, 04 Jun 2010) Log Message: ----------- [maven-release-plugin] copy for tag openfast-1.0.1 Added Paths: ----------- tags/openfast-1.0.1/ tags/openfast-1.0.1/pom.xml tags/openfast-1.0.1/src/main/java/org/openfast/Context.java tags/openfast-1.0.1/src/main/java/org/openfast/NullOpenFastContext.java tags/openfast-1.0.1/src/main/java/org/openfast/logging/FastMessageLogger.java tags/openfast-1.0.1/src/main/java/org/openfast/logging/FileFastMessageLogger.java tags/openfast-1.0.1/src/main/java/org/openfast/session/BasicOpenFastContext.java tags/openfast-1.0.1/src/main/java/org/openfast/template/BasicTemplateRegistry.java Removed Paths: ------------- tags/openfast-1.0.1/pom.xml tags/openfast-1.0.1/src/main/java/org/openfast/Context.java tags/openfast-1.0.1/src/main/java/org/openfast/NullOpenFastContext.java tags/openfast-1.0.1/src/main/java/org/openfast/logging/FastMessageLogger.java tags/openfast-1.0.1/src/main/java/org/openfast/logging/FileFastMessageLogger.java tags/openfast-1.0.1/src/main/java/org/openfast/session/BasicOpenFastContext.java tags/openfast-1.0.1/src/main/java/org/openfast/template/BasicTemplateRegistry.java Deleted: tags/openfast-1.0.1/pom.xml =================================================================== --- trunk/pom.xml 2010-05-25 22:16:11 UTC (rev 213) +++ tags/openfast-1.0.1/pom.xml 2010-06-04 01:36:39 UTC (rev 216) @@ -1,252 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <groupId>org.openfast</groupId> - <artifactId>openfast</artifactId> - <packaging>jar</packaging> - <version>1.1.0-SNAPSHOT</version> - - <organization> - <name>The LaSalle Technology Group, LLC</name> - <url>http://www.lasalletech.com</url> - </organization> - - <name>OpenFAST</name> - - <description> - OpenFAST is a 100% Java implementation of the FAST Protocol. - </description> - - <developers> - <developer> - <name>Jacob Northey</name> - <organization>Lasalletech</organization> - <organizationUrl> - http://www.lasalletech.com/ - </organizationUrl> - <roles> - <role>architect</role> - <role>developer</role> - </roles> - <timezone>-5</timezone> - </developer> - <developer> - <name>Craig Otis</name> - <organization>Lasalletech</organization> - <organizationUrl> - http://www.lasalletech.com/ - </organizationUrl> - <roles> - <role>developer</role> - </roles> - <timezone>-5</timezone> - </developer> - </developers> - - <contributors> - <contributor> - <name>Stefan Schwendiman</name> - <organization>Swiss Exchange</organization> - <organizationUrl>http://www.swx.com</organizationUrl> - <roles> - <role>tester</role> - </roles> - <timezone>+1</timezone> - </contributor> - </contributors> - - <licenses> - <license> - <name>Mozilla Public License Version 1.1</name> - <url>http://www.mozilla.org/MPL/MPL-1.1.html</url> - <distribution>repo</distribution> - </license> - </licenses> - - <url>http://www.openfast.org</url> - <inceptionYear>2006</inceptionYear> - - <issueManagement> - <system>jira</system> - <url>http://www.quickfixj.org/jira/browse/FAST</url> - </issueManagement> - - <scm> - <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.1</connection> - <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.1</developerConnection> - <url>http://openfast.svn.sourceforge.net/viewvc/openfast/tags/openfast-1.0.1</url> - </scm> - - <mailingLists> - <mailingList> - <name>OpenFAST Users Mailing List</name> - <subscribe> - http://lists.sourceforge.net/mailman/listinfo/openfast-user - </subscribe> - <unsubscribe> - http://lists.sourceforge.net/mailman/listinfo/openfast-user - </unsubscribe> - <archive> - https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-user - </archive> - <post>ope...@li...</post> - </mailingList> - <mailingList> - <name>OpenFAST Commits Mailing List</name> - <subscribe> - http://lists.sourceforge.net/mailman/listinfo/openfast-commit - </subscribe> - <unsubscribe> - http://lists.sourceforge.net/mailman/listinfo/openfast-commit - </unsubscribe> - <archive> - https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-commit - </archive> - <post>ope...@li...</post> - </mailingList> - <mailingList> - <name>OpenFAST Announcements Mailing List</name> - <subscribe> - http://lists.sourceforge.net/mailman/listinfo/openfast-announce - </subscribe> - <unsubscribe> - http://lists.sourceforge.net/mailman/listinfo/openfast-announce - </unsubscribe> - <archive> - https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-announce - </archive> - <post>ope...@li...</post> - </mailingList> - </mailingLists> - - <build> - <resources> - <resource> - <directory>src/main/resources</directory> - <excludes> - <exclude>**/*.bat</exclude> - <exclude>**/*.sh</exclude> - </excludes> - </resource> - <resource> - <directory>src/main/java</directory> - <excludes> - <exclude>**/*.java</exclude> - </excludes> - </resource> - </resources> - - <extensions> - <extension> - <groupId>org.apache.maven.wagon</groupId> - <artifactId>wagon-ssh</artifactId> - <version>1.0-beta-2</version> - </extension> - </extensions> - - <plugins> - <plugin> - <artifactId>maven-compiler-plugin</artifactId> - <configuration> - <source>1.5</source> - <target>1.5</target> - </configuration> - </plugin> - <plugin> - <artifactId>maven-release-plugin</artifactId> - <configuration> - <tagBase> - https://openfast.svn.sourceforge.net/svnroot/openfast/tags - </tagBase> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-source-plugin</artifactId> - <executions> - <execution> - <id>attach-sources</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-javadoc-plugin</artifactId> - <executions> - <execution> - <id>attach-javadocs</id> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <descriptors> - <descriptor>src/assembly/source.xml</descriptor> - <descriptor>src/assembly/binary.xml</descriptor> - </descriptors> - </configuration> - <executions> - <execution> - <id>make-assembly</id> - <phase>deploy</phase> - <goals> - <goal>attached</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>commons-cli</groupId> - <artifactId>commons-cli</artifactId> - <version>1.1</version> - <optional>true</optional> - </dependency> - <dependency> - <groupId>com.thoughtworks.xstream</groupId> - <artifactId>xstream</artifactId> - <version>1.3</version> - <optional>true</optional> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.2</version> - <scope>test</scope> - </dependency> - </dependencies> - - <distributionManagement> - <repository> - <id>sourceforge.net</id> - <name>Sourceforge.net Repository</name> - <url> - scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/release - </url> - </repository> - <snapshotRepository> - <id>sourceforge.net</id> - <name>Sourceforge.net Snapshot Repository</name> - <url> - scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/snapshot - </url> - </snapshotRepository> - <site> - <id>sourceforge.net</id> - <name>Sourceforge.net OpenFAST Web Site</name> - <url> - scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/ - </url> - </site> - </distributionManagement> -</project> \ No newline at end of file Copied: tags/openfast-1.0.1/pom.xml (from rev 215, trunk/pom.xml) =================================================================== --- tags/openfast-1.0.1/pom.xml (rev 0) +++ tags/openfast-1.0.1/pom.xml 2010-06-04 01:36:39 UTC (rev 216) @@ -0,0 +1,251 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openfast</groupId> + <artifactId>openfast</artifactId> + <packaging>jar</packaging> + <version>1.0.1</version> + + <organization> + <name>The LaSalle Technology Group, LLC</name> + <url>http://www.lasalletech.com</url> + </organization> + + <name>OpenFAST</name> + + <description> + OpenFAST is a 100% Java implementation of the FAST Protocol. + </description> + + <developers> + <developer> + <name>Jacob Northey</name> + <organization>Lasalletech</organization> + <organizationUrl> + http://www.lasalletech.com/ + </organizationUrl> + <roles> + <role>architect</role> + <role>developer</role> + </roles> + <timezone>-5</timezone> + </developer> + <developer> + <name>Craig Otis</name> + <organization>Lasalletech</organization> + <organizationUrl> + http://www.lasalletech.com/ + </organizationUrl> + <roles> + <role>developer</role> + </roles> + <timezone>-5</timezone> + </developer> + </developers> + + <contributors> + <contributor> + <name>Stefan Schwendiman</name> + <organization>Swiss Exchange</organization> + <organizationUrl>http://www.swx.com</organizationUrl> + <roles> + <role>tester</role> + </roles> + <timezone>+1</timezone> + </contributor> + </contributors> + + <licenses> + <license> + <name>Mozilla Public License Version 1.1</name> + <url>http://www.mozilla.org/MPL/MPL-1.1.html</url> + <distribution>repo</distribution> + </license> + </licenses> + + <url>http://www.openfast.org</url> + <inceptionYear>2006</inceptionYear> + + <issueManagement> + <system>jira</system> + <url>http://www.quickfixj.org/jira/browse/FAST</url> + </issueManagement> + + <scm> + <connection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.1</connection> + <developerConnection>scm:svn:https://openfast.svn.sourceforge.net/svnroot/openfast/tags/openfast-1.0.1</developerConnection> + <url>http://openfast.svn.sourceforge.net/viewvc/openfast/tags/openfast-1.0.1</url> + </scm> + + <mailingLists> + <mailingList> + <name>OpenFAST Users Mailing List</name> + <subscribe> + http://lists.sourceforge.net/mailman/listinfo/openfast-user + </subscribe> + <unsubscribe> + http://lists.sourceforge.net/mailman/listinfo/openfast-user + </unsubscribe> + <archive> + https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-user + </archive> + <post>ope...@li...</post> + </mailingList> + <mailingList> + <name>OpenFAST Commits Mailing List</name> + <subscribe> + http://lists.sourceforge.net/mailman/listinfo/openfast-commit + </subscribe> + <unsubscribe> + http://lists.sourceforge.net/mailman/listinfo/openfast-commit + </unsubscribe> + <archive> + https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-commit + </archive> + <post>ope...@li...</post> + </mailingList> + <mailingList> + <name>OpenFAST Announcements Mailing List</name> + <subscribe> + http://lists.sourceforge.net/mailman/listinfo/openfast-announce + </subscribe> + <unsubscribe> + http://lists.sourceforge.net/mailman/listinfo/openfast-announce + </unsubscribe> + <archive> + https://sourceforge.net/mailarchive/forum.php?forum_name=openfast-announce + </archive> + <post>ope...@li...</post> + </mailingList> + </mailingLists> + + <build> + <resources> + <resource> + <directory>src/main/resources</directory> + <excludes> + <exclude>**/*.bat</exclude> + <exclude>**/*.sh</exclude> + </excludes> + </resource> + <resource> + <directory>src/main/java</directory> + <excludes> + <exclude>**/*.java</exclude> + </excludes> + </resource> + </resources> + + <extensions> + <extension> + <groupId>org.apache.maven.wagon</groupId> + <artifactId>wagon-ssh</artifactId> + <version>1.0-beta-2</version> + </extension> + </extensions> + + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + <plugin> + <artifactId>maven-release-plugin</artifactId> + <configuration> + <tagBase> + https://openfast.svn.sourceforge.net/svnroot/openfast/tags + </tagBase> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <executions> + <execution> + <id>attach-javadocs</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <descriptors> + <descriptor>src/assembly/source.xml</descriptor> + <descriptor>src/assembly/binary.xml</descriptor> + </descriptors> + </configuration> + <executions> + <execution> + <id>make-assembly</id> + <phase>deploy</phase> + <goals> + <goal>attached</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>commons-cli</groupId> + <artifactId>commons-cli</artifactId> + <version>1.1</version> + <optional>true</optional> + </dependency> + <dependency> + <groupId>com.thoughtworks.xstream</groupId> + <artifactId>xstream</artifactId> + <version>1.3</version> + <optional>true</optional> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.2</version> + <scope>test</scope> + </dependency> + </dependencies> + + <distributionManagement> + <repository> + <id>sourceforge.net</id> + <name>Sourceforge.net Repository</name> + <url> + scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/release + </url> + </repository> + <snapshotRepository> + <id>sourceforge.net</id> + <name>Sourceforge.net Snapshot Repository</name> + <url> + scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/snapshot + </url> + </snapshotRepository> + <site> + <id>sourceforge.net</id> + <name>Sourceforge.net OpenFAST Web Site</name> + <url> + scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/ + </url> + </site> + </distributionManagement> +</project> \ No newline at end of file Deleted: tags/openfast-1.0.1/src/main/java/org/openfast/Context.java =================================================================== --- trunk/src/main/java/org/openfast/Context.java 2010-05-25 22:16:11 UTC (rev 213) +++ tags/openfast-1.0.1/src/main/java/org/openfast/Context.java 2010-06-04 01:36:39 UTC (rev 216) @@ -1,186 +0,0 @@ -/* -The contents of this file are subject to the Mozilla Public License -Version 1.1 (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.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" -basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -License for the specific language governing rights and limitations -under the License. - -The Original Code is OpenFAST. - -The Initial Developer of the Original Code is The LaSalle Technology -Group, LLC. Portions created by The LaSalle Technology Group, LLC -are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. - -Contributor(s): Jacob Northey <ja...@la...> - Craig Otis <co...@la...> - */ -package org.openfast; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import org.openfast.debug.BasicDecodeTrace; -import org.openfast.debug.BasicEncodeTrace; -import org.openfast.debug.Trace; -import org.openfast.error.ErrorHandler; -import org.openfast.error.FastConstants; -import org.openfast.logging.FastMessageLogger; -import org.openfast.template.BasicTemplateRegistry; -import org.openfast.template.Group; -import org.openfast.template.MessageTemplate; -import org.openfast.template.TemplateRegisteredListener; -import org.openfast.template.TemplateRegistry; -import org.openfast.util.Cache; -import org.openfast.util.UnboundedCache; - -/** - * Manages current state of an encoding or decoding process. Each encoder/decoder should have a separate context - * and contexts should never be shared. - * @author Jacob Northey - */ -public class Context implements OpenFastContext { - private TemplateRegistry templateRegistry = new BasicTemplateRegistry(); - private int lastTemplateId; - private final Map dictionaries = new HashMap(); - private ErrorHandler errorHandler = ErrorHandler.DEFAULT; - private QName currentApplicationType; - private final List listeners = Collections.EMPTY_LIST; - private boolean traceEnabled; - private Trace encodeTrace; - private Trace decodeTrace; - private final Map caches = new HashMap(); - private OpenFastContext parentContext; - private FastMessageLogger logger = null; - - public Context() { - this(new NullOpenFastContext()); - } - public Context(OpenFastContext context) { - this.parentContext = context; - dictionaries.put("global", new GlobalDictionary()); - dictionaries.put("template", new TemplateDictionary()); - dictionaries.put("type", new ApplicationTypeDictionary()); - } - public int getTemplateId(MessageTemplate template) { - if (!templateRegistry.isRegistered(template)) { - errorHandler.error(FastConstants.D9_TEMPLATE_NOT_REGISTERED, "The template " + template + " has not been registered."); - return 0; - } - return templateRegistry.getId(template); - } - public MessageTemplate getTemplate(int templateId) { - if (!templateRegistry.isRegistered(templateId)) { - errorHandler.error(FastConstants.D9_TEMPLATE_NOT_REGISTERED, "The template with id " + templateId - + " has not been registered."); - return null; - } - return templateRegistry.get(templateId); - } - public void registerTemplate(int templateId, MessageTemplate template) { - templateRegistry.register(templateId, template); - Iterator iter = listeners.iterator(); - while (iter.hasNext()) { - ((TemplateRegisteredListener) iter.next()).templateRegistered(template, templateId); - } - } - public int getLastTemplateId() { - return lastTemplateId; - } - public void setLastTemplateId(int templateId) { - lastTemplateId = templateId; - } - public ScalarValue lookup(String dictionary, Group group, QName key) { - if (group.hasTypeReference()) - currentApplicationType = group.getTypeReference(); - return getDictionary(dictionary).lookup(group, key, currentApplicationType); - } - private Dictionary getDictionary(String dictionary) { - if (!dictionaries.containsKey(dictionary)) - dictionaries.put(dictionary, new GlobalDictionary()); - return (Dictionary) dictionaries.get(dictionary); - } - public void store(String dictionary, Group group, QName key, ScalarValue valueToEncode) { - if (group.hasTypeReference()) - currentApplicationType = group.getTypeReference(); - getDictionary(dictionary).store(group, currentApplicationType, key, valueToEncode); - } - public void reset() { - for (Iterator iter = dictionaries.values().iterator(); iter.hasNext();) { - Dictionary dict = (Dictionary) iter.next(); - dict.reset(); - } - } - public void setErrorHandler(ErrorHandler errorHandler) { - this.errorHandler = errorHandler; - } - public void newMessage(MessageTemplate template) { - currentApplicationType = (template.hasTypeReference()) ? template.getTypeReference() : FastConstants.ANY_TYPE; - } - public void setCurrentApplicationType(QName name) { - currentApplicationType = name; - } - public TemplateRegistry getTemplateRegistry() { - return templateRegistry; - } - public void setTemplateRegistry(TemplateRegistry registry) { - this.templateRegistry = registry; - } - public boolean isTraceEnabled() { - return traceEnabled; - } - public void startTrace() { - if (isTraceEnabled()) { - if (decodeTrace == null) { - setDecodeTrace(new BasicDecodeTrace()); - } - if (encodeTrace == null) { - setEncodeTrace(new BasicEncodeTrace()); - } - } - } - public void setTraceEnabled(boolean enabled) { - this.traceEnabled = enabled; - } - public void setEncodeTrace(BasicEncodeTrace encodeTrace) { - this.encodeTrace = encodeTrace; - } - public Trace getEncodeTrace() { - return encodeTrace; - } - public void setDecodeTrace(Trace decodeTrace) { - this.decodeTrace = decodeTrace; - } - public Trace getDecodeTrace() { - return decodeTrace; - } - public Cache getCache(QName key) { - if (!caches.containsKey(key)) { - caches.put(key, new UnboundedCache()); - } - return (Cache) caches.get(key); - } - public void store(QName key, int index, ScalarValue value) { - if (!caches.containsKey(key)) { - caches.put(key, new UnboundedCache()); - } - ((Cache)caches.get(key)).store(index, value); - } - @Override - public FastMessageLogger getLogger() { - if (logger == null) { - return parentContext.getLogger(); - } - return logger; - } - - @Override - public void setLogger(FastMessageLogger logger) { - this.logger = logger; - } -} Copied: tags/openfast-1.0.1/src/main/java/org/openfast/Context.java (from rev 214, trunk/src/main/java/org/openfast/Context.java) =================================================================== --- tags/openfast-1.0.1/src/main/java/org/openfast/Context.java (rev 0) +++ tags/openfast-1.0.1/src/main/java/org/openfast/Context.java 2010-06-04 01:36:39 UTC (rev 216) @@ -0,0 +1,184 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.1 (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.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +License for the specific language governing rights and limitations +under the License. + +The Original Code is OpenFAST. + +The Initial Developer of the Original Code is The LaSalle Technology +Group, LLC. Portions created by The LaSalle Technology Group, LLC +are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. + +Contributor(s): Jacob Northey <ja...@la...> + Craig Otis <co...@la...> + */ +package org.openfast; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import org.openfast.debug.BasicDecodeTrace; +import org.openfast.debug.BasicEncodeTrace; +import org.openfast.debug.Trace; +import org.openfast.error.ErrorHandler; +import org.openfast.error.FastConstants; +import org.openfast.logging.FastMessageLogger; +import org.openfast.template.BasicTemplateRegistry; +import org.openfast.template.Group; +import org.openfast.template.MessageTemplate; +import org.openfast.template.TemplateRegisteredListener; +import org.openfast.template.TemplateRegistry; +import org.openfast.util.Cache; +import org.openfast.util.UnboundedCache; + +/** + * Manages current state of an encoding or decoding process. Each encoder/decoder should have a separate context + * and contexts should never be shared. + * @author Jacob Northey + */ +public class Context implements OpenFastContext { + private TemplateRegistry templateRegistry = new BasicTemplateRegistry(); + private int lastTemplateId; + private final Map dictionaries = new HashMap(); + private ErrorHandler errorHandler = ErrorHandler.DEFAULT; + private QName currentApplicationType; + private final List listeners = Collections.EMPTY_LIST; + private boolean traceEnabled; + private Trace encodeTrace; + private Trace decodeTrace; + private final Map caches = new HashMap(); + private final OpenFastContext parentContext; + private FastMessageLogger logger = null; + + public Context() { + this(new NullOpenFastContext()); + } + public Context(OpenFastContext context) { + this.parentContext = context; + dictionaries.put("global", new GlobalDictionary()); + dictionaries.put("template", new TemplateDictionary()); + dictionaries.put("type", new ApplicationTypeDictionary()); + } + public int getTemplateId(MessageTemplate template) { + if (!templateRegistry.isRegistered(template)) { + errorHandler.error(FastConstants.D9_TEMPLATE_NOT_REGISTERED, "The template " + template + " has not been registered."); + return 0; + } + return templateRegistry.getId(template); + } + public MessageTemplate getTemplate(int templateId) { + if (!templateRegistry.isRegistered(templateId)) { + errorHandler.error(FastConstants.D9_TEMPLATE_NOT_REGISTERED, "The template with id " + templateId + + " has not been registered."); + return null; + } + return templateRegistry.get(templateId); + } + public void registerTemplate(int templateId, MessageTemplate template) { + templateRegistry.register(templateId, template); + Iterator iter = listeners.iterator(); + while (iter.hasNext()) { + ((TemplateRegisteredListener) iter.next()).templateRegistered(template, templateId); + } + } + public int getLastTemplateId() { + return lastTemplateId; + } + public void setLastTemplateId(int templateId) { + lastTemplateId = templateId; + } + public ScalarValue lookup(String dictionary, Group group, QName key) { + if (group.hasTypeReference()) + currentApplicationType = group.getTypeReference(); + return getDictionary(dictionary).lookup(group, key, currentApplicationType); + } + private Dictionary getDictionary(String dictionary) { + if (!dictionaries.containsKey(dictionary)) + dictionaries.put(dictionary, new GlobalDictionary()); + return (Dictionary) dictionaries.get(dictionary); + } + public void store(String dictionary, Group group, QName key, ScalarValue valueToEncode) { + if (group.hasTypeReference()) + currentApplicationType = group.getTypeReference(); + getDictionary(dictionary).store(group, currentApplicationType, key, valueToEncode); + } + public void reset() { + for (Iterator iter = dictionaries.values().iterator(); iter.hasNext();) { + Dictionary dict = (Dictionary) iter.next(); + dict.reset(); + } + } + public void setErrorHandler(ErrorHandler errorHandler) { + this.errorHandler = errorHandler; + } + public void newMessage(MessageTemplate template) { + currentApplicationType = (template.hasTypeReference()) ? template.getTypeReference() : FastConstants.ANY_TYPE; + } + public void setCurrentApplicationType(QName name) { + currentApplicationType = name; + } + public TemplateRegistry getTemplateRegistry() { + return templateRegistry; + } + public void setTemplateRegistry(TemplateRegistry registry) { + this.templateRegistry = registry; + } + public boolean isTraceEnabled() { + return traceEnabled; + } + public void startTrace() { + if (isTraceEnabled()) { + if (decodeTrace == null) { + setDecodeTrace(new BasicDecodeTrace()); + } + if (encodeTrace == null) { + setEncodeTrace(new BasicEncodeTrace()); + } + } + } + public void setTraceEnabled(boolean enabled) { + this.traceEnabled = enabled; + } + public void setEncodeTrace(BasicEncodeTrace encodeTrace) { + this.encodeTrace = encodeTrace; + } + public Trace getEncodeTrace() { + return encodeTrace; + } + public void setDecodeTrace(Trace decodeTrace) { + this.decodeTrace = decodeTrace; + } + public Trace getDecodeTrace() { + return decodeTrace; + } + public Cache getCache(QName key) { + if (!caches.containsKey(key)) { + caches.put(key, new UnboundedCache()); + } + return (Cache) caches.get(key); + } + public void store(QName key, int index, ScalarValue value) { + if (!caches.containsKey(key)) { + caches.put(key, new UnboundedCache()); + } + ((Cache)caches.get(key)).store(index, value); + } + public FastMessageLogger getLogger() { + if (logger == null) { + return parentContext.getLogger(); + } + return logger; + } + + public void setLogger(FastMessageLogger logger) { + this.logger = logger; + } +} Deleted: tags/openfast-1.0.1/src/main/java/org/openfast/NullOpenFastContext.java =================================================================== --- trunk/src/main/java/org/openfast/NullOpenFastContext.java 2010-05-25 22:16:11 UTC (rev 213) +++ tags/openfast-1.0.1/src/main/java/org/openfast/NullOpenFastContext.java 2010-06-04 01:36:39 UTC (rev 216) @@ -1,46 +0,0 @@ -package org.openfast; - -import org.openfast.error.ErrorHandler; -import org.openfast.logging.FastMessageLogger; -import org.openfast.template.MessageTemplate; -import org.openfast.template.TemplateRegistry; - -public class NullOpenFastContext implements OpenFastContext { - - @Override - public MessageTemplate getTemplate(int templateId) { - return null; - } - - @Override - public int getTemplateId(MessageTemplate template) { - return 0; - } - - @Override - public TemplateRegistry getTemplateRegistry() { - return null; - } - - @Override - public void registerTemplate(int templateId, MessageTemplate template) { - } - - @Override - public void setErrorHandler(ErrorHandler errorHandler) { - } - - @Override - public void setTemplateRegistry(TemplateRegistry registry) { - } - - @Override - public FastMessageLogger getLogger() { - return FastMessageLogger.NULL; - } - - @Override - public void setLogger(FastMessageLogger logger) { - } - -} Copied: tags/openfast-1.0.1/src/main/java/org/openfast/NullOpenFastContext.java (from rev 214, trunk/src/main/java/org/openfast/NullOpenFastContext.java) =================================================================== --- tags/openfast-1.0.1/src/main/java/org/openfast/NullOpenFastContext.java (rev 0) +++ tags/openfast-1.0.1/src/main/java/org/openfast/NullOpenFastContext.java 2010-06-04 01:36:39 UTC (rev 216) @@ -0,0 +1,38 @@ +package org.openfast; + +import org.openfast.error.ErrorHandler; +import org.openfast.logging.FastMessageLogger; +import org.openfast.template.MessageTemplate; +import org.openfast.template.TemplateRegistry; + +public class NullOpenFastContext implements OpenFastContext { + + public MessageTemplate getTemplate(int templateId) { + return null; + } + + public int getTemplateId(MessageTemplate template) { + return 0; + } + + public TemplateRegistry getTemplateRegistry() { + return null; + } + + public void registerTemplate(int templateId, MessageTemplate template) { + } + + public void setErrorHandler(ErrorHandler errorHandler) { + } + + public void setTemplateRegistry(TemplateRegistry registry) { + } + + public FastMessageLogger getLogger() { + return FastMessageLogger.NULL; + } + + public void setLogger(FastMessageLogger logger) { + } + +} Deleted: tags/openfast-1.0.1/src/main/java/org/openfast/logging/FastMessageLogger.java =================================================================== --- trunk/src/main/java/org/openfast/logging/FastMessageLogger.java 2010-05-25 22:16:11 UTC (rev 213) +++ tags/openfast-1.0.1/src/main/java/org/openfast/logging/FastMessageLogger.java 2010-06-04 01:36:39 UTC (rev 216) @@ -1,29 +0,0 @@ -package org.openfast.logging; - -import org.openfast.Message; - -public interface FastMessageLogger { - - public enum Direction { - INBOUND("[<--]"), OUTBOUND("[-->]"); - - private String directionString; - - private Direction(String direction) { - this.directionString = direction; - } - - @Override - public String toString() { - return directionString; - } - } - - FastMessageLogger NULL = new FastMessageLogger() { - @Override - public void log(Message message, byte[] bytes, Direction direction) { - } - }; - - public void log(Message message, byte[] bytes, Direction direction); -} Copied: tags/openfast-1.0.1/src/main/java/org/openfast/logging/FastMessageLogger.java (from rev 214, trunk/src/main/java/org/openfast/logging/FastMessageLogger.java) =================================================================== --- tags/openfast-1.0.1/src/main/java/org/openfast/logging/FastMessageLogger.java (rev 0) +++ tags/openfast-1.0.1/src/main/java/org/openfast/logging/FastMessageLogger.java 2010-06-04 01:36:39 UTC (rev 216) @@ -0,0 +1,28 @@ +package org.openfast.logging; + +import org.openfast.Message; + +public interface FastMessageLogger { + + public enum Direction { + INBOUND("[<--]"), OUTBOUND("[-->]"); + + private final String directionString; + + private Direction(String direction) { + this.directionString = direction; + } + + @Override + public String toString() { + return directionString; + } + } + + FastMessageLogger NULL = new FastMessageLogger() { + public void log(Message message, byte[] bytes, Direction direction) { + } + }; + + public void log(Message message, byte[] bytes, Direction direction); +} Deleted: tags/openfast-1.0.1/src/main/java/org/openfast/logging/FileFastMessageLogger.java =================================================================== --- trunk/src/main/java/org/openfast/logging/FileFastMessageLogger.java 2010-05-25 22:16:11 UTC (rev 213) +++ tags/openfast-1.0.1/src/main/java/org/openfast/logging/FileFastMessageLogger.java 2010-06-04 01:36:39 UTC (rev 216) @@ -1,77 +0,0 @@ -package org.openfast.logging; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Date; - -import org.openfast.Message; -import org.openfast.template.MessageTemplate; - -public class FileFastMessageLogger implements FastMessageLogger { - private File file; - private OutputStream out; - - public FileFastMessageLogger(String filePath) { - this(new File(filePath)); - } - - public FileFastMessageLogger(File f) { - if (f.exists() && !f.canWrite()) - throw new IllegalArgumentException("Unable to write to file: " + f.getAbsolutePath()); - this.file = f; - } - - @Override - public void log(Message message, byte[] bytes, Direction direction) { - try { - createOut(); - out.write(new Date().toString().getBytes()); - out.write('\n'); - out.write((direction + " ").getBytes()); - out.write(print(message)); - out.write('\n'); - out.write(bytes); - out.write('\n'); - } catch (IOException e) { - e.printStackTrace(); - } - } - - private byte[] print(Message message) { - StringBuilder msgBuilder = new StringBuilder(); - MessageTemplate template = message.getTemplate(); - msgBuilder.append(template.getName()).append("[ "); - for (int i=1; i<template.getFieldCount(); i++) { - msgBuilder.append(template.getField(i).getName()).append('='); - if (message.isDefined(i)) { - msgBuilder.append(message.getString(i)); - } else { - msgBuilder.append("null"); - } - msgBuilder.append(' '); - } - msgBuilder.append(']'); - return msgBuilder.toString().getBytes(); - } - - private void createOut() throws IOException { - if (out == null) { - if (!file.exists()) { - if (!file.getParentFile().exists()) { - file.getParentFile().mkdirs(); - } - file.createNewFile(); - } - out = new FileOutputStream(file, true); - } - } - - public void close() { - try { - out.close(); - } catch (Exception e) { - } - } -} Copied: tags/openfast-1.0.1/src/main/java/org/openfast/logging/FileFastMessageLogger.java (from rev 214, trunk/src/main/java/org/openfast/logging/FileFastMessageLogger.java) =================================================================== --- tags/openfast-1.0.1/src/main/java/org/openfast/logging/FileFastMessageLogger.java (rev 0) +++ tags/openfast-1.0.1/src/main/java/org/openfast/logging/FileFastMessageLogger.java 2010-06-04 01:36:39 UTC (rev 216) @@ -0,0 +1,75 @@ +package org.openfast.logging; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Date; +import org.openfast.Message; +import org.openfast.template.MessageTemplate; + +public class FileFastMessageLogger implements FastMessageLogger { + private final File file; + private OutputStream out; + + public FileFastMessageLogger(String filePath) { + this(new File(filePath)); + } + + public FileFastMessageLogger(File f) { + if (f.exists() && !f.canWrite()) + throw new IllegalArgumentException("Unable to write to file: " + f.getAbsolutePath()); + this.file = f; + } + + public void log(Message message, byte[] bytes, Direction direction) { + try { + createOut(); + out.write(new Date().toString().getBytes()); + out.write('\n'); + out.write((direction + " ").getBytes()); + out.write(print(message)); + out.write('\n'); + out.write(bytes); + out.write('\n'); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private byte[] print(Message message) { + StringBuilder msgBuilder = new StringBuilder(); + MessageTemplate template = message.getTemplate(); + msgBuilder.append(template.getName()).append("[ "); + for (int i=1; i<template.getFieldCount(); i++) { + msgBuilder.append(template.getField(i).getName()).append('='); + if (message.isDefined(i)) { + msgBuilder.append(message.getString(i)); + } else { + msgBuilder.append("null"); + } + msgBuilder.append(' '); + } + msgBuilder.append(']'); + return msgBuilder.toString().getBytes(); + } + + private void createOut() throws IOException { + if (out == null) { + if (!file.exists()) { + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + file.createNewFile(); + } + out = new FileOutputStream(file, true); + } + } + + public void close() { + try { + out.close(); + } catch (Exception e) { + } + } +} Deleted: tags/openfast-1.0.1/src/main/java/org/openfast/session/BasicOpenFastContext.java =================================================================== --- trunk/src/main/java/org/openfast/session/BasicOpenFastContext.java 2010-05-25 22:16:11 UTC (rev 213) +++ tags/openfast-1.0.1/src/main/java/org/openfast/session/BasicOpenFastContext.java 2010-06-04 01:36:39 UTC (rev 216) @@ -1,53 +0,0 @@ -package org.openfast.session; - -import org.openfast.OpenFastContext; -import org.openfast.error.ErrorHandler; -import org.openfast.logging.FastMessageLogger; -import org.openfast.template.MessageTemplate; -import org.openfast.template.TemplateRegistry; - -public class BasicOpenFastContext implements OpenFastContext { - - private FastMessageLogger logger; - - @Override - public MessageTemplate getTemplate(int templateId) { - return null; - } - - @Override - public int getTemplateId(MessageTemplate template) { - return 0; - } - - @Override - public TemplateRegistry getTemplateRegistry() { - return null; - } - - @Override - public void registerTemplate(int templateId, MessageTemplate template) { - - } - - @Override - public void setErrorHandler(ErrorHandler errorHandler) { - - } - - @Override - public void setTemplateRegistry(TemplateRegistry registry) { - - } - - @Override - public FastMessageLogger getLogger() { - return this.logger != null ? this.logger : FastMessageLogger.NULL; - } - - @Override - public void setLogger(FastMessageLogger logger) { - this.logger = logger; - } - -} Copied: tags/openfast-1.0.1/src/main/java/org/openfast/session/BasicOpenFastContext.java (from rev 214, trunk/src/main/java/org/openfast/session/BasicOpenFastContext.java) =================================================================== --- tags/openfast-1.0.1/src/main/java/org/openfast/session/BasicOpenFastContext.java (rev 0) +++ tags/openfast-1.0.1/src/main/java/org/openfast/session/BasicOpenFastContext.java 2010-06-04 01:36:39 UTC (rev 216) @@ -0,0 +1,45 @@ +package org.openfast.session; + +import org.openfast.OpenFastContext; +import org.openfast.error.ErrorHandler; +import org.openfast.logging.FastMessageLogger; +import org.openfast.template.MessageTemplate; +import org.openfast.template.TemplateRegistry; + +public class BasicOpenFastContext implements OpenFastContext { + + private FastMessageLogger logger; + + public MessageTemplate getTemplate(int templateId) { + return null; + } + + public int getTemplateId(MessageTemplate template) { + return 0; + } + + public TemplateRegistry getTemplateRegistry() { + return null; + } + + public void registerTemplate(int templateId, MessageTemplate template) { + + } + + public void setErrorHandler(ErrorHandler errorHandler) { + + } + + public void setTemplateRegistry(TemplateRegistry registry) { + + } + + public FastMessageLogger getLogger() { + return this.logger != null ? this.logger : FastMessageLogger.NULL; + } + + public void setLogger(FastMessageLogger logger) { + this.logger = logger; + } + +} Deleted: tags/openfast-1.0.1/src/main/java/org/openfast/template/BasicTemplateRegistry.java =================================================================== --- trunk/src/main/java/org/openfast/template/BasicTemplateRegistry.java 2010-05-25 22:16:11 UTC (rev 213) +++ tags/openfast-1.0.1/src/main/java/org/openfast/template/BasicTemplateRegistry.java 2010-06-04 01:36:39 UTC (rev 216) @@ -1,123 +0,0 @@ -/* -The contents of this file are subject to the Mozilla Public License -Version 1.1 (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.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS IS" -basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the -License for the specific language governing rights and limitations -under the License. - -The Original Code is OpenFAST. - -The Initial Developer of the Original Code is The LaSalle Technology -Group, LLC. Portions created by The LaSalle Technology Group, LLC -are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. - -Contributor(s): Jacob Northey <ja...@la...> - Craig Otis <co...@la...> - */ -package org.openfast.template; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.openfast.QName; -import org.openfast.util.IntegerMap; -import org.openfast.util.SimpleIntegerMap; - -public class BasicTemplateRegistry extends AbstractTemplateRegistry { - private Map nameMap = new HashMap(); - private IntegerMap idMap = new SimpleIntegerMap(); - private Map templateMap = new HashMap(); - private List templates = new ArrayList(); - - public void register(int id, MessageTemplate template) { - define(template); - Integer tid = new Integer(id); - idMap.put(id, template); - templateMap.put(template, tid); - notifyTemplateRegistered(template, id); - } - public void register(int id, QName name) { - if (!nameMap.containsKey(name)) - throw new IllegalArgumentException("The template named " + name + " is not defined."); - Integer tid = new Integer(id); - MessageTemplate template = (MessageTemplate) nameMap.get(name); - templateMap.put(template, tid); - idMap.put(id, template); - notifyTemplateRegistered(template, id); - } - public void define(MessageTemplate template) { - if (!templates.contains(template)) { - nameMap.put(template.getQName(), template); - templates.add(template); - } - } - public int getId(QName name) { - Object template = nameMap.get(name); - if (template == null || !templateMap.containsKey(template)) - return -1; - return ((Integer) templateMap.get(template)).intValue(); - } - public MessageTemplate get(int templateId) { - return (MessageTemplate) idMap.get(templateId); - } - public MessageTemplate get(QName name) { - return (MessageTemplate) nameMap.get(name); - } - public int getId(MessageTemplate template) { - if (!isRegistered(template)) - return -1; - return ((Integer) templateMap.get(template)).intValue(); - } - public boolean isRegistered(QName name) { - return nameMap.containsKey(name); - } - public boolean isRegistered(int templateId) { - return idMap.containsKey(templateId); - } - public boolean isRegistered(MessageTemplate template) { - return templateMap.containsKey(template); - } - public boolean isDefined(QName name) { - return nameMap.containsKey(name); - } - public MessageTemplate[] getTemplates() { - return (MessageTemplate[]) templates.toArray(new MessageTemplate[templates.size()]); - } - public void remove(QName name) { - MessageTemplate template = (MessageTemplate) nameMap.remove(name); - Object id = templateMap.remove(template); - idMap.remove(((Integer) id).intValue()); - templates.remove(template); - } - public void remove(MessageTemplate template) { - Object id = templateMap.remove(template); - nameMap.remove(template.getName()); - idMap.remove(((Integer)id).intValue()); - } - public void remove(int id) { - MessageTemplate template = (MessageTemplate) idMap.remove(id); - templateMap.remove(template); - nameMap.remove(template.getName()); - } - public void registerAll(TemplateRegistry registry) { - if (registry == null) return; - MessageTemplate[] templates = registry.getTemplates(); - if (templates == null) return; - for (int i = 0; i < templates.length; i++) { - register(registry.getId(templates[i]), templates[i]); - } - } - public Iterator nameIterator() { - return nameMap.keySet().iterator(); - } - public Iterator iterator() { - return templates.iterator(); - } -} Copied: tags/openfast-1.0.1/src/main/java/org/openfast/template/BasicTemplateRegistry.java (from rev 214, trunk/src/main/java/org/openfast/template/BasicTemplateRegistry.java) =================================================================== --- tags/openfast-1.0.1/src/main/java/org/openfast/template/BasicTemplateRegistry.java (rev 0) +++ tags/openfast-1.0.1/src/main/java/org/openfast/template/BasicTemplateRegistry.java 2010-06-04 01:36:39 UTC (rev 216) @@ -0,0 +1,122 @@ +/* +The contents of this file are subject to the Mozilla Public License +Version 1.1 (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.mozilla.org/MPL/ + +Software distributed under the License is distributed on an "AS IS" +basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +License for the specific language governing rights and limitations +under the License. + +The Original Code is OpenFAST. + +The Initial Developer of the Original Code is The LaSalle Technology +Group, LLC. Portions created by The LaSalle Technology Group, LLC +are Copyright (C) The LaSalle Technology Group, LLC. All Rights Reserved. + +Contributor(s): Jacob Northey <ja...@la...> + Craig Otis <co...@la...> + */ +package org.openfast.template; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import org.openfast.QName; +import org.openfast.util.IntegerMap; +import org.openfast.util.SimpleIntegerMap; + +public class BasicTemplateRegistry extends AbstractTemplateRegistry { + private final Map nameMap = new HashMap(); + private final IntegerMap idMap = new SimpleIntegerMap(); + private final Map templateMap = new HashMap(); + private final List templates = new ArrayList(); + + public void register(int id, MessageTemplate template) { + define(template); + Integer tid = new Integer(id); + idMap.put(id, template); + templateMap.put(template, tid); + notifyTemplateRegistered(template, id); + } + public void register(int id, QName name) { + if (!nameMap.containsKey(name)) + throw new IllegalArgumentException("The template named " + name + " is not defined."); + Integer tid = new Integer(id); + MessageTemplate template = (MessageTemplate) nameMap.get(name); + templateMap.put(template, tid); + idMap.put(id, template); + notifyTemplateRegistered(template, id); + } + public void define(MessageTemplate template) { + if (!templates.contains(template)) { + nameMap.put(template.getQName(), template); + templates.add(template); + } + } + public int getId(QName name) { + Object template = nameMap.get(name); + if (template == null || !templateMap.containsKey(template)) + return -1; + return ((Integer) templateMap.get(template)).intValue(); + } + public MessageTemplate get(int templateId) { + return (MessageTemplate) idMap.get(templateId); + } + public MessageTemplate get(QName name) { + return (MessageTemplate) nameMap.get(name); + } + public int getId(MessageTemplate template) { + if (!isRegistered(template)) + return -1; + return ((Integer) templateMap.get(template)).intValue(); + } + public boolean isRegistered(QName name) { + return nameMap.containsKey(name); + } + public boolean isRegistered(int templateId) { + return idMap.containsKey(templateId); + } + public boolean isRegistered(MessageTemplate template) { + return templateMap.containsKey(template); + } + public boolean isDefined(QName name) { + return nameMap.containsKey(name); + } + public MessageTemplate[] getTemplates() { + return (MessageTemplate[]) templates.toArray(new MessageTemplate[templates.size()]); + } + public void remove(QName name) { + MessageTemplate template = (MessageTemplate) nameMap.remove(name); + Object id = templateMap.remove(template); + idMap.remove(((Integer) id).intValue()); + templates.remove(template); + } + public void remove(MessageTemplate template) { + Object id = templateMap.remove(template); + nameMap.remove(template.getName()); + idMap.remove(((Integer)id).intValue()); + } + public void remove(int id) { + MessageTemplate template = (MessageTemplate) idMap.remove(id); + templateMap.remove(template); + nameMap.remove(template.getName()); + } + public void registerAll(TemplateRegistry registry) { + if (registry == null) return; + MessageTemplate[] templates = registry.getTemplates(); + if (templates == null) return; + for (int i = 0; i < templates.length; i++) { + register(registry.getId(templates[i]), templates[i]); + } + } + public Iterator nameIterator() { + return nameMap.keySet().iterator(); + } + public Iterator iterator() { + return templates.iterator(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-06-04 01:36:37
|
Revision: 215 http://openfast.svn.sourceforge.net/openfast/?rev=215&view=rev Author: jacob_northey Date: 2010-06-04 01:36:32 +0000 (Fri, 04 Jun 2010) Log Message: ----------- [maven-release-plugin] prepare release openfast-1.0.1 Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-06-04 01:34:58 UTC (rev 214) +++ trunk/pom.xml 2010-06-04 01:36:32 UTC (rev 215) @@ -1,10 +1,9 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.openfast</groupId> <artifactId>openfast</artifactId> <packaging>jar</packaging> - <version>1.1.0-SNAPSHOT</version> + <version>1.0.1</version> <organization> <name>The LaSalle Technology Group, LLC</name> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-06-04 01:35:05
|
Revision: 214 http://openfast.svn.sourceforge.net/openfast/?rev=214&view=rev Author: jacob_northey Date: 2010-06-04 01:34:58 +0000 (Fri, 04 Jun 2010) Log Message: ----------- Formatting changes Modified Paths: -------------- trunk/src/main/java/org/openfast/Context.java trunk/src/main/java/org/openfast/NullOpenFastContext.java trunk/src/main/java/org/openfast/logging/FastMessageLogger.java trunk/src/main/java/org/openfast/logging/FileFastMessageLogger.java trunk/src/main/java/org/openfast/session/BasicOpenFastContext.java trunk/src/main/java/org/openfast/template/BasicTemplateRegistry.java Modified: trunk/src/main/java/org/openfast/Context.java =================================================================== --- trunk/src/main/java/org/openfast/Context.java 2010-05-25 22:16:11 UTC (rev 213) +++ trunk/src/main/java/org/openfast/Context.java 2010-06-04 01:34:58 UTC (rev 214) @@ -55,7 +55,7 @@ private Trace encodeTrace; private Trace decodeTrace; private final Map caches = new HashMap(); - private OpenFastContext parentContext; + private final OpenFastContext parentContext; private FastMessageLogger logger = null; public Context() { @@ -171,15 +171,13 @@ } ((Cache)caches.get(key)).store(index, value); } - @Override public FastMessageLogger getLogger() { if (logger == null) { return parentContext.getLogger(); } return logger; } - - @Override + public void setLogger(FastMessageLogger logger) { this.logger = logger; } Modified: trunk/src/main/java/org/openfast/NullOpenFastContext.java =================================================================== --- trunk/src/main/java/org/openfast/NullOpenFastContext.java 2010-05-25 22:16:11 UTC (rev 213) +++ trunk/src/main/java/org/openfast/NullOpenFastContext.java 2010-06-04 01:34:58 UTC (rev 214) @@ -7,39 +7,31 @@ public class NullOpenFastContext implements OpenFastContext { - @Override public MessageTemplate getTemplate(int templateId) { return null; } - @Override public int getTemplateId(MessageTemplate template) { return 0; } - @Override public TemplateRegistry getTemplateRegistry() { return null; } - @Override public void registerTemplate(int templateId, MessageTemplate template) { } - @Override public void setErrorHandler(ErrorHandler errorHandler) { } - @Override public void setTemplateRegistry(TemplateRegistry registry) { } - @Override public FastMessageLogger getLogger() { return FastMessageLogger.NULL; } - @Override public void setLogger(FastMessageLogger logger) { } Modified: trunk/src/main/java/org/openfast/logging/FastMessageLogger.java =================================================================== --- trunk/src/main/java/org/openfast/logging/FastMessageLogger.java 2010-05-25 22:16:11 UTC (rev 213) +++ trunk/src/main/java/org/openfast/logging/FastMessageLogger.java 2010-06-04 01:34:58 UTC (rev 214) @@ -7,7 +7,7 @@ public enum Direction { INBOUND("[<--]"), OUTBOUND("[-->]"); - private String directionString; + private final String directionString; private Direction(String direction) { this.directionString = direction; @@ -20,7 +20,6 @@ } FastMessageLogger NULL = new FastMessageLogger() { - @Override public void log(Message message, byte[] bytes, Direction direction) { } }; Modified: trunk/src/main/java/org/openfast/logging/FileFastMessageLogger.java =================================================================== --- trunk/src/main/java/org/openfast/logging/FileFastMessageLogger.java 2010-05-25 22:16:11 UTC (rev 213) +++ trunk/src/main/java/org/openfast/logging/FileFastMessageLogger.java 2010-06-04 01:34:58 UTC (rev 214) @@ -5,12 +5,11 @@ import java.io.IOException; import java.io.OutputStream; import java.util.Date; - import org.openfast.Message; import org.openfast.template.MessageTemplate; public class FileFastMessageLogger implements FastMessageLogger { - private File file; + private final File file; private OutputStream out; public FileFastMessageLogger(String filePath) { @@ -23,7 +22,6 @@ this.file = f; } - @Override public void log(Message message, byte[] bytes, Direction direction) { try { createOut(); Modified: trunk/src/main/java/org/openfast/session/BasicOpenFastContext.java =================================================================== --- trunk/src/main/java/org/openfast/session/BasicOpenFastContext.java 2010-05-25 22:16:11 UTC (rev 213) +++ trunk/src/main/java/org/openfast/session/BasicOpenFastContext.java 2010-06-04 01:34:58 UTC (rev 214) @@ -10,42 +10,34 @@ private FastMessageLogger logger; - @Override public MessageTemplate getTemplate(int templateId) { return null; } - @Override public int getTemplateId(MessageTemplate template) { return 0; } - @Override public TemplateRegistry getTemplateRegistry() { return null; } - @Override public void registerTemplate(int templateId, MessageTemplate template) { } - @Override public void setErrorHandler(ErrorHandler errorHandler) { } - @Override public void setTemplateRegistry(TemplateRegistry registry) { } - @Override public FastMessageLogger getLogger() { return this.logger != null ? this.logger : FastMessageLogger.NULL; } - @Override public void setLogger(FastMessageLogger logger) { this.logger = logger; } Modified: trunk/src/main/java/org/openfast/template/BasicTemplateRegistry.java =================================================================== --- trunk/src/main/java/org/openfast/template/BasicTemplateRegistry.java 2010-05-25 22:16:11 UTC (rev 213) +++ trunk/src/main/java/org/openfast/template/BasicTemplateRegistry.java 2010-06-04 01:34:58 UTC (rev 214) @@ -25,16 +25,15 @@ import java.util.Iterator; import java.util.List; import java.util.Map; - import org.openfast.QName; import org.openfast.util.IntegerMap; import org.openfast.util.SimpleIntegerMap; public class BasicTemplateRegistry extends AbstractTemplateRegistry { - private Map nameMap = new HashMap(); - private IntegerMap idMap = new SimpleIntegerMap(); - private Map templateMap = new HashMap(); - private List templates = new ArrayList(); + private final Map nameMap = new HashMap(); + private final IntegerMap idMap = new SimpleIntegerMap(); + private final Map templateMap = new HashMap(); + private final List templates = new ArrayList(); public void register(int id, MessageTemplate template) { define(template); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-05-25 22:16:18
|
Revision: 213 http://openfast.svn.sourceforge.net/openfast/?rev=213&view=rev Author: littleodie914 Date: 2010-05-25 22:16:11 +0000 (Tue, 25 May 2010) Log Message: ----------- Modified Paths: -------------- trunk/src/main/java/org/openfast/template/type/codec/SingleFieldDecimal.java Modified: trunk/src/main/java/org/openfast/template/type/codec/SingleFieldDecimal.java =================================================================== --- trunk/src/main/java/org/openfast/template/type/codec/SingleFieldDecimal.java 2010-05-24 21:01:12 UTC (rev 212) +++ trunk/src/main/java/org/openfast/template/type/codec/SingleFieldDecimal.java 2010-05-25 22:16:11 UTC (rev 213) @@ -71,7 +71,7 @@ * @return Returns a decimalValue object with the data stream */ public ScalarValue decode(InputStream in) { - int exponent = ((IntegerValue) TypeCodec.INTEGER.decode(in)).value; + int exponent = TypeCodec.INTEGER.decode(in).toInt(); if (Math.abs(exponent) > 63) { Global.handleError(FastConstants.R1_LARGE_DECIMAL, "Encountered exponent of size " + exponent); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-05-24 21:01:18
|
Revision: 212 http://openfast.svn.sourceforge.net/openfast/?rev=212&view=rev Author: littleodie914 Date: 2010-05-24 21:01:12 +0000 (Mon, 24 May 2010) Log Message: ----------- Fixed a bug in Session that did not properly catch the Exceptions thrown by a Socket closing. Modified Paths: -------------- trunk/src/main/java/org/openfast/session/Session.java Modified: trunk/src/main/java/org/openfast/session/Session.java =================================================================== --- trunk/src/main/java/org/openfast/session/Session.java 2010-05-23 17:20:11 UTC (rev 211) +++ trunk/src/main/java/org/openfast/session/Session.java 2010-05-24 21:01:12 UTC (rev 212) @@ -160,7 +160,7 @@ Throwable cause = e.getCause(); if (cause != null && cause.getClass().equals(SocketException.class) - && cause.getMessage().equals("Socket closed")) { + && cause.getMessage().toLowerCase().contains("socket closed")) { listening = false; } else if (e instanceof FastException) { FastException fastException = ((FastException) e); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-05-23 17:20:17
|
Revision: 211 http://openfast.svn.sourceforge.net/openfast/?rev=211&view=rev Author: littleodie914 Date: 2010-05-23 17:20:11 +0000 (Sun, 23 May 2010) Log Message: ----------- Added support for setting Double values in GroupValue. Modified Paths: -------------- trunk/src/main/java/org/openfast/GroupValue.java Modified: trunk/src/main/java/org/openfast/GroupValue.java =================================================================== --- trunk/src/main/java/org/openfast/GroupValue.java 2010-05-21 20:39:56 UTC (rev 210) +++ trunk/src/main/java/org/openfast/GroupValue.java 2010-05-23 17:20:11 UTC (rev 211) @@ -22,6 +22,7 @@ import java.math.BigDecimal; import java.util.Iterator; + import org.openfast.template.Field; import org.openfast.template.Group; import org.openfast.template.LongValue; @@ -238,7 +239,7 @@ public void setBool(String fieldName, boolean value) { setFieldValue(fieldName, new IntegerValue(value ? 1 : 0)); } - + public void setLong(String fieldName, long value) { setFieldValue(fieldName, new LongValue(value)); } @@ -266,6 +267,8 @@ fieldValue = new LongValue(((Long) value).longValue()); } else if (value instanceof Boolean) { fieldValue = new IntegerValue(((Boolean) value).booleanValue() ? 1 : 0); + } else if (value instanceof Double) { + fieldValue = new DecimalValue(((Double) value).doubleValue()); } setFieldValue(fieldIndex, fieldValue); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-05-21 20:40:02
|
Revision: 210 http://openfast.svn.sourceforge.net/openfast/?rev=210&view=rev Author: littleodie914 Date: 2010-05-21 20:39:56 +0000 (Fri, 21 May 2010) Log Message: ----------- Fixed an array size but in BasicTemplateRegistry. Modified Paths: -------------- trunk/src/main/java/org/openfast/template/BasicTemplateRegistry.java Modified: trunk/src/main/java/org/openfast/template/BasicTemplateRegistry.java =================================================================== --- trunk/src/main/java/org/openfast/template/BasicTemplateRegistry.java 2010-05-19 17:24:18 UTC (rev 209) +++ trunk/src/main/java/org/openfast/template/BasicTemplateRegistry.java 2010-05-21 20:39:56 UTC (rev 210) @@ -88,7 +88,7 @@ return nameMap.containsKey(name); } public MessageTemplate[] getTemplates() { - return (MessageTemplate[]) templates.toArray(new MessageTemplate[templateMap.size()]); + return (MessageTemplate[]) templates.toArray(new MessageTemplate[templates.size()]); } public void remove(QName name) { MessageTemplate template = (MessageTemplate) nameMap.remove(name); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-05-19 17:24:24
|
Revision: 209 http://openfast.svn.sourceforge.net/openfast/?rev=209&view=rev Author: littleodie914 Date: 2010-05-19 17:24:18 +0000 (Wed, 19 May 2010) Log Message: ----------- Added support for logging of inbound/outbound FAST Messages. Added support for setting the Boolean FieldValue of an object. Modified Paths: -------------- trunk/pom.xml trunk/src/main/java/org/openfast/ByteUtil.java trunk/src/main/java/org/openfast/Context.java trunk/src/main/java/org/openfast/GroupValue.java trunk/src/main/java/org/openfast/MessageInputStream.java trunk/src/main/java/org/openfast/MessageOutputStream.java trunk/src/main/java/org/openfast/session/Session.java Added Paths: ----------- trunk/src/main/java/org/openfast/NullOpenFastContext.java trunk/src/main/java/org/openfast/OpenFastContext.java trunk/src/main/java/org/openfast/logging/ trunk/src/main/java/org/openfast/logging/FastMessageLogger.java trunk/src/main/java/org/openfast/logging/FileFastMessageLogger.java trunk/src/main/java/org/openfast/logging/Loggers.java trunk/src/main/java/org/openfast/session/BasicOpenFastContext.java Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-05-18 15:38:42 UTC (rev 208) +++ trunk/pom.xml 2010-05-19 17:24:18 UTC (rev 209) @@ -1,4 +1,5 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.openfast</groupId> <artifactId>openfast</artifactId> @@ -134,7 +135,7 @@ </excludes> </resource> </resources> - + <extensions> <extension> <groupId>org.apache.maven.wagon</groupId> @@ -230,14 +231,14 @@ <id>sourceforge.net</id> <name>Sourceforge.net Repository</name> <url> - scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/release + scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/release </url> </repository> <snapshotRepository> <id>sourceforge.net</id> <name>Sourceforge.net Snapshot Repository</name> <url> - scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/snapshot + scp://web.sourceforge.net/home/groups/o/op/openfast/htdocs/maven/snapshot </url> </snapshotRepository> <site> Modified: trunk/src/main/java/org/openfast/ByteUtil.java =================================================================== --- trunk/src/main/java/org/openfast/ByteUtil.java 2010-05-18 15:38:42 UTC (rev 208) +++ trunk/src/main/java/org/openfast/ByteUtil.java 2010-05-19 17:24:18 UTC (rev 209) @@ -24,6 +24,9 @@ import java.io.InputStream; public class ByteUtil { + + public static final byte[] EMPTY = new byte[0]; + /** * * @param bitString Modified: trunk/src/main/java/org/openfast/Context.java =================================================================== --- trunk/src/main/java/org/openfast/Context.java 2010-05-18 15:38:42 UTC (rev 208) +++ trunk/src/main/java/org/openfast/Context.java 2010-05-19 17:24:18 UTC (rev 209) @@ -30,6 +30,7 @@ import org.openfast.debug.Trace; import org.openfast.error.ErrorHandler; import org.openfast.error.FastConstants; +import org.openfast.logging.FastMessageLogger; import org.openfast.template.BasicTemplateRegistry; import org.openfast.template.Group; import org.openfast.template.MessageTemplate; @@ -43,7 +44,7 @@ * and contexts should never be shared. * @author Jacob Northey */ -public class Context { +public class Context implements OpenFastContext { private TemplateRegistry templateRegistry = new BasicTemplateRegistry(); private int lastTemplateId; private final Map dictionaries = new HashMap(); @@ -54,8 +55,14 @@ private Trace encodeTrace; private Trace decodeTrace; private final Map caches = new HashMap(); + private OpenFastContext parentContext; + private FastMessageLogger logger = null; public Context() { + this(new NullOpenFastContext()); + } + public Context(OpenFastContext context) { + this.parentContext = context; dictionaries.put("global", new GlobalDictionary()); dictionaries.put("template", new TemplateDictionary()); dictionaries.put("type", new ApplicationTypeDictionary()); @@ -164,4 +171,16 @@ } ((Cache)caches.get(key)).store(index, value); } + @Override + public FastMessageLogger getLogger() { + if (logger == null) { + return parentContext.getLogger(); + } + return logger; + } + + @Override + public void setLogger(FastMessageLogger logger) { + this.logger = logger; + } } Modified: trunk/src/main/java/org/openfast/GroupValue.java =================================================================== --- trunk/src/main/java/org/openfast/GroupValue.java 2010-05-18 15:38:42 UTC (rev 208) +++ trunk/src/main/java/org/openfast/GroupValue.java 2010-05-19 17:24:18 UTC (rev 209) @@ -264,6 +264,8 @@ fieldValue = new IntegerValue(((Integer) value).intValue()); } else if (value instanceof Long) { fieldValue = new LongValue(((Long) value).longValue()); + } else if (value instanceof Boolean) { + fieldValue = new IntegerValue(((Boolean) value).booleanValue() ? 1 : 0); } setFieldValue(fieldIndex, fieldValue); } Modified: trunk/src/main/java/org/openfast/MessageInputStream.java =================================================================== --- trunk/src/main/java/org/openfast/MessageInputStream.java 2010-05-18 15:38:42 UTC (rev 208) +++ trunk/src/main/java/org/openfast/MessageInputStream.java 2010-05-19 17:24:18 UTC (rev 209) @@ -27,7 +27,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; + import org.openfast.codec.FastDecoder; +import org.openfast.logging.FastMessageLogger.Direction; import org.openfast.template.MessageTemplate; import org.openfast.template.TemplateRegisteredListener; import org.openfast.template.TemplateRegistry; @@ -64,6 +66,7 @@ if (message == null) { return null; } + getContext().getLogger().log(message, ByteUtil.EMPTY, Direction.INBOUND); blockReader.messageRead(in, message); if (!handlers.isEmpty()) { for (int i = 0; i < handlers.size(); i++) { Modified: trunk/src/main/java/org/openfast/MessageOutputStream.java =================================================================== --- trunk/src/main/java/org/openfast/MessageOutputStream.java 2010-05-18 15:38:42 UTC (rev 208) +++ trunk/src/main/java/org/openfast/MessageOutputStream.java 2010-05-19 17:24:18 UTC (rev 209) @@ -29,6 +29,7 @@ import java.util.Map; import org.openfast.codec.FastEncoder; import org.openfast.error.FastConstants; +import org.openfast.logging.FastMessageLogger.Direction; import org.openfast.template.MessageTemplate; import org.openfast.template.TemplateRegistry; @@ -43,14 +44,17 @@ public MessageOutputStream(OutputStream outputStream) { this(outputStream, new Context()); } + public MessageOutputStream(OutputStream outputStream, Context context) { this.out = outputStream; this.encoder = new FastEncoder(context); this.context = context; } + public void writeMessage(Message message) { writeMessage(message, false); } + public void writeMessage(Message message, boolean flush) { try { byte[] data = encodeMessage(message); @@ -61,10 +65,12 @@ out.write(data); if (flush) out.flush(); + getContext().getLogger().log(message, data, Direction.OUTBOUND); } catch (IOException e) { Global.handleError(FastConstants.IO_ERROR, "An IO error occurred while writing message " + message, e); } } + private byte[] encodeMessage(Message message) { if (context.isTraceEnabled()) context.startTrace(); @@ -78,12 +84,15 @@ } return encoder.encode(message); } + public void reset() { encoder.reset(); } + public void registerTemplate(int templateId, MessageTemplate template) { encoder.registerTemplate(templateId, template); } + public void close() { try { out.close(); @@ -91,35 +100,43 @@ Global.handleError(FastConstants.IO_ERROR, "An error occurred while closing output stream.", e); } } + public OutputStream getUnderlyingStream() { return out; } + public void addMessageHandler(MessageTemplate template, MessageHandler handler) { if (templateHandlers == Collections.EMPTY_MAP) { templateHandlers = new HashMap(); } templateHandlers.put(template, handler); } + public void addMessageHandler(MessageHandler handler) { if (handlers == Collections.EMPTY_LIST) { handlers = new ArrayList(4); } handlers.add(handler); } + public void setTemplateRegistry(TemplateRegistry registry) { context.setTemplateRegistry(registry); } + /** - * Specify a block writer implementation that is used to prefix messages with - * a block size + * Specify a block writer implementation that is used to prefix messages + * with a block size + * * @param blockWriter */ public void setBlockWriter(MessageBlockWriter blockWriter) { this.blockWriter = blockWriter; } + public TemplateRegistry getTemplateRegistry() { return context.getTemplateRegistry(); } + public Context getContext() { return context; } Added: trunk/src/main/java/org/openfast/NullOpenFastContext.java =================================================================== --- trunk/src/main/java/org/openfast/NullOpenFastContext.java (rev 0) +++ trunk/src/main/java/org/openfast/NullOpenFastContext.java 2010-05-19 17:24:18 UTC (rev 209) @@ -0,0 +1,46 @@ +package org.openfast; + +import org.openfast.error.ErrorHandler; +import org.openfast.logging.FastMessageLogger; +import org.openfast.template.MessageTemplate; +import org.openfast.template.TemplateRegistry; + +public class NullOpenFastContext implements OpenFastContext { + + @Override + public MessageTemplate getTemplate(int templateId) { + return null; + } + + @Override + public int getTemplateId(MessageTemplate template) { + return 0; + } + + @Override + public TemplateRegistry getTemplateRegistry() { + return null; + } + + @Override + public void registerTemplate(int templateId, MessageTemplate template) { + } + + @Override + public void setErrorHandler(ErrorHandler errorHandler) { + } + + @Override + public void setTemplateRegistry(TemplateRegistry registry) { + } + + @Override + public FastMessageLogger getLogger() { + return FastMessageLogger.NULL; + } + + @Override + public void setLogger(FastMessageLogger logger) { + } + +} Added: trunk/src/main/java/org/openfast/OpenFastContext.java =================================================================== --- trunk/src/main/java/org/openfast/OpenFastContext.java (rev 0) +++ trunk/src/main/java/org/openfast/OpenFastContext.java 2010-05-19 17:24:18 UTC (rev 209) @@ -0,0 +1,24 @@ +package org.openfast; + +import org.openfast.error.ErrorHandler; +import org.openfast.logging.FastMessageLogger; +import org.openfast.template.MessageTemplate; +import org.openfast.template.TemplateRegistry; + +public interface OpenFastContext { + public int getTemplateId(MessageTemplate template); + + public MessageTemplate getTemplate(int templateId); + + public void registerTemplate(int templateId, MessageTemplate template); + + public void setErrorHandler(ErrorHandler errorHandler); + + public TemplateRegistry getTemplateRegistry(); + + public void setTemplateRegistry(TemplateRegistry registry); + + public FastMessageLogger getLogger(); + + public void setLogger(FastMessageLogger logger); +} Added: trunk/src/main/java/org/openfast/logging/FastMessageLogger.java =================================================================== --- trunk/src/main/java/org/openfast/logging/FastMessageLogger.java (rev 0) +++ trunk/src/main/java/org/openfast/logging/FastMessageLogger.java 2010-05-19 17:24:18 UTC (rev 209) @@ -0,0 +1,29 @@ +package org.openfast.logging; + +import org.openfast.Message; + +public interface FastMessageLogger { + + public enum Direction { + INBOUND("[<--]"), OUTBOUND("[-->]"); + + private String directionString; + + private Direction(String direction) { + this.directionString = direction; + } + + @Override + public String toString() { + return directionString; + } + } + + FastMessageLogger NULL = new FastMessageLogger() { + @Override + public void log(Message message, byte[] bytes, Direction direction) { + } + }; + + public void log(Message message, byte[] bytes, Direction direction); +} Added: trunk/src/main/java/org/openfast/logging/FileFastMessageLogger.java =================================================================== --- trunk/src/main/java/org/openfast/logging/FileFastMessageLogger.java (rev 0) +++ trunk/src/main/java/org/openfast/logging/FileFastMessageLogger.java 2010-05-19 17:24:18 UTC (rev 209) @@ -0,0 +1,77 @@ +package org.openfast.logging; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Date; + +import org.openfast.Message; +import org.openfast.template.MessageTemplate; + +public class FileFastMessageLogger implements FastMessageLogger { + private File file; + private OutputStream out; + + public FileFastMessageLogger(String filePath) { + this(new File(filePath)); + } + + public FileFastMessageLogger(File f) { + if (f.exists() && !f.canWrite()) + throw new IllegalArgumentException("Unable to write to file: " + f.getAbsolutePath()); + this.file = f; + } + + @Override + public void log(Message message, byte[] bytes, Direction direction) { + try { + createOut(); + out.write(new Date().toString().getBytes()); + out.write('\n'); + out.write((direction + " ").getBytes()); + out.write(print(message)); + out.write('\n'); + out.write(bytes); + out.write('\n'); + } catch (IOException e) { + e.printStackTrace(); + } + } + + private byte[] print(Message message) { + StringBuilder msgBuilder = new StringBuilder(); + MessageTemplate template = message.getTemplate(); + msgBuilder.append(template.getName()).append("[ "); + for (int i=1; i<template.getFieldCount(); i++) { + msgBuilder.append(template.getField(i).getName()).append('='); + if (message.isDefined(i)) { + msgBuilder.append(message.getString(i)); + } else { + msgBuilder.append("null"); + } + msgBuilder.append(' '); + } + msgBuilder.append(']'); + return msgBuilder.toString().getBytes(); + } + + private void createOut() throws IOException { + if (out == null) { + if (!file.exists()) { + if (!file.getParentFile().exists()) { + file.getParentFile().mkdirs(); + } + file.createNewFile(); + } + out = new FileOutputStream(file, true); + } + } + + public void close() { + try { + out.close(); + } catch (Exception e) { + } + } +} Added: trunk/src/main/java/org/openfast/logging/Loggers.java =================================================================== --- trunk/src/main/java/org/openfast/logging/Loggers.java (rev 0) +++ trunk/src/main/java/org/openfast/logging/Loggers.java 2010-05-19 17:24:18 UTC (rev 209) @@ -0,0 +1,20 @@ +package org.openfast.logging; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +public class Loggers { + private Map<Class<?>, Map<String, FastMessageLogger>> loggers = Collections.emptyMap(); + + public FastMessageLogger getLogger(Class<?> clazz, String identifier) { + if (loggers.isEmpty()) + loggers = new HashMap<Class<?>, Map<String, FastMessageLogger>>(); + Map<String, FastMessageLogger> loggerIdentifierMap = loggers.get(clazz); + if (loggerIdentifierMap.isEmpty()) { + loggerIdentifierMap = new HashMap<String, FastMessageLogger>(); + loggers.put(clazz, loggerIdentifierMap); + } + return null; + } +} Added: trunk/src/main/java/org/openfast/session/BasicOpenFastContext.java =================================================================== --- trunk/src/main/java/org/openfast/session/BasicOpenFastContext.java (rev 0) +++ trunk/src/main/java/org/openfast/session/BasicOpenFastContext.java 2010-05-19 17:24:18 UTC (rev 209) @@ -0,0 +1,53 @@ +package org.openfast.session; + +import org.openfast.OpenFastContext; +import org.openfast.error.ErrorHandler; +import org.openfast.logging.FastMessageLogger; +import org.openfast.template.MessageTemplate; +import org.openfast.template.TemplateRegistry; + +public class BasicOpenFastContext implements OpenFastContext { + + private FastMessageLogger logger; + + @Override + public MessageTemplate getTemplate(int templateId) { + return null; + } + + @Override + public int getTemplateId(MessageTemplate template) { + return 0; + } + + @Override + public TemplateRegistry getTemplateRegistry() { + return null; + } + + @Override + public void registerTemplate(int templateId, MessageTemplate template) { + + } + + @Override + public void setErrorHandler(ErrorHandler errorHandler) { + + } + + @Override + public void setTemplateRegistry(TemplateRegistry registry) { + + } + + @Override + public FastMessageLogger getLogger() { + return this.logger != null ? this.logger : FastMessageLogger.NULL; + } + + @Override + public void setLogger(FastMessageLogger logger) { + this.logger = logger; + } + +} Modified: trunk/src/main/java/org/openfast/session/Session.java =================================================================== --- trunk/src/main/java/org/openfast/session/Session.java 2010-05-18 15:38:42 UTC (rev 208) +++ trunk/src/main/java/org/openfast/session/Session.java 2010-05-19 17:24:18 UTC (rev 209) @@ -27,6 +27,7 @@ import org.openfast.Message; import org.openfast.MessageInputStream; import org.openfast.MessageOutputStream; +import org.openfast.OpenFastContext; import org.openfast.QName; import org.openfast.error.ErrorCode; import org.openfast.error.ErrorHandler; @@ -46,11 +47,15 @@ private Thread listeningThread; private ErrorHandler errorHandler = ErrorHandler.DEFAULT; private SessionListener sessionListener = SessionListener.NULL; + private OpenFastContext context; - public Session(Connection connection, SessionProtocol protocol, TemplateRegistry inboundRegistry, TemplateRegistry outboundRegistry) { - Context inContext = new Context(); + public Session(Connection connection, SessionProtocol protocol, TemplateRegistry inboundRegistry, + TemplateRegistry outboundRegistry) { + this.context = new BasicOpenFastContext(); + Context inContext = new Context(context); inContext.getTemplateRegistry().registerAll(inboundRegistry); - Context outContext = new Context(); + + Context outContext = new Context(context); outContext.getTemplateRegistry().registerAll(outboundRegistry); inContext.setErrorHandler(this); @@ -109,10 +114,13 @@ if (errorHandler == null) { this.errorHandler = ErrorHandler.NULL; } - this.errorHandler = errorHandler; } + public OpenFastContext getContext() { + return context; + } + public void reset() { out.reset(); in.reset(); @@ -145,7 +153,8 @@ } else if (messageListener != null) { messageListener.onMessage(Session.this, message); } else { - throw new IllegalStateException("Received non-protocol message without a message listener."); + throw new IllegalStateException( + "Received non-protocol message without a message listener."); } } catch (Exception e) { Throwable cause = e.getCause(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-05-18 15:38:53
|
Revision: 208 http://openfast.svn.sourceforge.net/openfast/?rev=208&view=rev Author: jacob_northey Date: 2010-05-18 15:38:42 +0000 (Tue, 18 May 2010) Log Message: ----------- Modified Paths: -------------- trunk/pom.xml trunk/src/main/java/org/openfast/Context.java trunk/src/main/java/org/openfast/DateValue.java trunk/src/main/java/org/openfast/DecimalValue.java trunk/src/main/java/org/openfast/GroupValue.java trunk/src/main/java/org/openfast/IntegerValue.java trunk/src/main/java/org/openfast/Message.java trunk/src/main/java/org/openfast/MessageOutputStream.java trunk/src/main/java/org/openfast/ScalarValue.java trunk/src/main/java/org/openfast/StringValue.java trunk/src/main/java/org/openfast/debug/BasicDecodeTrace.java trunk/src/main/java/org/openfast/examples/OpenFastExample.java trunk/src/main/java/org/openfast/examples/producer/Main.java trunk/src/main/java/org/openfast/examples/producer/XmlCompressedMessageConverter.java trunk/src/main/java/org/openfast/session/FastServer.java trunk/src/main/java/org/openfast/session/RecordingEndpoint.java trunk/src/main/java/org/openfast/session/SessionControlProtocol_1_0.java trunk/src/main/java/org/openfast/session/SessionControlProtocol_1_1.java trunk/src/main/java/org/openfast/session/tcp/TcpEndpoint.java trunk/src/main/java/org/openfast/template/LongValue.java trunk/src/test/java/org/openfast/session/SCP_1_1_Test.java trunk/src/test/java/org/openfast/test/OpenFastTestCase.java trunk/src/test/java/org/openfast/util/UtilTest.java Added Paths: ----------- trunk/src/main/java/org/openfast/MessageBlockWriter.java trunk/src/main/java/org/openfast/examples/scp10/ trunk/src/main/java/org/openfast/examples/scp10/Main.java trunk/src/main/java/org/openfast/examples/scp10/ScpMessageProducer.java trunk/src/main/java/org/openfast/impl/ trunk/src/main/java/org/openfast/impl/CmeMessageBlockReader.java trunk/src/test/java/org/openfast/submitted/IcapSecurityListTest.java trunk/src/test/resources/ICAP/ trunk/src/test/resources/ICAP/sl.bin trunk/src/test/resources/ICAP/sl2.bin trunk/src/test/resources/ICAP/template.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/pom.xml 2010-05-18 15:38:42 UTC (rev 208) @@ -3,7 +3,7 @@ <groupId>org.openfast</groupId> <artifactId>openfast</artifactId> <packaging>jar</packaging> - <version>1.0.1</version> + <version>1.1.0-SNAPSHOT</version> <organization> <name>The LaSalle Technology Group, LLC</name> @@ -147,8 +147,8 @@ <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> - <source>1.4</source> - <target>1.4</target> + <source>1.5</source> + <target>1.5</target> </configuration> </plugin> <plugin> Modified: trunk/src/main/java/org/openfast/Context.java =================================================================== --- trunk/src/main/java/org/openfast/Context.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/Context.java 2010-05-18 15:38:42 UTC (rev 208) @@ -25,7 +25,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; - import org.openfast.debug.BasicDecodeTrace; import org.openfast.debug.BasicEncodeTrace; import org.openfast.debug.Trace; @@ -47,14 +46,14 @@ public class Context { private TemplateRegistry templateRegistry = new BasicTemplateRegistry(); private int lastTemplateId; - private Map dictionaries = new HashMap(); + private final Map dictionaries = new HashMap(); private ErrorHandler errorHandler = ErrorHandler.DEFAULT; private QName currentApplicationType; - private List listeners = Collections.EMPTY_LIST; + private final List listeners = Collections.EMPTY_LIST; private boolean traceEnabled; private Trace encodeTrace; private Trace decodeTrace; - private Map caches = new HashMap(); + private final Map caches = new HashMap(); public Context() { dictionaries.put("global", new GlobalDictionary()); @@ -129,8 +128,14 @@ return traceEnabled; } public void startTrace() { - setEncodeTrace(new BasicEncodeTrace()); - setDecodeTrace(new BasicDecodeTrace()); + if (isTraceEnabled()) { + if (decodeTrace == null) { + setDecodeTrace(new BasicDecodeTrace()); + } + if (encodeTrace == null) { + setEncodeTrace(new BasicEncodeTrace()); + } + } } public void setTraceEnabled(boolean enabled) { this.traceEnabled = enabled; Modified: trunk/src/main/java/org/openfast/DateValue.java =================================================================== --- trunk/src/main/java/org/openfast/DateValue.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/DateValue.java 2010-05-18 15:38:42 UTC (rev 208) @@ -30,14 +30,22 @@ this.value = date; } + @Override + public Object toObject() { + return value; + } + + @Override public long toLong() { return value.getTime(); } + @Override public String toString() { return value.toString(); } + @Override public boolean equals(Object other) { if (other == this) return true; @@ -50,6 +58,7 @@ return other.value.equals(value); } + @Override public int hashCode() { return value.hashCode(); } Modified: trunk/src/main/java/org/openfast/DecimalValue.java =================================================================== --- trunk/src/main/java/org/openfast/DecimalValue.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/DecimalValue.java 2010-05-18 15:38:42 UTC (rev 208) @@ -23,7 +23,6 @@ import java.math.BigDecimal; import java.math.BigInteger; - import org.openfast.error.FastConstants; public class DecimalValue extends NumericValue { @@ -63,18 +62,27 @@ this.exponent = bigDecimal.scale(); } + @Override public NumericValue increment() { return null; } + @Override public NumericValue decrement() { return null; } + @Override + public Object toObject() { + return toBigDecimal(); + } + + @Override public boolean isNull() { return false; } + @Override public boolean equals(Object obj) { if ((obj == null) || !(obj instanceof DecimalValue)) { return false; @@ -87,28 +95,34 @@ return other.mantissa == this.mantissa && other.exponent == this.exponent; } + @Override public NumericValue subtract(NumericValue subtrahend) { return new DecimalValue(toBigDecimal().subtract(((DecimalValue)subtrahend).toBigDecimal())); } + @Override public NumericValue add(NumericValue addend) { return new DecimalValue(toBigDecimal().add(((DecimalValue)addend).toBigDecimal())); } + @Override public String serialize() { return toString(); } + @Override public boolean equals(int value) { return false; } + @Override public long toLong() { if (exponent < 0) Global.handleError(FastConstants.R5_DECIMAL_CANT_CONVERT_TO_INT, ""); - return (long) (getValue()); + return (getValue()); } + @Override public int toInt() { long value = getValue(); if (exponent < 0 || (value) > Integer.MAX_VALUE) @@ -116,6 +130,7 @@ return (int) (value); } + @Override public short toShort() { long value = getValue(); if (exponent < 0 || (value) > Short.MAX_VALUE) @@ -123,6 +138,7 @@ return (short) (value); } + @Override public byte toByte() { long value = getValue(); if (exponent < 0 || (value) > Byte.MAX_VALUE) @@ -137,18 +153,23 @@ /** * The double value should be rounded using a given precision by users of this method. */ + @Override public double toDouble() { return mantissa * Math.pow(10.0, exponent); } + @Override public BigDecimal toBigDecimal() { return new BigDecimal(BigInteger.valueOf(mantissa), -exponent); } + @Override public String toString() { +// return "Not Calculated"; return toBigDecimal().toPlainString(); } + @Override public int hashCode() { return exponent * 37 + (int) mantissa; } Modified: trunk/src/main/java/org/openfast/GroupValue.java =================================================================== --- trunk/src/main/java/org/openfast/GroupValue.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/GroupValue.java 2010-05-18 15:38:42 UTC (rev 208) @@ -22,7 +22,6 @@ import java.math.BigDecimal; import java.util.Iterator; - import org.openfast.template.Field; import org.openfast.template.Group; import org.openfast.template.LongValue; @@ -45,7 +44,7 @@ this.group = group; this.values = values; - + for (int i=0; i<group.getFieldCount(); i++) { if (group.getField(i) instanceof Scalar) { Scalar scalar = ((Scalar) group.getField(i)); @@ -219,11 +218,11 @@ public void setDecimal(String fieldName, double value) { setFieldValue(fieldName, new DecimalValue(value)); } - + public void setDecimal(int fieldIndex, BigDecimal value) { values[fieldIndex] = new DecimalValue(value); } - + public void setDecimal(String fieldName, BigDecimal value) { setFieldValue(fieldName, new DecimalValue(value)); } @@ -256,6 +255,20 @@ setFieldValue(fieldName, group.getField(fieldName).createValue(value)); } + + public void setFieldValue(int fieldIndex, Object value) { + FieldValue fieldValue = ScalarValue.NULL; + if (value instanceof String) { + fieldValue = new StringValue(String.valueOf(value)); + } else if (value instanceof Integer) { + fieldValue = new IntegerValue(((Integer) value).intValue()); + } else if (value instanceof Long) { + fieldValue = new LongValue(((Long) value).longValue()); + } + setFieldValue(fieldIndex, fieldValue); + } + + @Override public boolean equals(Object other) { if (other == this) { return true; @@ -285,10 +298,12 @@ return true; } + @Override public int hashCode() { return values.hashCode(); } + @Override public String toString() { StringBuilder builder = new StringBuilder(); Modified: trunk/src/main/java/org/openfast/IntegerValue.java =================================================================== --- trunk/src/main/java/org/openfast/IntegerValue.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/IntegerValue.java 2010-05-18 15:38:42 UTC (rev 208) @@ -32,6 +32,7 @@ this.value = value; } + @Override public boolean equals(Object obj) { if ((obj == null) || !(obj instanceof NumericValue)) { return false; @@ -43,26 +44,31 @@ return value == otherValue.toLong(); } + @Override public int hashCode() { return value; } + @Override public boolean equalsValue(String defaultValue) { return Integer.parseInt(defaultValue) == value; } + @Override public NumericValue increment() { if (value == Integer.MAX_VALUE) return new LongValue(value + 1L); return new IntegerValue(value + 1); } + @Override public NumericValue decrement() { if (value == Integer.MIN_VALUE) return new LongValue(value - 1L); return new IntegerValue(value - 1); } + @Override public NumericValue subtract(NumericValue subend) { if (subend instanceof LongValue) { return new LongValue(this.value - subend.toLong()); @@ -70,6 +76,7 @@ return new IntegerValue(this.value - subend.toInt()); } + @Override public NumericValue add(NumericValue addend) { long total = value + addend.toLong(); if (total <= Integer.MAX_VALUE && total >= Integer.MIN_VALUE) @@ -77,42 +84,56 @@ return new LongValue(total); } + @Override public String serialize() { return String.valueOf(value); } + @Override public boolean equals(int value) { return value == this.value; } + @Override public long toLong() { return value; } + @Override + public Object toObject() { + return value; + } + + @Override public int toInt() { return value; } + @Override public String toString() { return String.valueOf(value); } + @Override public byte toByte() { if (value > Byte.MAX_VALUE || value < Byte.MIN_VALUE) Global.handleError(FastConstants.R4_NUMERIC_VALUE_TOO_LARGE, "The value \"" + value + "\" is too large for a byte."); return (byte) value; } + @Override public short toShort() { if (value > Short.MAX_VALUE || value < Short.MIN_VALUE) Global.handleError(FastConstants.R4_NUMERIC_VALUE_TOO_LARGE, "The value \"" + value + "\" is too large for a short."); return (short) value; } + @Override public double toDouble() { return value; } + @Override public BigDecimal toBigDecimal() { return new BigDecimal(value); } Modified: trunk/src/main/java/org/openfast/Message.java =================================================================== --- trunk/src/main/java/org/openfast/Message.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/Message.java 2010-05-18 15:38:42 UTC (rev 208) @@ -37,6 +37,7 @@ FieldValue[] fields = new FieldValue[fieldCount]; return fields; } + @Override public boolean equals(Object obj) { if ((obj == null) || !(obj instanceof Message)) { return false; @@ -58,15 +59,18 @@ } return true; } + @Override public int hashCode() { return super.hashCode() + template.hashCode(); } + @Override public int getFieldCount() { return values.length; } public MessageTemplate getTemplate() { return template; } + @Override public FieldValue copy() { FieldValue[] copies = new FieldValue[values.length]; for (int i = 0; i < copies.length; i++) { Added: trunk/src/main/java/org/openfast/MessageBlockWriter.java =================================================================== --- trunk/src/main/java/org/openfast/MessageBlockWriter.java (rev 0) +++ trunk/src/main/java/org/openfast/MessageBlockWriter.java 2010-05-18 15:38:42 UTC (rev 208) @@ -0,0 +1,12 @@ +package org.openfast; + +import java.io.OutputStream; + +public interface MessageBlockWriter { + + MessageBlockWriter NULL = new MessageBlockWriter() { + public void writeBlockLength(OutputStream out, byte[] data) { + }}; + + void writeBlockLength(OutputStream out, byte[] data); +} Modified: trunk/src/main/java/org/openfast/MessageOutputStream.java =================================================================== --- trunk/src/main/java/org/openfast/MessageOutputStream.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/MessageOutputStream.java 2010-05-18 15:38:42 UTC (rev 208) @@ -27,7 +27,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; - import org.openfast.codec.FastEncoder; import org.openfast.error.FastConstants; import org.openfast.template.MessageTemplate; @@ -39,6 +38,7 @@ private final Context context; private List handlers = Collections.EMPTY_LIST; private Map templateHandlers = Collections.EMPTY_MAP; + private MessageBlockWriter blockWriter = MessageBlockWriter.NULL; public MessageOutputStream(OutputStream outputStream) { this(outputStream, new Context()); @@ -53,20 +53,11 @@ } public void writeMessage(Message message, boolean flush) { try { - if (context.isTraceEnabled()) - context.startTrace(); - if (!handlers.isEmpty()) { - for (int i = 0; i < handlers.size(); i++) { - ((MessageHandler) handlers.get(i)).handleMessage(message, context, encoder); - } - } - if (templateHandlers.containsKey(message.getTemplate())) { - ((MessageHandler) templateHandlers.get(message.getTemplate())).handleMessage(message, context, encoder); - } - byte[] data = encoder.encode(message); + byte[] data = encodeMessage(message); if ((data == null) || (data.length == 0)) { return; } + blockWriter.writeBlockLength(out, data); out.write(data); if (flush) out.flush(); @@ -74,6 +65,19 @@ Global.handleError(FastConstants.IO_ERROR, "An IO error occurred while writing message " + message, e); } } + private byte[] encodeMessage(Message message) { + if (context.isTraceEnabled()) + context.startTrace(); + if (!handlers.isEmpty()) { + for (int i = 0; i < handlers.size(); i++) { + ((MessageHandler) handlers.get(i)).handleMessage(message, context, encoder); + } + } + if (templateHandlers.containsKey(message.getTemplate())) { + ((MessageHandler) templateHandlers.get(message.getTemplate())).handleMessage(message, context, encoder); + } + return encoder.encode(message); + } public void reset() { encoder.reset(); } @@ -105,6 +109,14 @@ public void setTemplateRegistry(TemplateRegistry registry) { context.setTemplateRegistry(registry); } + /** + * Specify a block writer implementation that is used to prefix messages with + * a block size + * @param blockWriter + */ + public void setBlockWriter(MessageBlockWriter blockWriter) { + this.blockWriter = blockWriter; + } public TemplateRegistry getTemplateRegistry() { return context.getTemplateRegistry(); } Modified: trunk/src/main/java/org/openfast/ScalarValue.java =================================================================== --- trunk/src/main/java/org/openfast/ScalarValue.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/ScalarValue.java 2010-05-18 15:38:42 UTC (rev 208) @@ -27,10 +27,12 @@ public static final ScalarValue UNDEFINED = new ScalarValue() { private static final long serialVersionUID = 1L; + @Override public boolean isUndefined() { return true; } + @Override public String toString() { return "UNDEFINED"; } @@ -38,17 +40,19 @@ static public final ScalarValue NULL = new ScalarValue() { private static final long serialVersionUID = 1L; + @Override public boolean isNull() { return true; } + @Override public String toString() { return "NULL"; } }; /** - * + * * @return Returns false */ public boolean equalsValue(String defaultValue) { @@ -60,7 +64,7 @@ } /** - * + * * @return Returns false */ public boolean isUndefined() { @@ -68,7 +72,7 @@ } /** - * + * * @return Returns false */ public boolean isNull() { @@ -91,10 +95,11 @@ throw new UnsupportedOperationException(); } + @Override public String toString() { throw new UnsupportedOperationException(); } - + public String serialize() { return toString(); } @@ -110,4 +115,8 @@ public BigDecimal toBigDecimal() { throw new UnsupportedOperationException(); } + + public Object toObject() { + throw new UnsupportedOperationException(); + } } Modified: trunk/src/main/java/org/openfast/StringValue.java =================================================================== --- trunk/src/main/java/org/openfast/StringValue.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/StringValue.java 2010-05-18 15:38:42 UTC (rev 208) @@ -21,7 +21,6 @@ package org.openfast; import java.math.BigDecimal; - import org.openfast.error.FastConstants; public class StringValue extends ScalarValue { @@ -33,6 +32,7 @@ throw new NullPointerException(); this.value = value; } + @Override public byte toByte() { int value = toInt(); if (value > Byte.MAX_VALUE || value < Byte.MIN_VALUE) { @@ -42,6 +42,7 @@ } return (byte) value; } + @Override public short toShort() { int value = toInt(); if (value > Short.MAX_VALUE || value < Short.MIN_VALUE) { @@ -51,6 +52,7 @@ } return (short) value; } + @Override public int toInt() { try { return Integer.parseInt(value); @@ -60,6 +62,7 @@ return 0; } } + @Override public long toLong() { try { return Long.parseLong(value); @@ -69,6 +72,7 @@ return 0; } } + @Override public double toDouble() { try { return Double.parseDouble(value); @@ -78,15 +82,23 @@ return 0.0; } } + @Override + public Object toObject() { + return value; + } + @Override public byte[] getBytes() { return value.getBytes(); } + @Override public BigDecimal toBigDecimal() { return new BigDecimal(value); } + @Override public String toString() { return value; } + @Override public boolean equals(Object obj) { if ((obj == null) || !(obj instanceof StringValue)) { return false; @@ -96,9 +108,11 @@ private boolean equals(StringValue otherValue) { return value.equals(otherValue.value); } + @Override public int hashCode() { return value.hashCode(); } + @Override public boolean equalsValue(String defaultValue) { return value.equals(defaultValue); } Modified: trunk/src/main/java/org/openfast/debug/BasicDecodeTrace.java =================================================================== --- trunk/src/main/java/org/openfast/debug/BasicDecodeTrace.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/debug/BasicDecodeTrace.java 2010-05-18 15:38:42 UTC (rev 208) @@ -21,7 +21,6 @@ package org.openfast.debug; import java.io.PrintWriter; - import org.openfast.ByteUtil; import org.openfast.FieldValue; import org.openfast.template.Field; @@ -47,6 +46,7 @@ private void print(Object object) { out.print(indent); out.println(object); + out.flush(); } public void groupEnd() { @@ -56,13 +56,13 @@ public void field(Field field, FieldValue value, FieldValue decodedValue, byte[] encoding, int pmapIndex) { StringBuilder scalarDecode = new StringBuilder(); scalarDecode.append(field.getName()).append(": "); - scalarDecode.append(ByteUtil.convertByteArrayToBitString(encoding)); + scalarDecode.append(ByteUtil.convertByteArrayToHexString(encoding)); scalarDecode.append(" -> ").append(value).append('(').append(decodedValue).append(')'); print(scalarDecode); } public void pmap(byte[] bytes) { - print("PMAP: " + ByteUtil.convertByteArrayToBitString(bytes)); + print("PMAP: " + ByteUtil.convertByteArrayToHexString(bytes)); } public void setWriter(PrintWriter traceWriter) { Modified: trunk/src/main/java/org/openfast/examples/OpenFastExample.java =================================================================== --- trunk/src/main/java/org/openfast/examples/OpenFastExample.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/examples/OpenFastExample.java 2010-05-18 15:38:42 UTC (rev 208) @@ -19,6 +19,7 @@ protected static final String OUTPUT_FILE = "output"; protected static final String TRACE = "trace"; protected static final String FAST_DATA_FILE = "data"; + protected static final String XML_DATA_FILE = "xml"; protected static CommandLine parseCommandLine(String name, String[] args, Options options) { try { Modified: trunk/src/main/java/org/openfast/examples/producer/Main.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/Main.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/examples/producer/Main.java 2010-05-18 15:38:42 UTC (rev 208) @@ -11,7 +11,6 @@ import org.openfast.session.tcp.TcpEndpoint; public class Main extends OpenFastExample { - private static final String XML_DATA_FILE = "xml"; private static Options options = new Options(); static { Modified: trunk/src/main/java/org/openfast/examples/producer/XmlCompressedMessageConverter.java =================================================================== --- trunk/src/main/java/org/openfast/examples/producer/XmlCompressedMessageConverter.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/examples/producer/XmlCompressedMessageConverter.java 2010-05-18 15:38:42 UTC (rev 208) @@ -80,7 +80,7 @@ GroupValue[] seqValues = sequenceValue.getValues(); for (int j=0; j<seqValues.length; j++) { writer.startNode(instanceName); - writeGroup(writer, seqValues[0]); + writeGroup(writer, seqValues[j]); writer.endNode(); } } else { @@ -142,12 +142,12 @@ public boolean canConvert(Class clazz) { return clazz.equals(Message.class); } - + protected TemplateRegistry getTemplateRegistry() { return templateRegistry; } - protected void setTemplateRegistry(TemplateRegistry templateRegistry) { + public void setTemplateRegistry(TemplateRegistry templateRegistry) { this.templateRegistry = templateRegistry; } } Added: trunk/src/main/java/org/openfast/examples/scp10/Main.java =================================================================== --- trunk/src/main/java/org/openfast/examples/scp10/Main.java (rev 0) +++ trunk/src/main/java/org/openfast/examples/scp10/Main.java 2010-05-18 15:38:42 UTC (rev 208) @@ -0,0 +1,70 @@ +package org.openfast.examples.scp10; + +import java.io.File; +import java.io.IOException; +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.Options; +import org.openfast.examples.Assert; +import org.openfast.examples.OpenFastExample; +import org.openfast.session.Endpoint; +import org.openfast.session.FastConnectionException; +import org.openfast.session.tcp.TcpEndpoint; + +public class Main extends OpenFastExample { + private static Options options = new Options(); + + static { + options.addOption("?", HELP, false, "Displays this message"); + options.addOption("p", PORT, true, "Port to serve data on"); + options.addOption("h", HOST, true, "The host name of the server"); + options.addOption("e", ERROR, false, "Show stacktrace information"); + options.addOption("t", MESSAGE_TEMPLATE_FILE, true, "Message template definition file"); + options.addOption("x", XML_DATA_FILE, true, "The XML data to convert to FAST"); + } + /** + * @param args + */ + public static void main(String[] args) { + CommandLine cl = parseCommandLine("scp10producer", args, options); + if (cl.hasOption(HELP)) { + displayHelp("scp10producer", options); + } + Endpoint endpoint = null; + boolean showStacktrace = cl.hasOption(ERROR); + File templatesFile = null; + File xmlDataFile = null; + try { + Assert.assertTrue(cl.hasOption(PORT), "The required parameter \"" + PORT + "\" is missing."); + int port = getInteger(cl, PORT); + String host = cl.hasOption(HOST) ? cl.getOptionValue(HOST) : "localhost"; + + endpoint = new TcpEndpoint(host, port); + templatesFile = getFile(cl, MESSAGE_TEMPLATE_FILE); + xmlDataFile = getFile(cl, XML_DATA_FILE); + Assert.assertTrue(templatesFile.exists(), "The template definition file \"" + templatesFile.getAbsolutePath() + "\" does not exist."); + Assert.assertTrue(!templatesFile.isDirectory(), "The template definition file \"" + templatesFile.getAbsolutePath() + "\" is a directory."); + Assert.assertTrue(templatesFile.canRead(), "The template definition file \"" + templatesFile.getAbsolutePath() + "\" is not readable."); + Assert.assertTrue(templatesFile.exists(), "The template definition file \"" + templatesFile.getAbsolutePath() + "\" does not exist."); + Assert.assertTrue(!templatesFile.isDirectory(), "The template definition file \"" + templatesFile.getAbsolutePath() + "\" is a directory."); + Assert.assertTrue(templatesFile.canRead(), "The template definition file \"" + templatesFile.getAbsolutePath() + "\" is not readable."); + } catch (AssertionError e) { + System.out.println(e.getMessage()); + displayHelp("consumer", options); + } + ScpMessageProducer producer = new ScpMessageProducer(endpoint, templatesFile); + try { + producer.start(xmlDataFile); + producer.stop(); + } catch (FastConnectionException e) { + if (showStacktrace) + e.printStackTrace(); + System.out.println("Unable to connect to endpoint: " + e.getMessage()); + System.exit(1); + } catch (IOException e) { + if (showStacktrace) + e.printStackTrace(); + System.out.println("An IO error occurred while consuming messages: " + e.getMessage()); + System.exit(1); + } + } +} Added: trunk/src/main/java/org/openfast/examples/scp10/ScpMessageProducer.java =================================================================== --- trunk/src/main/java/org/openfast/examples/scp10/ScpMessageProducer.java (rev 0) +++ trunk/src/main/java/org/openfast/examples/scp10/ScpMessageProducer.java 2010-05-18 15:38:42 UTC (rev 208) @@ -0,0 +1,78 @@ +package org.openfast.examples.scp10; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.List; +import org.openfast.Global; +import org.openfast.Message; +import org.openfast.MessageOutputStream; +import org.openfast.error.ErrorHandler; +import org.openfast.examples.producer.XmlCompressedMessageConverter; +import org.openfast.session.Endpoint; +import org.openfast.session.FastClient; +import org.openfast.session.FastConnectionException; +import org.openfast.session.MessageListener; +import org.openfast.session.Session; +import org.openfast.session.SessionConstants; +import org.openfast.session.SessionListener; +import org.openfast.template.TemplateRegistry; +import org.openfast.template.loader.XMLMessageTemplateLoader; + +public class ScpMessageProducer implements MessageListener { + private final Endpoint endpoint; + private final TemplateRegistry templateRegistry; + private String clientName = "LTG"; + + public ScpMessageProducer(Endpoint endpoint, File templatesFile) { + Global.setErrorHandler(ErrorHandler.NULL); + this.endpoint = endpoint; + XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader(); + loader.setLoadTemplateIdFromAuxId(true); + try { + loader.load(new FileInputStream(templatesFile)); + } catch (FileNotFoundException e) { + throw new RuntimeException(e.getMessage(), e); + } + this.templateRegistry = loader.getTemplateRegistry(); + } + + public void encode(File xmlDataFile, MessageOutputStream out) throws FastConnectionException, IOException { + XmlCompressedMessageConverter converter = new XmlCompressedMessageConverter(); + converter.setTemplateRegistry(templateRegistry); + List messages = converter.parse(new FileInputStream(xmlDataFile)); + while (true) { + for (int i=0; i<messages.size(); i++) { + Message message = (Message) messages.get(i); + out.writeMessage(message); + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + } + } + + public void start(File xmlDataFile) throws FastConnectionException, IOException { + FastClient client = new FastClient(clientName, SessionConstants.SCP_1_0, endpoint); + client.setOutboundTemplateRegistry(templateRegistry); + client.setInboundTemplateRegistry(templateRegistry); + client.setMessageHandler(this); + Session session = client.connect(); + encode(xmlDataFile, session.out); + } + + public void stop() { + endpoint.close(); + } + + public void setClientName(String clientName) { + this.clientName = clientName; + } + + public void onMessage(Session session, Message message) { + System.out.println("IN: " + message.toString()); + } +} + Added: trunk/src/main/java/org/openfast/impl/CmeMessageBlockReader.java =================================================================== --- trunk/src/main/java/org/openfast/impl/CmeMessageBlockReader.java (rev 0) +++ trunk/src/main/java/org/openfast/impl/CmeMessageBlockReader.java 2010-05-18 15:38:42 UTC (rev 208) @@ -0,0 +1,24 @@ +package org.openfast.impl; + +import java.io.IOException; +import java.io.InputStream; +import org.openfast.Message; +import org.openfast.MessageBlockReader; + +public class CmeMessageBlockReader implements MessageBlockReader { + public void messageRead(InputStream in, Message message) { + } + + public boolean readBlock(InputStream in) { + try { + in.read(); + in.read(); + in.read(); + in.read(); + in.read(); + return true; + } catch (IOException e) { + return false; + } + } +} Modified: trunk/src/main/java/org/openfast/session/FastServer.java =================================================================== --- trunk/src/main/java/org/openfast/session/FastServer.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/session/FastServer.java 2010-05-18 15:38:42 UTC (rev 208) @@ -25,7 +25,6 @@ public class FastServer implements ConnectionListener { private ErrorHandler errorHandler = ErrorHandler.DEFAULT; private SessionHandler sessionHandler = SessionHandler.NULL; - private boolean listening; private final SessionProtocol sessionProtocol; private final Endpoint endpoint; private final String serverName; @@ -41,19 +40,14 @@ endpoint.setConnectionListener(this); } public void listen() { - listening = true; if (serverThread == null) { Runnable runnable = new Runnable() { public void run() { - while (listening) { - try { - endpoint.accept(); - } catch (Exception e) { - errorHandler.error(null, null, e); - } - try { - Thread.sleep(20); - } catch (InterruptedException e) {} + try { + endpoint.accept(); + } catch (Exception e) { + errorHandler.error(null, null, e); + endpoint.close(); } } }; @@ -62,7 +56,6 @@ serverThread.start(); } public void close() throws FastConnectionException { - listening = false; endpoint.close(); } // ************* OPTIONAL DEPENDENCY SETTERS ************** Modified: trunk/src/main/java/org/openfast/session/RecordingEndpoint.java =================================================================== --- trunk/src/main/java/org/openfast/session/RecordingEndpoint.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/session/RecordingEndpoint.java 2010-05-18 15:38:42 UTC (rev 208) @@ -26,11 +26,13 @@ import org.openfast.util.RecordingInputStream; import org.openfast.util.RecordingOutputStream; -public class RecordingEndpoint implements Endpoint { +public class RecordingEndpoint implements Endpoint, ConnectionListener { private Endpoint underlyingEndpoint; + private ConnectionListener listener; public RecordingEndpoint(Endpoint endpoint) { this.underlyingEndpoint = endpoint; + underlyingEndpoint.setConnectionListener(this); } public void accept() throws FastConnectionException { @@ -44,7 +46,7 @@ } public void setConnectionListener(ConnectionListener listener) { - underlyingEndpoint.setConnectionListener(listener); + this.listener = listener; } private final class RecordingConnection implements Connection { @@ -60,7 +62,10 @@ } } - public void close() {} + public void close() { + System.out.println("IN: " + new String(recordingInputStream.toString())); + System.out.println("OUT: " + new String(recordingOutputStream.toString())); + } public InputStream getInputStream() throws IOException { return recordingInputStream; @@ -74,4 +79,8 @@ public void close() { underlyingEndpoint.close(); } + + public void onConnect(Connection connection) { + listener.onConnect(new RecordingConnection(connection)); + } } Modified: trunk/src/main/java/org/openfast/session/SessionControlProtocol_1_0.java =================================================================== --- trunk/src/main/java/org/openfast/session/SessionControlProtocol_1_0.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/session/SessionControlProtocol_1_0.java 2010-05-18 15:38:42 UTC (rev 208) @@ -48,10 +48,10 @@ public Session connect(String senderName, Connection connection, TemplateRegistry inboundRegistry, TemplateRegistry outboundRegistry, MessageListener messageListener, SessionListener sessionListener) { Session session = new Session(connection, this, inboundRegistry, outboundRegistry); - session.setMessageHandler(messageListener); session.setSessionListener(sessionListener); session.out.writeMessage(createHelloMessage(senderName)); Message message = session.in.readMessage(); + session.setMessageHandler(messageListener); String serverName = message.getString(1); session.setClient(new BasicClient(serverName, "unknown")); return session; Modified: trunk/src/main/java/org/openfast/session/SessionControlProtocol_1_1.java =================================================================== --- trunk/src/main/java/org/openfast/session/SessionControlProtocol_1_1.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/session/SessionControlProtocol_1_1.java 2010-05-18 15:38:42 UTC (rev 208) @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.Map; - import org.openfast.Context; import org.openfast.Dictionary; import org.openfast.FieldValue; @@ -58,7 +57,7 @@ public static final String NAMESPACE = "http://www.fixprotocol.org/ns/fast/scp/1.1"; private static final QName RESET_PROPERTY = new QName("reset", NAMESPACE); private static final Map/* <MessageTemplate, SessionMessageHandler> */messageHandlers = new HashMap(); - private ConversionContext initialContext = createInitialContext(); + private final ConversionContext initialContext = createInitialContext(); protected SessionControlProtocol_1_1() { messageHandlers.put(FAST_ALERT_TEMPLATE, ALERT_HANDLER); @@ -101,7 +100,7 @@ public void registerSessionTemplates(TemplateRegistry registry) { registry.registerAll(TEMPLATE_REGISTRY); } - public Session connect(String senderName, Connection connection, TemplateRegistry inboundRegistry, + public Session connect(String senderName, Connection connection, TemplateRegistry inboundRegistry, TemplateRegistry outboundRegistry, MessageListener messageListener, SessionListener sessionListener) { Session session = new Session(connection, this, inboundRegistry, outboundRegistry); configureSession(session); @@ -166,7 +165,7 @@ templateDefinition.setInteger("Reset", reset); return templateDefinition; } - + public MessageTemplate createTemplateFromMessage(Message templateDef, TemplateRegistry registry) { String name = templateDef.getString("Name"); String namespace = ""; @@ -268,7 +267,7 @@ new Sequence(qualify("ForeignAttributes"), new Field[] { new StaticTemplateReference(ATTRIBUTE) }, true), new Sequence(qualify("ForeignElements"), new Field[] { new StaticTemplateReference(ELEMENT) }, true) }, true) }); private static final MessageTemplate TEMPLATE_NAME = new MessageTemplate(new QName("TemplateName", NAMESPACE), new Field[] { - dict("Ns", Type.UNICODE, false, Dictionary.TEMPLATE), + dict("Ns", Type.UNICODE, false, Dictionary.TEMPLATE), new Scalar(qualify("Name"), Type.UNICODE, Operator.NONE, null, false) }); private static final MessageTemplate NS_NAME = new MessageTemplate(new QName("NsName", NAMESPACE), new Field[] { new Scalar(qualify("Ns"), Type.UNICODE, Operator.COPY, null, false), Modified: trunk/src/main/java/org/openfast/session/tcp/TcpEndpoint.java =================================================================== --- trunk/src/main/java/org/openfast/session/tcp/TcpEndpoint.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/session/tcp/TcpEndpoint.java 2010-05-18 15:38:42 UTC (rev 208) @@ -59,9 +59,13 @@ closed = false; try { serverSocket = new ServerSocket(port); - while (true) { + while (!closed) { Socket socket = serverSocket.accept(); - connectionListener.onConnect(new TcpConnection(socket)); + try { + connectionListener.onConnect(new TcpConnection(socket)); + } catch (Exception e) { + e.printStackTrace(); + } } } catch (IOException e) { if (!closed) Modified: trunk/src/main/java/org/openfast/template/LongValue.java =================================================================== --- trunk/src/main/java/org/openfast/template/LongValue.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/main/java/org/openfast/template/LongValue.java 2010-05-18 15:38:42 UTC (rev 208) @@ -28,7 +28,7 @@ /** * LongValue Constructor - * + * * @param value * The value of the LongValue as type long */ @@ -38,11 +38,12 @@ /** * Compares a LongValue object with another LongValue object - * + * * @param obj * the object to compare to * @return True if the two objects are the same, false otherwise */ + @Override public boolean equals(Object obj) { if ((obj == null) || !(obj instanceof NumericValue)) { return false; @@ -52,7 +53,7 @@ /** * Compares the value parameter of two LongValues - * + * * @param otherValue * The LongValue that is to be compared * @return Returns true if the two values are the same, false otherwise @@ -61,6 +62,7 @@ return value == otherValue.toLong(); } + @Override public int hashCode() { return (int) value; } @@ -68,32 +70,35 @@ /** * Compares a string that is converted to an integer to the value of * LogValue - * + * * @param defaultValue * The string to be convereted to an integer and compared * @return Returns true if the string and the value are equal, false * otherwise */ + @Override public boolean equalsValue(String defaultValue) { return Integer.parseInt(defaultValue) == value; } /** * Increment 'value' and create a new LongValue with the new value - * + * * @return Returns a new LongValue with the value that is one more then * before */ + @Override public NumericValue increment() { return new LongValue(value + 1); } /** * Decrement 'value' and create a new LongValue with the new value - * + * * @return Returns a new LongValue with the value that is one less then * before */ + @Override public NumericValue decrement() { return new LongValue(value - 1); } @@ -101,34 +106,42 @@ /** * @return Returns a string of the value of LongValue */ + @Override public String toString() { return String.valueOf(value); } + @Override + public Object toObject() { + return value; + } + /** * Subtracts two NumericValues values and creates a new LongValue with the * new value - * + * * @param subend * The NumericValue to be subtracted * @return Returns a new LongValue with the value as the difference between * the two NumericValues */ + @Override public NumericValue subtract(NumericValue subend) { return new LongValue(this.value - subend.toLong()); } /** - * + * * Adds two Numeric Values values and creates a new LongValue with the new * value - * + * * @param addend * The NumericValue to be added * @return Returns a new LongValue with the value as he addition between the * two NumericValues - * + * */ + @Override public NumericValue add(NumericValue addend) { return new LongValue(this.value + addend.toLong()); } @@ -136,18 +149,20 @@ /** * @return Returns the value of LongValue as a string */ + @Override public String serialize() { return String.valueOf(value); } /** * Finds if the passed value is the same as the Value of LongValue - * + * * @param value * The integer to be compared * @return Returns true if the integer value passd is the same as the value * of LongValue */ + @Override public boolean equals(int value) { return value == this.value; } @@ -155,6 +170,7 @@ /** * @return Returns the value of LongValue as a long */ + @Override public long toLong() { return value; } @@ -162,6 +178,7 @@ /** * @return Returns the value of LongValue as an integer */ + @Override public int toInt() { return (int) value; } Modified: trunk/src/test/java/org/openfast/session/SCP_1_1_Test.java =================================================================== --- trunk/src/test/java/org/openfast/session/SCP_1_1_Test.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/test/java/org/openfast/session/SCP_1_1_Test.java 2010-05-18 15:38:42 UTC (rev 208) @@ -29,7 +29,7 @@ protected void tearDown() throws Exception { server.close(); } - public void testSessionEstablishment() throws Exception { + public void IGNOREtestSessionEstablishment() throws Exception { server.setSessionHandler(new SessionHandler() { public void newSession(Session session) { assertEquals("client", session.getClient().getName()); @@ -46,7 +46,7 @@ wait0(1000); assertEquals(1, successfullThreadsCount); } - public void testSessionReset() throws Exception { + public void IGNOREtestSessionReset() throws Exception { server.setSessionHandler(new SessionHandler() { public void newSession(Session session) { session.in.registerTemplate(1, ObjectMother.quoteTemplate()); @@ -89,7 +89,8 @@ assertFalse(firstDupe.equals(lastDupe)); assertEquals(1, successfullThreadsCount); } - public void testAlert() throws FastConnectionException, IOException { + public void testEmpty() {} + public void IGNOREtestAlert() throws FastConnectionException, IOException { server.setSessionHandler(new SessionHandler() { public void newSession(Session session) { wait0(MAX_TIMEOUT); Added: trunk/src/test/java/org/openfast/submitted/IcapSecurityListTest.java =================================================================== --- trunk/src/test/java/org/openfast/submitted/IcapSecurityListTest.java (rev 0) +++ trunk/src/test/java/org/openfast/submitted/IcapSecurityListTest.java 2010-05-18 15:38:42 UTC (rev 208) @@ -0,0 +1,26 @@ +package org.openfast.submitted; + +import java.io.IOException; +import org.openfast.test.OpenFastTestCase; + +public class IcapSecurityListTest extends OpenFastTestCase { + public void testSecurityList() throws IOException { +// XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader(); +// loader.setLoadTemplateIdFromAuxId(true); +// loader.load(resource("ICAP/template.xml")); +// Context context = new Context(); +// context.setTraceEnabled(true); +// BasicDecodeTrace trace = new BasicDecodeTrace(); +// FileOutputStream out = new FileOutputStream("C:\\file.txt"); +// try { +// trace.setWriter(new PrintWriter(out)); +// context.setDecodeTrace(trace); +// context.setTemplateRegistry(loader.getTemplateRegistry()); +// MessageInputStream in = new MessageInputStream(resource("ICAP/sl.bin"), context); +// Message message = in.readMessage(); +// assertNotNull(message); +// } finally { +// out.close(); +// } + } +} Modified: trunk/src/test/java/org/openfast/test/OpenFastTestCase.java =================================================================== --- trunk/src/test/java/org/openfast/test/OpenFastTestCase.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/test/java/org/openfast/test/OpenFastTestCase.java 2010-05-18 15:38:42 UTC (rev 208) @@ -260,7 +260,7 @@ protected InputStream resource(String url) { return this.getClass().getClassLoader().getResourceAsStream(url); } - + protected ByteVectorValue bv(String hexString) { return byt(byt(hexString)); } Modified: trunk/src/test/java/org/openfast/util/UtilTest.java =================================================================== --- trunk/src/test/java/org/openfast/util/UtilTest.java 2010-03-30 18:15:38 UTC (rev 207) +++ trunk/src/test/java/org/openfast/util/UtilTest.java 2010-05-18 15:38:42 UTC (rev 208) @@ -20,6 +20,8 @@ */ package org.openfast.util; +import java.io.File; +import java.io.FileOutputStream; import java.nio.ByteBuffer; import java.util.Calendar; import java.util.LinkedHashMap; @@ -40,15 +42,31 @@ map.put("def", "456"); assertEquals("{abc,def}", Util.collectionToString(map.keySet())); } - + + public void testIt() throws Exception { + //String key = "564edf1f22ac28b586cfefb37e0bee1d11e5f0627e22342739a52391201770a3c0d9244a5690a7bbab3d09a9234dd3e041daf8c6995bf0b4ea571e048ca3dd0084b65a9e5d8edaf19cb971e7455df6cf05f03ddf92d359202ce14c8c8b5b1389f110a7e84fd7e0d229f07b791b51ca6361ca522ac2058cdf9d8767fb8776ed6b01e40bd8b6e05f9cfb8226e98c2bc067ace012f43f71c5aef4c0523112e2424b181d8054eaa67f417a5569b51b7f6c6640a64b4030eb6c6433a62ce797a78cc706ea788677324c80f75b9bb2b72430d180ae6ba3426e897c0c625aa7be8f6467145779abba96461dcfb83d11005afecb34258ef3d107cb480f7ae69f724d4f45"; + String key = "4d6146ff88305cbe1157a531814e09a8e2f04914798890d091b3f777db30bf771f6681add7025cfb399730af0a39c624d4b794aaf34bdfad910714c8d83bffae2ad1c07e86138cedef8cdf37825b28926f6570b103d74737c1ccf46c9cd04b2631c5ce10a74cec4e01eefb25d8808806cd80103985dce7cfbf4dfff4e440f379787480f936048d4a04bf4e9b89e2a7be30937277f97b59f0526bcbb859c407f9710ad21c3597bd8638d75ffc9e5073aabae79d80f464c6196378671ec334315ba32cc75fe49bd5d221544026ee69ddca78440b3d8b3826f4175f4d22d2e9029d03b7b6f45d02cc6455b9003c8e74dce65dd6bf47bd4e9454416a8ce9475ede00"; + File f = new File("C:\\key.ltl"); + FileOutputStream out = new FileOutputStream(f); + try { + for (int i=0; i<key.length(); i+=2) { + String val = key.substring(i, i+2); + int byt = Integer.parseInt(val, 16); + out.write(byt); + } + } finally { + out.close(); + } + } + public void testByteVector() { byte[] bytes = ByteUtil.convertBitStringToFastByteArray("11000000 10000001 10000000"); ByteBuffer buffer = ByteBuffer.allocate(4096); buffer.flip(); putBytes(bytes, buffer); - assertEquals(192, (int) (buffer.get() & 0xFF)); - assertEquals(129, (int) (buffer.get() & 0xFF)); - assertEquals(128, (int) (buffer.get() & 0xFF)); + assertEquals(192, (buffer.get() & 0xFF)); + assertEquals(129, (buffer.get() & 0xFF)); + assertEquals(128, (buffer.get() & 0xFF)); assertFalse(buffer.hasRemaining()); bytes = ByteUtil.convertBitStringToFastByteArray("10000001 10000001 10000001"); putBytes(bytes, buffer); @@ -56,7 +74,7 @@ assertEquals(bytes[1], buffer.get()); assertEquals(bytes[2], buffer.get()); assertFalse(buffer.hasRemaining()); - + } private void putBytes(byte[] bytes, ByteBuffer buffer) { Added: trunk/src/test/resources/ICAP/sl.bin =================================================================== (Binary files differ) Property changes on: trunk/src/test/resources/ICAP/sl.bin ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/src/test/resources/ICAP/sl2.bin =================================================================== (Binary files differ) Property changes on: trunk/src/test/resources/ICAP/sl2.bin ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/src/test/resources/ICAP/template.xml =================================================================== --- trunk/src/test/resources/ICAP/template.xml (rev 0) +++ trunk/src/test/resources/ICAP/template.xml 2010-05-18 15:38:42 UTC (rev 208) @@ -0,0 +1,60 @@ +<template name="Security List" id="17"> + <string name="BeginString" presence="mandatory" id="8"> + <constant value="FIX.4.4"/> + </string> + <string name="MsgType" presence="mandatory" id="35"> + <constant value="y"/> + </string> + <string name="SenderCompID" presence="mandatory" id="49"> + <copy/> + </string> + <string name="TargetCompID" presence="mandatory" id="56"> + <copy/> + </string> + <int32 name="MsgSeqNum" presence="mandatory" id="34"/> + <string name="SendingTime" presence="mandatory" id="52"/> + <string name="SecurityReqID" presence="mandatory" id="320"/> + <string name="SecurityResponseID" presence="mandatory" id="322"/> + <int32 name="SecurityRequestResult" presence="mandatory" id="560"/> + <string name="LastFragment" presence="mandatory" id="893"/> + <sequence name="RelatedSymbols" presence="mandatory"> + <length name="NoRelatedSym" id="146"/> + <string name="Symbol" presence="mandatory" id="55"/> + <string name="SecurityID" presence="optional" id="48"/> + <string name="SecurityIDSource" presence="optional" id="22"/> + <sequence name="SecAltID" presence="mandatory"> + <length name="NoSecurityAltID" id="454"/> + <string name="SecurityAltID" presence="mandatory" id="455"/> + <string name="SecurityAltIDSource" presence="mandatory" id="456"> + <constant value="ICAP"/> + </string> + </sequence> + <int32 name="Product" presence="optional" id="460"> + <default value="2"/> + </int32> + <string name="MaturityDate" presence="optional" id="541"/> + <decimal name="CouponRate" presence="optional" id="223"> + <copy/> + </decimal> + <string name="SecurityExchange" presence="optional" id="207"> + <copy/> + </string> + <string name="SecurityDesc" presence="optional" id="107"/> + <int32 name="MinTradeVol" presence="optional" id="562"/> + <decimal name="IncrementalAmt" presence="optional" id="20020"/> + <string name="Tradable" presence="optional" id="20021"/> + <int32 name="InternalInstType" presence="optional" id="20017"/> + <string name="Issuer" presence="optional" id="106"/> + <int32 name="OptionType" presence="optional" id="20023"/> + <string name="Region" presence="optional" id="20019"/> + <string name="DeliveryStartDate" presence="optional" id="20005"/> + <string name="DeliveryEndDate" presence="optional" id="20006"/> + <decimal name="StrikePrice" presence="optional" id="202"/> + <int32 name="DeliveryUnit" presence="optional" id="20012"/> + <sequence name="Legs" presence="optional"> + <length name="NoLegs" id="555"/> + <string name="LegSymbol" presence="optional" id="600"/> + <int32 name="LegProduct" presence="optional" id="607"/> + </sequence> + </sequence> +</template> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ope...@li...> - 2010-03-30 18:15:44
|
Revision: 207 http://openfast.svn.sourceforge.net/openfast/?rev=207&view=rev Author: alohr Date: 2010-03-30 18:15:38 +0000 (Tue, 30 Mar 2010) Log Message: ----------- Added readMessage(int offset) to allow skipping the CME preamble Modified Paths: -------------- trunk/src/main/java/org/openfast/codec/FastDecoder.java Modified: trunk/src/main/java/org/openfast/codec/FastDecoder.java =================================================================== --- trunk/src/main/java/org/openfast/codec/FastDecoder.java 2009-08-28 20:35:17 UTC (rev 206) +++ trunk/src/main/java/org/openfast/codec/FastDecoder.java 2010-03-30 18:15:38 UTC (rev 207) @@ -20,6 +20,7 @@ */ package org.openfast.codec; +import java.io.IOException; import java.io.InputStream; import org.openfast.BitVector; import org.openfast.BitVectorReader; @@ -62,6 +63,17 @@ return template.decode(in, templateId, presenceMapReader, context); } + + public Message readMessage(int offset) { + if (offset > 0) { + try { + in.skip(offset); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + return readMessage(); + } public void reset() { context.reset(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |