Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Employing a Winning Porting Strategy

Find out how you can cross-compile an open source ASP.NET web application to a Java EE application, to easily port it from Windows and SQL Server Express to Tomcat and MySQL.


advertisement
n the recent "Race to Linux 2.0" competition, a .NET programming event hosted by DevX, .NET developers were invited to get ASP.NET applications up and running on Linux. The three-part competition allowed entrants to download preselected .NET applications and either port them or rewrite them to run on Linux, using any other technologies of their choosing.

I chose to port the Blog Starter Kit to the Java Enterprise Edition (Java EE) platform using Mainsoft for Java EE, Developer Edition (Grasshopper 2.0). The Blog Starter Kit is an open source ASP.NET application developed by Shanku Niyogi for users who want to adopt and customize an easy-to-use blog application for their site. Grasshopper is a Visual Studio 2005 extension that enables you to cross-compile an ASP.NET 2.0 web application project to a Java EE application and run it on Linux. The combination of Grasshopper and VMware Server for the MySQL Virtual Appliance made porting the Blog Starter Kit very easy. To begin, take a look at the application chosen for this solution.

The Blog Starter Kit
The Blog Starter Kit is an open source, ASP.NET 2.0 application. It works out of the box with a small amount of configuration, and it offers interesting features such as a rich text editor for formatting posts, the ability to expose the blog as an RSS feed, and an email notification for posted comments. The application works with IIS on Windows 2003 or IIS on Windows XP. Using Grasshopper, you can port the Blog Starter Kit to run on Java under Linux and migrate the database in less than a day.



Grasshopper bridges the gap between .NET and Java EE by extending the Visual Studio IDE with a robust code-porting toolkit. When you build an ASP.NET application, the C# compiler compiles the program code into an assembly containing Microsoft Intermediate Language (MSIL). To execute the MSIL the .NET Common Language Runtime (CLR) compiles the assembly into a platform-specific instruction set.

Grasshopper converts that same MSIL code into Java bytecode. Grasshopper rehosts the Mono .NET Framework libraries on Java to deliver key .NET functionality on the Java EE platform. (Note that Mono is an open source, cross-platform implementation of the .NET Framework—Mainsoft is a contributor.) Grasshopper deploys your applications to a Tomcat application server, along with a Java implementation of the .NET namespaces. With very few changes to an original .NET application, you can "hop" into Java.

To get started with the porting project, first you'll step through the process of preparing to port the Blog Starter Kit:

  1. Install the Grasshopper 2.0 extension into Visual Studio 2005 to open the sample project.
  2. Download the Blog Starter Kit sample project. Unzip it to a directory of your choosing, and then open Visual Studio 2005.
  3. Select File --> Open --> Web Site, and browse to the project folder that you just unzipped (BlogWebApplication folder).
  4. Once you've loaded the Web application project, look for a file called Welcome.html, which outlines the functionality of the Blog Starter Kit. Follow the instructions for creating an administrative user.

Before you begin the port, it's a good idea to run the web site to make sure it functions as expected. Press the F5 key or click the Play button to run the web site from Visual Studio's built-in web server.

Connecting to a SQL Server in a hybrid Windows/Linux network is one approach to porting the application. For example, you can change the C# code to access MySQL using the OleDb ADO.NET provider and the MySQL JDBC driver.

Editor's Note: This article was contributed through Mainsoft. We have selected this article for publication because we believe it to have sufficient, objective technical merit, and it was written by an independent developer.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date