November 8, 2006

Adobe FDS2 - US$20K

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 10:13 am

Looking through the Adobe website I came across the pricing structure for the Flex Data Services 2 framework, the enterprise edition costing $20K per CPU. A budget that would be un-achievable to most, and even in a high-load website, you will most likely have to setup a clustered environment, meaning that you will most likely be up for more than one licence. Ouch!
So where does that leave us? We can consider the other technologies that are available, including XML and WebServices. Both work in plain text XML which works like a dream for small data transfer, but you quickly consider the amount of formatting and XML document places around the data and often the formatting takes up a lot of the file size, bloating it out. (This may be remedied slightly through GZip compression over HTTP, but I need to investigate…).

So if we still want Flash Remoting without the price tag where do we turn? - Open Source

Quoting a recent article I read I have often heard people claim “Companies do not invest into open source technologies” which I think is pretty wrong. A quote obtained from a recent article with Rasmum Lerdorf (a developer of open source technologies - PHP) when asked about ‘The Open Source movement is still portrayed by many as “anarchistic” and some kind of “threat to society”‘ :

As far as being mainstream, the product of this “movement” is most definitely mainstream. The “movement” built the Internet as we know it today. It built the TCP/IP stacks used in most of the operating systems people use (yes, even Windows). It built the most popular Web server in the world, along with the DNS and MTA systems that make the Internet tick. Heck, if you go back a bit, it built the entire industry. The first operating systems were all open source, because that was the only sane way to do things. You could not sell someone a big mainframe without providing the source to the brains of the thing. It was only later on that the concept of not providing the source code was introduced.

But I guess your real question is what I think of Microsoft’s attempt to convince the world that large groups of people collaborating to solve problems somehow threatens the very fabric of the society we live in. And I don’t think there are “many” people making this claim, as it is complete crap — I would like to think that the world is a good place and not full of people who would propagate such a ridiculous idea. Let’s put an end to all meetings of large groups of people while we are at it. They might be evil anarchists out to destroy the world.

In the end, mainstream acceptance is not the goal. The goal for most people who work on free software and open source projects is the technology itself. It is building a tool that solves the problem. It is not about ideology for most of us, and as such, mainstream acceptance only involves mainstream use of the technology. This has been achieved on many fronts already, with many more still to come.

Getting past the whole Corporate versus Community conversation and moving on;

PHP as a thin layer provides great database layering, with a nice framework AMF-PHP which could handle basic output to flex. This framework works great, but still has around 40-50ms class instantiation cost per request (which may be considered pretty low, and can be tuned with APC). Making the move to a JEE environment means that we can handle database queries through a JDBC environment, bringing JDBC equivalent database into PHP means more overhead, and unless you go that path it makes it more difficult to make your whole project scalable. But discussing PHP and JEE performance is not the point of this article, we are talking about alternatives.
OpenAMF is a JEE alternate to the Flash Data Services offered by Adobe. I found a nice little introduction to openAMF with this article. Although a slightly bloated introduction regarding JEE, PHP and ActionScript it is still relevant to conversations we have been starting on this blog, such as “Where does PHP really sit?

One of the cumbersome of using Java is the relatively complex setup of Java applications, with different steps based on the container. J2EE helps on this, exposing a more standard framework to follow for web developers. Also Java is not a common shared hosting offer, and this make sense because the power of java and his multithread run shines in big applications or when a lot of traffic is expected, due also to the live of servlets in memory. Usually little-medium applications fits fine in more straightforward languages like PHP. So freelancers developers not involved in big corporations are not usually faced to Java, and it’s a shame, because it’s a great language. But the grow of ActionScript from AS1 to AS2 force coders to write in a more Java-like (or should say OOP-like) way, so Java seems more familiar to them. And AS3 will reinforce this being a really truly class based language (in fact, not compatible with previous versions of the Flash Player) All of this make the jump to Java less heavy for actionscript coders, at least with Java in relationship with Flash.

Being Java a wide field, probably Flash developers will be faced first in data exchange with Java. This could be done in many faces, in example name/value pairs could be solved with some jsp file, but the really power of data exchange is exposed trough Flash Remoting. Even java can map ActionScript classes to Java classes whit out problem, something that arises as a problem in the first implementations of other Remoting libraries like amfphp (last versions solve this) Also since the gateway runs as a servlet, is really fast in doing his work (except the first time of course).

You  can read more about AMF-PHP here for using PHP or take a look at JEE alternative OpenAMF.

November 7, 2006

Connection Pooling and Hibernate

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 9:01 pm

Connection pools are a smart way of maintaining connections so that they can be reused when the database receives future requests for data. Reading through the Hibernate documentation, Hibernate explains that the connection pooling algorithm used as default by Hibernate is not adequate for production, and recommends the c3p0 open source database connection pool’er.

Hibernate’s own connection pooling algorithm is however quite rudimentary. It is intended to help you get started and is not intended for use in a production system or even for performance testing. You should use a third party pool for best performance and stability. Just replace the hibernate.connection.pool_size property with connection pool specific settings. This will turn off Hibernate’s internal pool. For example, you might like to use C3P0.

You can find the c3p0 project on Sourceforge from this URL: http://sourceforge.net/projects/c3p0

C3P0 is an open source JDBC connection pool distributed along with Hibernate in the lib directory. Hibernate will use its C3P0ConnectionProvider for connection pooling if you set hibernate.c3p0.* properties. If you’d like to use Proxool refer to the packaged hibernate.properties and the Hibernate web site for more information.

c3p0 is an easy-to-use library for augmenting traditional (DriverManager-based) JDBC drivers with JNDI-bindable DataSources, including DataSources that implement Connection and Statement Pooling, as described by the jdbc3 spec and jdbc2 std extension.

You can read about Connection Pooling on wikipedia, or read this documentation on how to configure hibernate to use c3p0.

As a note to PHP users, PHP creator Rasmus Lerdorf discusses about the lack of connection pooling in PHP (as well as all the other hard questions of PHP). People can check out SQLRelay as a way of helping implement connection pooling, but requires a server install.

SQL Relay is a persistent database connection pooling, proxying and load balancing system for Unix and Linux supporting ODBC, Oracle, MySQL, PostgreSQL, Sybase, MS SQL Server, IBM DB2, Interbase, SQLite and MS Access (minimally) with APIs for C, C++, Perl, Perl-DBI, Python, Python-DB, Zope, PHP, Ruby, Ruby-DBI, Java and TCL, drop-in replacement libraries for MySQL and PostgreSQL clients, command line clients, a GUI configuration tool and extensive documentation. The APIs support advanced database operations such as bind variables, multi-row fetches, client-side result set caching and suspended transactions. It is ideal for speeding up database-driven web-based applications, accessing databases from unsupported platforms, migrating between databases, distributing access to replicated databases and throttling database access.

November 6, 2006

JSP - Displaying Date/Time notes

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 9:30 pm

Having a hunt I came across the article on JavaRanch about displaying Date/Time on JSP pages with a few different strategies. Displaying a date/time really needs to be localised for i18n (internationalisation) standards and needs to involve the Locale/getLocale().

JSP - linking to URL with additional parameters

You will find other articles relevant to this document in these sections:
Cameron Manderson @ 9:24 pm

Having a muck around with JSP’s with struts lead me across a scenario where multiple parameters need to be parsed through to another action. Although probably simpler to do using a manual link, using the html:link taglib is preferred so that we can change our servlet configuration/URL. When I investigated into the issue it appears that you need to parse across a HashMap in the pageContext, which involves some initial JSP tags - not very pretty. The other way of doing it is to use the c:url of the JSTL package if it is available to you.
You can read through the discussion thread here.