Hi Manish,
Please find steps I did to gain performance,
Extracting information from XML and converting it into VO is done in AIR
application,
Code in AIR project:
function windowedapplication1_applicationCompleteHandler(event:FlexEvent):void
{
//XML information data. Demo xml is provided
actual xml has thousands of line code.
var objectModelXML:XML = new XML(<Policy>
<policyNumber>POL123</policyNumber>
<policyName>RAJ</policyName>
<amount>Billion</amount>
<Attribute>
<Name>R1</Name>
<Fame>R2</Fame>
</Attribute>
</Policy>);
//registerClassAlias("ObjectModel",
ObjectModel); //registering vo class ObjectModel in AIR app
var object:ObjectModel =
convertXMLToObject(objectModelXML);
var ba:ByteArray = new ByteArray();
ba.writeObject(object);
trace(writeBinaryFile("om", ba));
}
private function
convertXMLToObject(objectModel:XML):ObjectModel{
var object:ObjectModel = new ObjectModel();
for each(var value:XML in
objectModel.children()){
if(value.localName() == "Attribute"){
object.attributeXML = value;
}else{
object[value.localName()] =
value.text().toString();
}
}
return object;
}
public function writeBinaryFile(name : String, array :
ByteArray) : String {
try {
var f : File =
File.desktopDirectory.resolvePath(name);
var fs : FileStream = new FileStream();
fs.open(f, FileMode.WRITE);
fs.writeBytes(array);
fs.close();
return f.nativePath + " written.";
}
catch (err : Error) {
return err.name;
}
return "Error writing file.";
}
This air app will generate file name "om" on desktop. The file "om" has a as3
objects containing information of XML's
Code in Apllication, (embed om file into application)
[Embed(source="om",
mimeType="application/octet-stream")]
private var om:Class;
protected function
application1_creationCompleteHandler(event:FlexEvent):void
{
// TODO Auto-generated method stub
registerClassAlias("ObjectModel", ObjectModel);
//registering vo class ObjectModel with application
var byteArray:ByteArrayAsset =
ByteArrayAsset(new om());
var object:Object = byteArray.readObject();
if(object is ObjectModel){ //If you don't
register "ObjectModel" class then app will not need info successfully.
trace("true");
//read object information directly
instead of extracting information from xml.
}
}
Common Library Code of VO: (This library swc containing various VO's will be
shared among air and runtime app)
//For example, I am showing single demo class
public class ObjectModel
{
private var _policyName:String;
private var _policyNumber:String;
private var _amount:String;
private var _attributeXML:XML;
public function ObjectModel()
{
}
public function get policyName():String
{
return _policyName;
}
public function set policyName(value:String):void
{
_policyName = value;
}
public function get policyNumber():String
{
return _policyNumber;
}
public function set policyNumber(value:String):void
{
_policyNumber = value;
}
public function get amount():String
{
return _amount;
}
public function set amount(value:String):void
{
_amount = value;
}
public function get attributeXML():XML
{
return _attributeXML;
}
public function set attributeXML(value:XML):void
{
_attributeXML = value;
}
}
Thanks & Regards,
Raj Shaikh
Senior Software Engineer
Majesco Mastek - P&C Division
Mastek Millennium Center, A-7, Millennium Business Park, Sector 1 Off Thane
Belapur Road, Mahape Navi Mumbai - 400701
(T) 91 22 27781272 Extn - 5250 | Mobile: 9970395965 | Fax: 91 22 27781332 |
www.mastek.com
||yatha dristi, tatha sristi||
-----Original Message-----
From: Manish Sharma [mailto:[email protected]]
Sent: Wednesday, July 24, 2013 12:06 PM
To: [email protected]
Subject: RE: Performance issue's
Hi Raju,
Can you please define this with a small piece of code.
Regards,
Manish
-----Original Message-----
From: Raj U. Shaikh [mailto:[email protected]]
Sent: Tuesday, July 23, 2013 4:59 PM
To: [email protected]
Subject: RE: Performance issue's
Thanks Maurice, it did worked.
Created a AIR application which will generate a VO's from XML's. (Vo class is
shared in between air application and main application) Then generated VO's are
dumped into hard disk by using ByteArray.
Dumped file then embedded into running application.
By using ByteArray.readObject taken binaray data.
Type casted object to VO class by using registerClassAsAlias method.
Smoothly working :)
-----Original Message-----
From: Maurice Amsellem [mailto:[email protected]]
Sent: Monday, July 22, 2013 10:19 PM
To: [email protected]
Subject: RE: Performance issue's
Possible solution:
Use serialization =>
1) Built a utility that will parse the XML , convert them to VOs, serialize the
VOs and save the result as a binary file, all at "build" time.
2) embed the binary file into your app.
3) Then at runtime, read the embedded file then deserialize to get back the
VOs.
Maurice
-----Message d'origine-----
De : Raj U. Shaikh [mailto:[email protected]] Envoyé : lundi 22 juillet
2013 18:22 À : [email protected] Objet : Performance issue's
Hi,
I am facing performance issue with application which plays with xml's
Problem is:
1. There are too many heavy xml embedded in flex modules swf.
2. After load of these module we start parsing that xml's in to VO's.
(Value Object a simple as3 object)
3. We use these VO's at different part of application as and when
necessary.
While, Profiling application using 'flash builder profiler' I encountered that
step 2(parsing xml's and converting it to Vo's) is taking more time and
responsible for many loitering of xml objects.
Solution is:
1. I want a utility which will generate a swf which will have as3 VO's
converted from xml's.
2. Application will load that swf file and start using that VO's directly.
That means I wanted a readymade VO's so that my parsing time will be reduced.
Implementation?
So how can I embed as3 objects instead of xml's into swf/modules?
Or
How can I convert xml's into as3 VO's at compile time? (I am ready with compile
time overhead than runtime)
Clue is:
In BlazeDS, We can convert Java objects into as3 objects.
So similarly can we convert xml's into as3 or xml's into java objects then into
as3 objects?
Thanks & Regards,
Raj Shaikh
Senior Software Engineer
Majesco Mastek - P&C Division
Mastek Millennium Center, A-7, Millennium Business Park, Sector 1 Off Thane
Belapur Road, Mahape Navi Mumbai - 400701
(T) 91 22 27781272 Extn - 5250 | Mobile: 9970395965 | Fax: 91 22 27781332 |
www.mastek.com<http://www.mastek.com/>
||yatha dristi, tatha sristi||
MASTEK LTD.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of
Mastek Limited, unless specifically indicated to that effect. Mastek Limited
does not accept any responsibility or liability for it. This e-mail and
attachments (if any) transmitted with it are confidential and/or privileged and
solely for the use of the intended person or entity to which it is addressed.
Any review, re-transmission, dissemination or other use of or taking of any
action in reliance upon this information by persons or entities other than the
intended recipient is prohibited. This e-mail and its attachments have been
scanned for the presence of computer viruses. It is the responsibility of the
recipient to run the virus check on e-mails and attachments before opening
them. If you have received this e-mail in error, kindly delete this e-mail from
desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
MASTEK LTD.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of
Mastek Limited, unless specifically indicated to that effect. Mastek Limited
does not accept any responsibility or liability for it. This e-mail and
attachments (if any) transmitted with it are confidential and/or privileged and
solely for the use of the intended person or entity to which it is addressed.
Any review, re-transmission, dissemination or other use of or taking of any
action in reliance upon this information by persons or entities other than the
intended recipient is prohibited. This e-mail and its attachments have been
scanned for the presence of computer viruses. It is the responsibility of the
recipient to run the virus check on e-mails and attachments before opening
them. If you have received this e-mail in error, kindly delete this e-mail from
desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::DISCLAIMER::
----------------------------------------------------------------------------------------------------------------------------------------------------
The contents of this e-mail and any attachment(s) are confidential and intended
for the named recipient(s) only.
E-mail transmission is not guaranteed to be secure or error-free as information
could be intercepted, corrupted,
lost, destroyed, arrive late or incomplete, or may contain viruses in
transmission. The e mail and its contents
(with or without referred errors) shall therefore not attach any liability on
the originator or HCL or its affiliates.
Views or opinions, if any, presented in this email are solely those of the
author and may not necessarily reflect the
views or opinions of HCL or its affiliates. Any form of reproduction,
dissemination, copying, disclosure, modification,
distribution and / or publication of this message without the prior written
consent of authorized representative of
HCL is strictly prohibited. If you have received this email in error please
delete it and notify the sender immediately.
Before opening any email and/or attachments, please check them for viruses and
other defects.
----------------------------------------------------------------------------------------------------------------------------------------------------
MASTEK LTD.
In the US, we're called MAJESCOMASTEK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opinions expressed in this e-mail are those of the individual and not that of
Mastek Limited, unless specifically indicated to that effect. Mastek Limited
does not accept any responsibility or liability for it. This e-mail and
attachments (if any) transmitted with it are confidential and/or privileged and
solely for the use of the intended person or entity to which it is addressed.
Any review, re-transmission, dissemination or other use of or taking of any
action in reliance upon this information by persons or entities other than the
intended recipient is prohibited. This e-mail and its attachments have been
scanned for the presence of computer viruses. It is the responsibility of the
recipient to run the virus check on e-mails and attachments before opening
them. If you have received this e-mail in error, kindly delete this e-mail from
desktop and server.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~