[
https://issues.apache.org/jira/browse/AXIS2-2957?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12512522
]
Amila Chinthaka Suriarachchi commented on AXIS2-2957:
-----------------------------------------------------
we have to improve the add element method so that it should avoid list to array
conversion. But the way you have suggested use java anotations which is 1.5
specific. but we have to keep this code 1.4 compatible.
> ADB. Time of addition of elements into array proportionally to a Sum!
> ---------------------------------------------------------------------
>
> Key: AXIS2-2957
> URL: https://issues.apache.org/jira/browse/AXIS2-2957
> Project: Axis 2.0 (Axis2)
> Issue Type: Bug
> Components: adb, codegen
> Affects Versions: 1.2
> Environment: Win XP Pro, Tomcat 5.5.20, Eclipse 3.2, Sun JDK 1.5
> Reporter: Denis
> Assignee: Amila Chinthaka Suriarachchi
> Priority: Critical
> Attachments: adb-codegen-sample-bug-factorial.zip
>
>
> The code, generated by ADB for addition of an element to an array, is carried
> out in time proportional to a sum from number of added elements.
> Also the ADB generates a dirty (bad formatted and without using import
> statements) code.
> The code was generated from Eclipse by wizard "Axis2 code generator".
> Small part of WSDL:
> <xs:complexType name="Advertisement">
> <xs:sequence>
> <xs:element name="id" type="xs:long"/>
> <xs:element name="placeId" type="xs:int"/>
> <xs:element name="header" type="xs:string"/>
> <xs:element name="file" type="xs:string"/>
> <xs:element minOccurs="0" name="url" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> <xs:complexType name="AdvertisementArray">
> <xs:sequence>
> <xs:element maxOccurs="unbounded" minOccurs="0"
> name="advertisement"
> type="data:Advertisement"/>
> </xs:sequence>
> </xs:complexType>
> <xs:complexType name="Packet">
> <xs:sequence>
> <xs:element name="id" type="xs:string"/>
> <xs:element minOccurs="0" name="sessionId"
> type="xs:string"/>
> <xs:element minOccurs="0" name="advertisements"
> type="data:AdvertisementArray"/>
> <xs:element minOccurs="0" name="info" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> <xs:element name="packet" type="data:Packet"/>
> See an example of a code:
> The auto generated by ADB AdvertisementArray.java contains following code:
> public void addAdvertisement (
> ru.scanrealty.supplier.deo. SRDAdvertisement param) {
> if (localAdvertisement == null) {
> localAdvertisement = new ru.scanrealty.supplier.deo.
> SRDAdvertisement [] {};
> }
> // update the setting tracker
> localAdvertisementTracker = true;
> java.util. List list =
> org.apache.axis2.databinding.utils.ConverterUtil
> .toList (localAdvertisement);
> list.add (param);
> this.localAdvertisement = (ru.scanrealty.supplier.deo.
> SRDAdvertisement []) list
> .toArray (new ru.scanrealty.supplier.deo.
> SRDAdvertisement [list
> .size ()]);
> }
> Also org.apache.axis2.databinding.utils.ConverterUtil.java contains following
> code:
> public static List toList (Object [] array) {
> if (array == null) {
> return new ArrayList ();
> } else {
> ArrayList list = new ArrayList ();
> for (int i = 0; i < array.length; i ++) {
> list.add (array [i]);
> }
> return list;
> }
> }
> It's very bad code!
> The following code will be carried out in time proportional to a sum from
> amount of added elements:
> ResultSet rs = < gets result set from DB >
> AdvertisementArray advertisements = new AdvertisementArray ();
> while (rs.next ()) {
> advertisements.addAdvertisement (createAdvertisement (rs));
> }
> It occurs because of transformation of an array to the list and copying of
> elements of an array in a loop in a code ConverterUtil.toList().
> In Java the given code should be as:
> public class AdvertisementArray
> implements org.apache.axis2.databinding. ADBBean {
> ......
> protected ArrayList <Advertisement> localAdvertisement; // Sequence and
> repeated elements.
> public Advertisement [] getAdvertisement () {
> ... some checks (also up on null) ...
> return (Advertisement []) localAdvertisement.toArray (new
> Advertisement [0]);
> }
> public void addAdvertisement (Advertisement el) {
> ... some checks ...
> localAdvertisement.add (el);
> }
> ......
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]