Hi Ruwan, thanks for your response. As described earlier it is perfectly clear to me that the usage of LinkedHashMaps would not solve the „problem“ entirely as the order of top level elements might still change. On the other hand the more annoying problem is the order of the elements below the top level elements, e.g. the list of hundreds of proxies, sequences and so on in random order. It was just a thought that changing the implementation to LinkedHashMaps would not hurt and at least address this particular issue. I tested it out and it is really an improvement.
Rethinking about the serialization process and the object store structure might also be a good thought. Enhancing on this part could also ease the process of writing custom mediators. Writing factories/serializer pairs gives a lot of control but also adds a lot of boilerplate-code and forces users to get in touch with rather low level XML-API (Axiom). Regards, Eric ________________________________ From: Ruwan Linton [mailto:[email protected]] Sent: Monday, November 09, 2009 11:20 PM To: [email protected] Subject: Re: Constant/reproducable order of elements in synapse.xml Hi Eric, I was on vacation and just got back. :-) Going through my email backlog. So, First of all I do not understand the issue that you are facing with the order. I agree that synapse serializes according to a hard order while builders do not expect that order. There is no specific reason to have that hard order, it was just the way that the serialization has been implemented. Since XML doesn't care about the order in which the elements are present, the serialization just goes on the different elements. Also if we are to preserve the order in which they were present in the synapse.xml that is used to build the configuration, making the object structure to be stored in LinkedHashMaps is not going to work since we keep separate HashMaps for the separate elements, for example proxy services are kept in its own HashMap while endpoints, sequences and local entries are on a different one. If we are to do this change we need to rethink about the serilization process and the object store structure. Thanks, Ruwan On Mon, Nov 9, 2009 at 11:04 AM, Hubert, Eric <[email protected]<mailto:[email protected]>> wrote: Hi Supun, If the object model does not preserve the order in which it has been created a serializer would need to store the order in some place independent from the configuration model itself which is also accessible by the deserializer at any later stage. Another implication is, that it is not enough to feed a deserializer just with the configuration model alone. It would need the additional meta data to be able to preserve the original order. Also any serializer/factory-deserializer-pair would need to implement this. Maybe others have already discussed about this at design time? Any input from the devs early involved? Regards, Eric ________________________________ From: Supun Kamburugamuva [mailto:[email protected]<mailto:[email protected]>] Sent: Monday, November 09, 2009 5:46 AM To: [email protected]<mailto:[email protected]> Subject: Re: Constant/reproducable order of elements in synapse.xml Hi Eric, I thought about this a bit further. Synapse runs on an object model. Not on a XML configuration. As far as I understood this was the original goal. Also it makes sense. The synapse configuration can be created using XML or may be spring or may be pure programming. At the synapse object model layer I think it is logical to use a hash map. If a particular serialization and building wants to have an order it is the responsibility of the build and serialize method writer to impose it. Isn't there a way to impose this at the serialize and builder level? Thanks, Supun.. On Sun, Nov 8, 2009 at 2:22 AM, Hubert, Eric <[email protected]<mailto:[email protected]>> wrote: Hi Supun, Please see my comments inline! Synapse language is treated as a programming language at least for the out side world. For example sequences can be attributed to functions. In any programming language the order in which these symbols occur does not matter as long as the symbols can be found by the caller. Agreed. So I have doubts in implementing an order for the synapse elements. By order I meant something like all the sequences are at the top then the proxy services etc. I share these doubts, but you describe exactly the current implementation. Please have a look at: SynapseXMLConfigurationSerializer.serializeConfiguration(SynapseConfiguration synCfg). It uses a fixed order of top level elements. Specific element serializers are then using an order depending on the way the configuration has been stored in memory. Mostly the XML information will be transferred to strongly typed data structures. While deserializing those values, currently a fixed order will be used. This might be different, from the one originally read in. Some list like structures are stored to unordered Map-Implementations for faster key-value access. While deserializing those values you end up with a random order. I think that this part could be fixed rather easily by using LinkedHashMap preserving the key order in which entries have been added to the map. When a user types in the synapse.xml, we should be able to preserve the order in which they have entered the elements in the synapse.xml. If you meant this one I'm +1 for implementing it. I also agree this would be the most desirable option, although the current implementation seems to be very far a way from that. Each factory/serializer pair would need to be designed for this purpose (e.g. keep a list or list of linked maps or any suitable structure of read elements/attributes, store it for deserialization purposes only and use this to retrieve the values in the exact order from structured object structures). I guess only something like this could warrant a working round-trip serialization/deserialization where the user may modify any part of the configuration, insert new stuff at any allowed place and this exact order will be preserved during later deserializations. So my concrete suggestion for a start was just to replace all class member implementations of SynapseConfiguration which are currently of type HashMap with LinkedHashMap. From my point of view this is at least an improvement. No pain, big gain? ;-) Regards, Eric -- Software Engineer, WSO2 Inc http://wso2.org supunk.blogspot.com<http://supunk.blogspot.com> -- Ruwan Linton Technical Lead & Product Manager; WSO2 ESB; http://wso2.org/esb WSO2 Inc.; http://wso2.org email: [email protected]<mailto:[email protected]>; cell: +94 77 341 3097 blog: http://ruwansblog.blogspot.com
