Serge Jespers created a cool widget about MAX 2009 containing facts, testimonials and the possibility to tweet directly from it. Also, you can create your own video (if you have a video camera).
Random thoughts about software development.
Posted by cornel | Filed under Java, LCDS/Blaze DS, Uncategorized
I created a small class to allow integration between the logging mechanism from BlazeDS and java.util.logging. As an example it’s useful if you plan to use BlazeDS or Livecycle Data Services inside Google App Engine – the former one uses java.util.logging.
In order to use it you should modify services-config.xml to use the newly created class (I created my class in the package flex.messaging.log):
<target class=”flex.messaging.log.JavaUtilLogTarget” level=”Debug”>
The source code is below:
import java.util.logging.Level; public class JavaUtilLogTarget extends AbstractTarget{ public void logEvent(LogEvent event) { java.util.logging.Logger log = java.util.logging.Logger.getLogger(event.logger.getCategory()); Level level; if (event.level >= LogEvent.ERROR) level = Level.SEVERE; else if (event.level >= LogEvent.WARN) level = Level.WARNING; else if (event.level >= LogEvent.INFO) level = Level.INFO; else if (event.level >= LogEvent.DEBUG) level = Level.FINE; else level = Level.FINEST; log.log(level,event.message,event.throwable); } }
Posted by cornel | Filed under Uncategorized
I discovered this book several nights ago and I was amazed. Funny and in the same time valuable it is also a “no-crap” book about working in the software world, dealing with difficult people, the value of information, building the version number 1.0 and many more things. The author offers practical solutions for a lot of scenarios, in a very humorous way.
Its not a book for just managers or for wanna be managers, any individual can benefit from it. However I think that for some individuals it can be harder to accept several of the author’s conclusion (I told you, it’s a “no crap” book). Especially for younger people.
The book can be bought here; also the author has a blog.
Posted by cornel | Filed under Uncategorized
Next week I’ll visit several Java User Groups in Germany speaking about Flex and Java
27 August Dusseldorf
1 September Stuttgart
2 September Karslruhe
In Stuttgart I will also present Fiber – building RIAs using an Model Driven Architecture
Looking forward to meeting you. If you know for a company from any of these towns interested in learning more about RIA let me know.
Posted by cornel | Filed under Uncategorized
Serge Jespers created a cool widget about MAX 2009 containing facts, testimonials and the possibility to tweet directly from it. Also, you can create your own video (if you have a video camera).
Posted by cornel | Filed under Uncategorized
Yesterday I discovered a very nice tool for optimizing websites – Page Speed from Google. It installs as a menu entry in the Firebug plugin. Running this tool on several websites (including the Romania’s largest newspaper) shows very interesting results -a lot of things to improve. I’m sure that some of them are very hard to find without an automated tool.
Some suggestions for www.evz.ro (the Romanian newspaper). They could save 200kbytes just by using proper sized images.
Enable gzip compression
Leverage browser caching
Combine external JavaScript
Minify JavaScript
Optimize images
Optimize the order of styles and scripts
Parallelize downloads across hostnames
Minimize DNS lookups
Specify image dimensions
Remove unused CSS
Serve static content from a cookieless domain
Minimize cookie size
Use efficient CSS selectors
Posted by cornel | Filed under Java, Uncategorized
Update: I added also compression. The result is the same, Hessian is the clear winner. Not quite sure why deflate takes so much time when applied to AMF output, but I was able to reproduce this result with different inputs.
Two months ago I was asked by several guys from JUG Gothenburg to do a comparison between AMF and classic Java serialization. I was not able to answer at the moment, because I had never thought about it nor had I performed any tests. Now I extended my mini-benchmark from my previous post and I also serialized the objects using Java serialization. The results are below, and you can see from the results that the size of compressed data is much larger for Java serialization (I used Java 1.6). Without looking at the code from ObjectOutputStream I assume that there are no techniques like detecting duplicate values and writing references or writing small number on fewer bytes.
My suggestion is to use AMF/Hessian rather than Java serialization whenever you can – you will be able to save a lot of bandwidth.
The result table is below, and you can download the source code from here.
| Avg Time (microseconds) | Data size (kbytes) | |
| AMF3 | 9945 | 28 |
| Hessian | 4675 | 29 |
| Java serialization | 6400 | 60 |
| AMF3+Deflate | 34479 | 14.5 |
| Hessian+Deflate | 6076 | 14 |
| Java serialization+Deflate | 19193 | 22 |
| XML | 22064 | 158 |
| XML+Deflate | 27336 | 18 |
Posted by cornel | Filed under Flex, Uncategorized
I have identified three cases in which you may want to extract parameters passed via the URL to your Flash application:
a)The URL is something like this: http://www.test.com/page.html?parameter=test. The SWF file is included in the HTML page.
Solution: Use the ExternalInterface to extract the data from URL. It’s not a nice solution but I do not know another option. The code is below:
private function readParameters():Object{ var params:String =
ExternalInterface.call("window.location.search.substring"); return (params?(new URLVariables(params.substring(1))):null); }
b)The URL is something like this: http://www.test.com/page.jsp?parameter=test. The SWF is included in the JSP page. The JSP will be rendered to produce HTML output.
The same solution from a) works. However, it is also possible to read the parameters from the Java code with request.getParameter() and add them to AC_FL_RunContent.. invocation.
AC_FL_RunContent(
"src", "test_test",
"width", "100%",
"height", "100%",
"align", "middle",
"id", "test_test",
"quality", "high",
"bgcolor", "#869ca7",
"name", "test_test",
"flashvars", "paramOne=test1¶m2=test2",
"allowScriptAccess","sameDomain",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
Now you can read the parameters with the following code:
var params:Object = Application.application.parameters
c)The SWF is called directly. for example http://www.test.com/myswf.swf?parameter=test
In this case you can read the parameters again using the code from b)
var params:Object = Application.application.parameters
Posted by cornel | Filed under Uncategorized
One of my friends told me about some online game called Tanki Online…I’m not a big fan of online multiplayer games but this game is really cool. It’s implemented in Flash with some impressive 3D effects. They released the game for open test and it seems that a lot of people are using it (sometimes you cannot play because the server is overloaded).

Posted by cornel | Filed under Flex, Java, Uncategorized
You can pack and send your data using AMF even if you don’t use the remoting services. In this post I will show several ways to do that using HTTP services. Why would you want to do that ? There are organizations or departments that expose only REST and SOAP services and it can be hard to persuade them to add the remoting services. In this case, when using web services, you have two solutions: you can create XML from your object graph (and for that you’ll have to write extra code) and apply a compression algorithm on it, or you can apply AMF serialization on the object graph, add the resulting byte code in the service body, and deserialize the AMF format on the client side.
Below is a sample how to do that. First, the Java code on the server:
public void service(ServletRequest arg0, ServletResponse response) throws ServletException, IOException { Product product = new Product("name","description"); SerializationContext context = new SerializationContext(); context.instantiateTypes = true; ByteArrayOutputStream baos = new ByteArrayOutputStream(64*1024); Amf3Output amf3Output = new Amf3Output(context); amf3Output.setOutputStream(baos); amf3Output.writeObject(product); amf3Output.flush(); response.getOutputStream().write(baos.toByteArray()); }
On the client you have two options. The easier one is to use an URLLoader.
private function loaderCompleteHandler(event:Event):void { //rebuild the object var product:Product = loader.data.readObject(); } function sendData(event:Event){ var request:URLRequest = new URLRequest("/test/loaddata/"); loader = new URLLoader(); loader.dataFormat = URLLoaderDataFormat.BINARY; loader.load(request); loader.addEventListener(IOErrorEvent.IO_ERROR, errorHandler); loader.addEventListener(Event.COMPLETE, loaderCompleteHandler); }
If you want to use an HTTPService you have a problem, because by default it does not handle binary data. However it’s easy to extend the class and to add binary support.
public class HTTPServiceExt extends HTTPService{ protected static var binaryChannel:Channel; protected static var binaryChannelSet:ChannelSet; public var binaryData:Boolean; public function HTTPServiceExt(){ } override public function send(parameters:Object = null):AsyncToken{ if (( useProxy == false ) && (binaryData)){ if ( binaryChannelSet == null ){ var dcs:ChannelSet = new ChannelSet(); binaryChannel = new DirectHTTPBinaryChannel("directhttpbinarychannel"); dcs.addChannel(binaryChannel); channelSet = dcs; binaryChannelSet = dcs; } else if ( channelSet != binaryChannelSet ){ channelSet = binaryChannelSet; } } return super.send(parameters); } }
The class DirectHTTPBinaryChannel is taken from Anirudh Sasikumar’s blog. It extends DirectHTTPChannel and it configures the internal URLoader to work with binary data.
Now you have an HTTPService class that knows how to receive binary data also. In order to use it you have to add the binaryData parameter:
function resultCall(event:ResultEvent):void{ var product:Product = event.result.readObject(); } <local:HTTPServiceExt binaryData="true" id="srv" url="/test/loaddata/" result="resultCall(event)" fault="faultCall(event)"/>
That’s all. You can refine the code; for example you may want to create only one URL for all the resources and to pass parameters, or you can use SOAP services and add the AMF binary format as an attachment.
I also uploaded a Flex/WTP project here containing all the source code.
Posted by cornel | Filed under Uncategorized
Blueprint is a plugin for Flex Builder that allows the developer to search for code samples directly from the IDE. No need for switching between IDE and the web browser. Unfortunately works for the moment only for Mac
.