April 5, 2010

Comparison of Web Proxy Portlet, Portletbridge and html2jsr286

There are at least three different JSR 168 / 286 portlet projects that have a similar target: to allow custom web apps and arbitrary web content be accessible in portlets.

I am the author of "Rails-portlet" and it's alive - I just updated the setup guide. It all started when I needed to develop a webapp for Liferay, and I wanted to do it with Rails. html2jsr286 is not an indication of the NIH syndrome, I just now learned of their existance. I inspected their source code, and this is a quick run-down of their features and pondering of future direction.

These are the common features in all three projects:

  • Getting content from a downstream site
  • Proxying of remote resources (e.g. images, Flash etc.)
  • Regular expression defining which URL's are in the portlet and which should be regular links
  • Rewriting CSS urls
  • Moving Javascript and CSS links out of the head
  • Session cookie support
All three have the same shortcoming concerning Ajax: the urls are not being rewritten so that XHR from the browser is not catched by the portlet.

WebProxyPortlet is being developed mainly for uPortal, and

..it provides mechanisms for connecting to and rendering HTML with options for clipping, maintaining session information, handling cookies. Proxied content is rendered within the portlet window. Web Proxy Portlet is often used to incorporate web content or applications that are built and run in non-Java environments allowing a site flexibility for integrating with many different technologies.

Sources of portletbridge

$ mkdir portletbridge
$ cd portletbridge/
$ cvs -z3 -d:pserver:anonymous@portletbridge.cvs.sourceforge.net:/cvsroot/portletbridge co -P .
Sources of WebProxyPortlet
$ svn co https://www.ja-sig.org/svn/portlets/WebproxyPortlet/trunk/ WebproxyPortlet
Sources of html2jsr286
$ git clone git@github.com:lamikae/html2jsr286.git

My impression after a while looking through the sources is that WebProxyPortlet is the most advanced, and has a number of nice features, especially in ways of user authentication and portlet configuration through the user interface.

Considering code cohesion and the number of Java classes: WebProxyPortlet has 58, Portletbridge 51 and html2jsr286 only 10 Java source files. Here are links to their main view methods:

void renderContent(final RenderRequest request, final RenderResponse response) in WebProxyPortlet.java
void doView(final RenderRequest request, final RenderResponse response) in BridgeViewPortlet.java
void render(RenderRequest request, RenderResponse response) in Rails286Portlet.java

WebProxyPortlet works in JSR 168 containers and supports a variety of authentication techniques, handles caching, has pluggable Java classes for custom request filtering and page processing. On top of this is uses a whole lot of JavaBeans and JSPs that make the portlet configurable from the GUI in the portlet config mode. I am not sure how much runtime overhead this accouts to, and how useful it is to let users select the HTML parser the portlet is going to use. Page processing is implemented by chaining up SAX filters.

Some criticism must be given; there are virtually no unit tests and there seems to be some code repetition and lots of "boilerplate" code (which is quite difficult to neutralize in Java) and somehow it just hurts me that the renderContent() method is 374 lines long. It could use some refactoring.

Portletbridge seems to have stalled active development some years ago, but there seems to be some recent code cleanup in progress, according to CVS logs.. It probably is doing what it's supposed to, feature-wise it seems to be close on par with html2jsr286, and it runs on JSR 168 portals. Page processing is done by XSLT, a feature that I really like.

html2jsr286 and Rails-portlet are strong in that they offer a toolchain for a Rails developer to get quickly into deployment with as much automation as possible. The other two projects look like they are more tuned to serve the portal administrator instead of the development team. The Rails-portlet project tools can also work without Rails, but then the deployment gets more encumbered, requiring more dirty work with Java and XML. Rails-portlet is targeting for web app developers who want to keep a healthy distance to the J2EE stack and "get things done" quickly.

html2jsr286 passes the Liferay UID in request headers, with a unique authentication mechanism. It can also handle Liferay GID – feature that is missing from the other two portlets. It is, however, restricted for JSR 286 portals, as it makes use of portlet filters, which were introduced only in JSR 286. The rationale behind this is to improve code coherence (there are no technical reasons that would demand using filters). JSR 286 container will, however, be needed for the XMLPortletRequest feature. The portlet is being used on at least two production sites, and in practise is doing fairly well. Page processing is done by HTML Parser, which does a decent job but has shortcomings that I would like to address with XSLT, and this is what Portletbridges is doing.

Nonetheless, I am considering a rational move to leverage WebProxyPortlet in Rails-portlet, and it seems that the first step is to get it running on Liferay and uPortal, hosting the portlet test bench.

Next big step would be to work on Ajax support, by carrying out ideas from these posts to implement XMLPortletRequest.


Gary S. Weaver said...

Great post! Very interested in using Ruby/Rails for portlets, and had tried using WebProxyPortlet previously, but you've done a much more thorough analysis!

FanWei said...

It's a good article to compare the methods using HTML modifying on the client side. Could we provide some methods on server side such as JSF 301?

Maged Makled said...

I tried your rails setup but I got an exception
java.lang.UnsupportedClassVersionError: Bad version number in .class file (unable to load class com.celamanzi.liferay.portlets.rails286.Rails286PortletFilter)
java.lang.Class.forName0(Native Method)

by the way I'm using liferay 6.0.1 with tomcat 6.0.26 and rails 2.3.5.


Maged Makled

Mikael said...

@Maged -

the class name changed in 0.10, but not in my branch. I merged the branches just a few days ago so if you run everything from git, now you should be fine. Recreate the JAR and your XML files. If you are using releases, you need to use the JAR packaged in Caterpillar.

Actually you are not the only one hit by this, it was asked on the mailing list a few days ago, and replied by Tulios (whose branch made this change ;)


fine said...

Hi, I downloaded WebproxyPortlet and use mvn build a war file, and deploy to Liferay portal successfully.

But when I add WebproxyPortlet to the liferay portal web page, the portlet doesn't show up on the web page.
I used Firebug find out its css style of the portlet header and tables are missing.

Can you tell me where can I add the css / html styles in the jsp files? I mean which jsp files I should modify?

My email is samwun@ixsystems.com.au

Mikael said...

@fine - I am not really knowledgeable of finer deployment details of WebProxyPortlet. However, the css and js files should always be separate from the jsp files. Inspect your Liferay HTML in Firebug to see where it goes awry.

Rose said...

really very nice information sharing and i am looking for such type of informative news and i get through this blog so i am very much thankful to you.
- liferay clustering

Mikael said...

Thanks for the comments. :)
Seatecnologia in Brazil has been an active contributor to Rails-portlet and they are very good with custom Liferay-ROR services.


Nicola said...

Does anyone make Webproxy portlet works on GateIn portal? I'm tring but I'm getting a lot of errors. In the case of anyone makes it run, are there some good idea about some web proxy portlet on GateIn?


Mikael said...

@Nicola - I've been working with getting Rails-portlet to run inside GateIn portal. My local dev version is now running, but there seems to be a problem with actionScopedRequestAttributes feature. This feature is needed for POST requests. I filed a bug about it, I'll see what's the response.

There is a workaround it, which would work on GateIn and possibly other portals as well, I may consider going that route.

Kai Wähner said...

Rails-portlet seems to be an interesting project. I wonder if it is still maintained?

The website still states "Rails 2", thus I wonder if it is compatible with "Rails 3", too?

Best regards,
Kai Wähner (Twitter: @KaiWaehner)

Alebri78 said...

I can not configure web proxy portlet on liferay 6.1, con you help me?


thanks very nice information sharing
proxy web
proxy web

This comment has been removed by the author.
John Miller said...

Interesting information. Thanks for sharing such nice and informative post. unblock YouTube