Developing J2EE and .NET-Agnostic Web Applications in

Document Sample
Developing J2EE and .NET-Agnostic Web Applications in Powered By Docstoc
					                                                      Developing J2EE and
                                                      .NET-Agnostic Web
                                                      Applications in
                                                      By Armeen Mazda

                                                any of today’s companies are        The Appeon for PowerBuilder

How to create PowerBuilder           M          moving from a PowerBuilder
                                                client/server to an N-tier web
                                     architecture in order to extend the reach
                                                                                    Before discussing how to build an J2EE
                                                                                    and .NET-agnostic application, it will help
applications for the web             of applications to employees, partners,        to better understand how it works. First,
                                     customers and other external parties. This     we will examine how PowerBuilder maps
using Appeon                         helps to ensure that systems will be scal-     to the N-tier architecture:
                                     able, secure, easy to maintain, and accessi-   x Presentation Tier (web server/
                                     ble via the Internet from any location.            browser): The presentation layer,
                                         However, developing web applications           which is comprised of HTML and
                                     generally requires developers to choose a          JavaScript, deploys to the web server
                                     particular platform or technology stack to         and runs at the browser utilizing stan-
                                     build upon. Both .NET and J2EE are well            dard HTTP(S) protocol over port 80.
                                     known and for practical purposes can be            The HTML defines the layout of the
                                     considered as industry standards. Each             web application windows. The
                                     offers benefits and tradeoffs. For indepen-        JavaScript represents the web equiva-
                                     dent software developers, this decision is         lent of the PowerScript or UI logic
                                     even more vital, since ISVs tend to sell           coded in the Window object, user
                                     their solutions to firms that may be com-          object, menu object, and any other
                                     mitted to one or the other. At the same            visual objects.
                                     time, producing multiple versions of the       x Middle Tier (J2EE or .NET applica-
                                     same software package is prohibitively             tion server): The business logic and
                                     expensive.                                         DataWindows deploy to the J2EE or
                                         In this article, we examine how                .NET application server. On a J2EE
                                     PowerBuilder developers can avoid this             application server, the middle tier is
                                     catch-22 by creating “platform-agnostic”           implemented with pure Java code, and
                                     web applications designed for users whose          on a .NET server the middle tier is
                                     companies are committed to either .NET             implemented with pure C# code.
                                     or J2EE. As part of our discussion, we will        DataWindows and Embedded SQL
                                     use the Appeon for PowerBuilder product            coded in the presentation layer are
                                     to show how these applications can be              actually executed on the application
Armeen Mazda is senior director of   developed to take advantage of the J2EE            server or middle tier. Also, any non-
North America field operations at    and .NET environments while continuing             visual logic deployed to the applica-
Appeon Corporation. For more         to leverage PowerBuilder’s familiar tools          tion server is also executed on the
information, please contact          and techniques.                                    middle tier.

                                            D E V E L O P I N G   J 2 E E   A N D    . N E T- A G N O S T I C     W E B    A P P L I C AT I O N S

x   Data Tier (Database): The database stores the raw data
    for the application as well as host stored procedures, if any.
    Keep in mind that any development project has two
    deployment options: It can be deployed as a web applica-
    tion or as a desktop (client/ server) application. As such,
    the application and its corresponding client/server coun-
    terpart can share the same database, achieving automatic
    data integration between Internet and desktop.

Appeon for PowerBuilder is mainly composed of a Power-
Builder IDE plug-in and a set of runtime Java or .NET server
x Appeon Developer: An extension to PowerBuilder with
   compiler-like technology that allows web application
   generation, maintenance, and upgrades to be carried                Figure 1: Web project functionality
   out within the PowerBuilder IDE.

                                                                                                                                                    T O O L S
x Appeon Server: Composed of J2EE or .NET server                      Step 2. Develop the application.
   components that provide runtime services for the                   The application is developed according to best web coding
   deployed web application such as data connectivity,                practices, which include minimizing database server calls and
   transaction management, printing, security, DataWindow,            using supported PowerBuilder features (documented in the
   and PowerBuilder user interface support.                           manual at
x Appeon Server Web Component: A series of JavaScript                 1. Create an application such as case2.
   web components utilizing AJAX technology to generate               2. Create a main window such as w_main.
   a PowerBuilder-style GUI in the standard Microsoft                 3. Drag your selected controls onto the window w_main.
   Internet Explorer browser.                                         4. Add instance variables into the window w_main.
                                                                      5. Add PowerScript in an event handler to respond to a user
Starting the J2EE and .NET-Agnostic Web Project                           event, such as “Clicked”.
in PowerBuilder                                                       6. Add PowerScript to establish the database connection
There are three high-level steps to building cross-platform               when the window w_main is opened (i.e., the “Open”
Web applications with Appeon, which are not significantly                 event).
different from developing PowerBuilder client/server applica-
tions. The following is a simple example to illustrate the                  //setting connection database information for SQLCA
development process:                                                        ...
                                                                            Connect sqlca;
Step 1. Analyze the project requirements.                                   If sqlca.sqlcode = 0 then
                                                                            open (w_main)
Let’s say that we want to create a single window containing
four tab pages where each tab page contains information pre-
                                                                            messagebox(‘error’,’fail to connect database!’)
sented in a grid format (see Figure 1). In the first tab page
                                                                            end if
“Order,” the user can search orders by order ID, and also
insert, delete, and retrieve records. If there are two or more
pages, then the user can easily navigate the records. Each            Step 3. Test the New Application.
Order ID will contain details that will be displayed on the           After completing these steps, your PowerBuilder client/server
remaining three tab pages: “Order Details 1,” “Order Details          application should be ready. You can test and run the
2,” and “Order Details 3.” The user can search records by the         client/server application in PowerBuilder.
order ID and selecting the particular Order ID will display
associated detail information in the remaining three tab pages.

                                                                                                        THIRD QUARTER 2006                   49
D E V E L O P I N G   J 2 E E   A N D   . N E T- A G N O S T I C   W E B   A P P L I C AT I O N S

Preparing the Web Application for Deployment to
J2EE and .NET
Appeon provides a number of tools to help ensure that the
PowerBuilder project successfully deploys onto the web. For
example, the Code Insight tool prevents developers from cod-
ing any PowerScript code that is not supported on the
Internet for automatic deployment to J2EE and .NET. It
accomplishes this by providing a lookup and paste service that
displays only supported PowerScript. Although Appeon for
PowerBuilder 5.0 currently supports nearly 90% of common
functionalities of PowerBuilder, there are some obscure or
quirky PowerScript that may be problematic.
    When Code Insight is enabled for a particular application,
the user may start editing the application objects. For exam-              Figure 3: Debugging the Web application
ple, take the following steps to add a new control and use
Code Insight to edit it:                                                   Deploying the Application to EAServer, WebLogic,
x Step 1 – Add a button to the current object in the Painter.              WebSphere and .NET Servers
x Step 2 – Save the object by clicking the Save button in                  Once your application is well-tested and working properly, the
    the PowerBar.                                                          final step is to automatically deploy the PowerBuilder project
x Step 3 – Double-click the button to open the Script view                 to the web. The process of deploying the new web application
    and pause for a micro-second after typing an identifier fol-           to various J2EE application and .NET servers is essentially the
    lowed by a dot (for example, pause after “This.”). If there            same (except slightly different configurations). The server
    is more than one property, variable, method, or statement              profiles and deployment profiles must be configured prior to
    that could be inserted, the Code Insight feature list pops             deployment to Sybase EAServer, BEA WebLogic, IBM
    up to allow you to select a supported property, variable or            WebSphere, or Microsoft .NET Web and application servers.
    method, as shown in Figure 2. You can select a supported                   Figure 4 shows the step of configuring a server profile for
    property, variable or method from the popup list.                      local deployment (i.e., to a Web and application server
                                                                           installed on the developer’s [local] machine).

Figure 2: Code Insight and unsupported features displayed in
popup window

In the event of some functionality working improperly, the
Appeon Debugger allows developers to directly debug the
application in the PowerBuilder IDE, will pinpoint the exact
line of PowerScript which may cause online runtime issues.                 Figure 4: Server profiles configuration
This tool offers all the debugging capabilities as the Power-
Builder Debugger; you can set breakpoints or monitor variables             Clicking the “Edit” button for Appeon Server opens the win-
of the PowerBuilder source code as shown in Figure 3.                      dow shown in Figure 5, where you may specify the server con-
                                                                           nection information, such as the server name or IP address
                                                                           and port number.

                                                D E V E L O P I N G   J 2 E E   A N D   . N E T- A G N O S T I C   W E B   A P P L I C AT I O N S

                                                                          Examining the Results
                                                                          To determine whether our web project was successful, let’s
                                                                          examine the resulting technology-agnostic application from
                                                                          several perspectives, including functionality, interoperability,
                                                                          scalability, productivity, and maintainability (Figure 6).
                                                                              Using Appeon for PowerBuilder, which utilizes AJAX
                                                                          technology, has allowed us to eliminate slow page refreshes,
                                                                          because data queried is retrieved and updated in the browser
                                                                          (“micro-refreshed”) without reloading the entire page.
                                                                          Developers are also able to manage the state of controls at
                                                                          PowerBuilder’s level of detail. Controls can be visible or invis-
                                                                          ible, or alternatively, enabled or disabled (also known as
                                                                          “dimmed” or “grayed-out”).
Figure 5: Appeon Server profile configuration                                 True Edit Masks and Format Styles are rarely seen in web
                                                                          applications because the JavaScript needed to implement
To configure a deployment profile, select one or more web                 them and the validation surrounding them is difficult to

                                                                                                                                                    T O O L S
servers and application servers (“Appeon Servers”) already                create and to run efficiently. However, Appeon’s Edit Masks
configured in the server profiles step above. When the                    consists of PowerBuilder properties that require no coding.
application is deployed with a particular profile, the web                Dozens of PowerBuilder Edit Masks for Strings, Numbers,
files and DataWindows will be deployed to the web and                     Dates, Times, and DateTimes are supported and automatically
application servers.                                                      moved into a web format, providing validation mechanism on
     Deploying the same project to another application server             the browser side to eliminate the wait for a server response.
requires the creation of additional server profiles. If, for exam-            Based on industry standards, the web application that is
ple, Sybase EAServer is installed on your local machine, you              deployed to a J2EE application server is also readily integrated
will have a “Local EAServer” deployment profile. Through                  with J2EE components such as EJBs and servlets, can consume
these deployment profiles, you gain J2EE and .NET Web                     Web services, and may utilize the Windows API (if running
deployment capability without any changes required of the                 on Windows operating system), as well as C/C++ code encap-
underlying project.                                                       sulated as DLLs. The application deployed to a .NET server
                                                                                                              can integrate with .NET
                                                                                                              and COM/COM+ compo-
                                                                                                              nents, utilize the Windows
                                                                                                              API, and consume Web
                                                                                                                   On the browser side, the
                                                                                                              application takes advantage
                                                                                                              of all standard integration
                                                                                                              techniques, including utiliz-
                                                                                                              ing the Windows API and
                                                                                                              external functions (DLLs),
                                                                                                              OLE/OCX controls and
                                                                                                              objects, execute registry and
                                                                                                              file functions, and launch-
                                                                                                              ing desktop applications
                                                                                                              with the PowerBuilder run
Figure 6: Appeon Web application integration capability                                                       command.

                                                                                                        THIRD QUARTER 2006                   51
D E V E L O P I N G   J 2 E E   A N D   . N E T- A G N O S T I C   W E B   A P P L I C AT I O N S

    The web application can also be deployed to a cluster of
web servers and application servers with load balancing and
failover. This allows the system to handle a growing user base
without re-architecting the application. When a server or
resource within the cluster becomes unavailable, it will be
transferred to another without disruption in availability. The
web application additionally takes advantage of “connection
pooling,” in which it connects to the database through the
application server’s connection pool or cache via a standard
JDBC or ODBC interface. Connection pooling does not
require a unique database connection to be established;
rather, it shares and swaps the database connections to reduce
load on the database. This can boost database scalability by
several times.
    Finally, to examine the developer productivity of Appeon               Figure 7: Functionally-equivalent J2EE Web application built with
for Powerbuilder, the same sample application was developed                the Eclipse IDE
J2EE utilizing the Eclipse IDE and JSPs, shown as Figure 7.
    It was found that Appeon for PowerBuilder development                  Future Maintenance
required 125 lines of code, developed by a PowerBuilder pro-               Future maintenance of the application is now a matter of
fessional; while a J2EE professional had to write 2,313 lines of           opening the existing application in PowerBuilder, making
code to accomplish the same goal.                                          changes, and automatically redeploying them through
                                                                           Appeon’s incremental web deployment functionality. s

  Got a great tip for DBAs or                                              Consider writing an article for
  developers? Some great                                                   the ISUG Technical Journal!
  advice, a new method, or
  excellent syntax?                                                        Becoming an author for the Journal helps build
                                                                           your resume, establish your reputation, and
                                                                           share your great concepts with fellow ISUG
                                                                           members. For more information, check out
                                                                           the ISUG Technical Journal Online to see
                                                                           sample articles and guidelines for authors.
                                                                           Then contact Managing Editor Mary Freeman
                                                                           at freemancomm@ to discuss
                                                                           your article concept.



Shared By: