[QFJ-154] Modify MessageFactory interface to add a functionality to create a group based on an enclosing message and group type Created: 10/Mar/07 Updated: 31/May/07 Resolved: 28/Mar/07 |
|
Status: | Closed |
Project: | QuickFIX/J |
Component/s: | Engine |
Affects Version/s: | 1.0.5 |
Fix Version/s: | 1.1.0 |
Type: | New Feature | Priority: | Default |
Reporter: | Toli Kuznets | Assignee: | Toli Kuznets |
Resolution: | Fixed | Votes: | 0 |
Labels: | None |
Attachments: | createGroup.patch | ||||||||
Issue Links: |
|
Description |
Currently, the MessageFactory class only exposes functionality to create a Message based on the FIX version and MsgType. Would be nice to also add a function that would create a group, based on the version, MsgType and the corresponding group type. Here's the prototype: /** * Creates a group for the specified parent message type and * for the fields with the corresponding field ID * * Example: to create a {@link quickfix.fix42.MarketDataRequest.NoMDEntryTypes} * you need to call * create({@link quickfix.field.MsgType#MARKET_DATA_REQUEST, {@link quickfix.field.NoMDEntryTypes#FIELD}) * * @param msgType Message type of the enclosing message * @param correspondingFieldID the fieldID of the field in the group * @return group */ public Group create(String beginString, String msgType, int correspondingFieldID); The change itself is fairly trivial - we just modify the XSLT that creates the MessageFactory classes to add another function. Any thoughts, requests or other implementation ideas? |
Comments |
Comment by Toli Kuznets [ 10/Mar/07 ] |
patch with changes and unit test |
Comment by Brad Harvey [ 14/Mar/07 ] |
Hi Toli, I think it's a good idea. I'd potentially use a convenience method which takes a Message instance instead of beginString and msgType. Which actually makes me wonder, can the generated Message classes have a method to create the groups instead? /**
Message quoteRequest = messageFactory.create("FIX.4.4", MsgType.QUOTE_REQUEST); Unfortunately you'd need a default implementation for Message which throws some type of error, which may be a good reason not to do it this way. Additionally/alternatively, each message could have a specific createGroup method for its groups. Eg QuoteRequest quoteRequest = new QuoteRequest(); Not sure if adding as well as creating is a good idea, and of course the method names are horrible but you get the picture. Cheers, |
Comment by Toli Kuznets [ 19/Mar/07 ] |
Brad, What you are suggesting in the first part is a good idea, to have think that'd be a pretty convenient method. I'm not sure about having a create function for each specific group - I think it'd be very unwieldy to have all these special-named functions, it'll quickly get cluttered and confusing. Steve, any thoughts? It'd definitely making generating each individual Message subclass more complicated, it'd have to know about which groups it has, but it's not impossible. and maybe "cleaner" than enumerating all the possible groups in the factory code. thoughts? |
Comment by Toli Kuznets [ 28/Mar/07 ] |
Fix checked in revision 605. /** * Creates a group for the specified parent message type and * for the fields with the corresponding field ID * * Example: to create a {@link quickfix.fix42.MarketDataRequest.NoMDEntryTypes} * you need to call * create({@link quickfix.field.MsgType#MARKET_DATA_REQUEST, {@link quickfix.field.NoMDEntryTypes#FIELD}) * * Function returns null if the group cannot be created. * @param beginString * the FIX version (for example, "FIX.4.2") * @param msgType Message type of the enclosing message * @param correspondingFieldID the fieldID of the field in the group * @return group, or null if the group can't be created. */ public Group create(String beginString, String msgType, int correspondingFieldID); |